提交 516ff43a 编写于 作者: fxy060608's avatar fxy060608

feat: add __UNI_FEATURE_RPX__

上级 e9fa8d40
......@@ -15,6 +15,7 @@ declare var __VUE_OPTIONS_API__: boolean
declare var __UNI_FEATURE_WX__: boolean
declare var __UNI_FEATURE_WXS__: boolean
declare var __UNI_FEATURE_RPX__: boolean
declare var __UNI_FEATURE_NVUE__: boolean
declare var __UNI_FEATURE_PROMISE__: boolean
declare var __UNI_FEATURE_LONGPRESS__: boolean
......
import { withModifiers } from 'vue'
import safeAreaInsets from 'safe-area-insets'
export const onTouchmovePrevent = /*#__PURE__*/ withModifiers(() => {}, [
'prevent',
])
export const onTouchmoveStop = /*#__PURE__*/ withModifiers(() => {}, ['stop'])
export function getWindowOffset() {
const style = document.documentElement.style
const top = parseInt(style.getPropertyValue('--window-top'))
const bottom = parseInt(style.getPropertyValue('--window-bottom'))
const left = parseInt(style.getPropertyValue('--window-left'))
const right = parseInt(style.getPropertyValue('--window-right'))
return {
top: top ? top + safeAreaInsets.top : 0,
bottom: bottom ? bottom + safeAreaInsets.bottom : 0,
left: left ? left + safeAreaInsets.left : 0,
right: right ? right + safeAreaInsets.right : 0,
}
}
interface PageCssVars {
'--window-top'?: string
'--window-bottom'?: string
'--window-left'?: string
'--window-right'?: string
'--window-margin'?: string
'--top-window-height'?: string
}
const style = document.documentElement.style
export function updateCssVar(cssVars: Record<string, any>) {
Object.keys(cssVars).forEach((name) => {
style.setProperty(name, cssVars[name])
})
}
export function updatePageCssVar(cssVars: PageCssVars) {
return updateCssVar(cssVars)
}
interface AppCssVar {
'--status-bar-height'?: string
'--tab-bar-height'?: string
}
export function updateAppCssVar(cssVars: AppCssVar) {
return updateCssVar(cssVars)
}
const sheetsMap = new Map()
export function updateStyle(id: string, content: string) {
let style = sheetsMap.get(id)
if (style && !(style instanceof HTMLStyleElement)) {
removeStyle(id)
style = undefined
}
if (!style) {
style = document.createElement('style')
style.setAttribute('type', 'text/css')
style.innerHTML = content
document.head.appendChild(style)
} else {
style.innerHTML = content
}
sheetsMap.set(id, style)
}
export function removeStyle(id: string) {
let style = sheetsMap.get(id)
if (style) {
if (style instanceof CSSStyleSheet) {
// @ts-ignore
const index = document.adoptedStyleSheets.indexOf(style)
// @ts-ignore
document.adoptedStyleSheets = document.adoptedStyleSheets.filter(
(s: CSSStyleSheet) => s !== style
)
} else {
document.head.removeChild(style)
}
sheetsMap.delete(id)
}
}
import { withModifiers } from 'vue'
export const onTouchmovePrevent = /*#__PURE__*/ withModifiers(() => {}, [
'prevent',
])
export const onTouchmoveStop = /*#__PURE__*/ withModifiers(() => {}, ['stop'])
import safeAreaInsets from 'safe-area-insets'
export function getWindowOffset() {
const style = document.documentElement.style
const top = parseInt(style.getPropertyValue('--window-top'))
const bottom = parseInt(style.getPropertyValue('--window-bottom'))
const left = parseInt(style.getPropertyValue('--window-left'))
const right = parseInt(style.getPropertyValue('--window-right'))
return {
top: top ? top + safeAreaInsets.top : 0,
bottom: bottom ? bottom + safeAreaInsets.bottom : 0,
left: left ? left + safeAreaInsets.left : 0,
right: right ? right + safeAreaInsets.right : 0,
}
}
export * from './dom'
export * from './util'
export * from './icon'
export * from './event'
export * from './scroll'
export * from './getRealRoute'
export * from './updateCssVar'
export * from './getWindowOffset'
interface PageCssVars {
'--window-top'?: string
'--window-bottom'?: string
'--window-left'?: string
'--window-right'?: string
'--window-margin'?: string
'--top-window-height'?: string
}
const style = document.documentElement.style
function updateCssVar(cssVars: Record<string, any>) {
Object.keys(cssVars).forEach((name) => {
style.setProperty(name, cssVars[name])
})
}
export function updatePageCssVar(cssVars: PageCssVars) {
return updateCssVar(cssVars)
}
interface AppCssVar {
'--status-bar-height'?: string
'--tab-bar-height'?: string
}
export function updateAppCssVar(cssVars: AppCssVar) {
return updateCssVar(cssVars)
}
import { ComponentPublicInstance } from 'vue'
import { normalizeTarget } from '@dcloudio/uni-shared'
import { getWindowOffset } from '../../helpers/getWindowOffset'
import { getWindowOffset } from '../../helpers'
const isClickEvent = (val: Event): val is MouseEvent => val.type === 'click'
const isMouseEvent = (val: Event): val is MouseEvent =>
val.type.indexOf('mouse') === 0
export function $normalizeNativeEvent(
this: ComponentPublicInstance,
evt: Event
) {
// normalizeNativeEvent
export function $nne(this: ComponentPublicInstance, evt: Event) {
// TODO 目前内置组件底层实现,也会进入以下处理逻辑,可能会有影响
const { currentTarget } = evt
if (!(evt instanceof Event) || !(currentTarget instanceof HTMLElement)) {
......
......@@ -8236,6 +8236,10 @@ function autoPrefix(style, rawName) {
// upx,rpx
const rpxRE = /\b([+-]?\d+(\.\d+)?)[r|u]px\b/g;
const normalizeRpx = (val) => {
// @ts-ignore
if (typeof rpx2px !== 'function') {
return val;
}
if (isString(val)) {
return val.replace(rpxRE, (a, b) => {
// @ts-ignore
......@@ -8398,7 +8402,7 @@ function createInvoker(initialValue, instance) {
if (timeStamp >= invoker.attached - 1) {
// fixed by xxxxxx
const proxy = instance && instance.proxy;
const normalizeNativeEvent = proxy && proxy.$normalizeNativeEvent;
const normalizeNativeEvent = proxy && proxy.$nne;
callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* NATIVE_EVENT_HANDLER */, [normalizeNativeEvent ? normalizeNativeEvent(e) : e]);
}
};
......
......@@ -8236,6 +8236,10 @@ function autoPrefix(style, rawName) {
// upx,rpx
const rpxRE = /\b([+-]?\d+(\.\d+)?)[r|u]px\b/g;
const normalizeRpx = (val) => {
// @ts-ignore
if (typeof rpx2px !== 'function') {
return val;
}
if (isString(val)) {
return val.replace(rpxRE, (a, b) => {
// @ts-ignore
......@@ -8398,7 +8402,7 @@ function createInvoker(initialValue, instance) {
if (timeStamp >= invoker.attached - 1) {
// fixed by xxxxxx
const proxy = instance && instance.proxy;
const normalizeNativeEvent = proxy && proxy.$normalizeNativeEvent;
const normalizeNativeEvent = proxy && proxy.$nne;
callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* NATIVE_EVENT_HANDLER */, [normalizeNativeEvent ? normalizeNativeEvent(e) : e]);
}
};
......
import {isFunction, extend, isPlainObject, isString, isArray, hasOwn as hasOwn$1, isObject as isObject$1, capitalize, toRawType, makeMap as makeMap$1, isPromise, invokeArrayFns as invokeArrayFns$1, hyphenate} from "@vue/shared";
import {injectHook, createVNode, withModifiers, inject, provide, reactive, computed, nextTick, getCurrentInstance, onBeforeMount, onMounted, onBeforeActivate, onBeforeDeactivate, openBlock, createBlock, mergeProps, toDisplayString, ref, defineComponent, resolveComponent, toHandlers, renderSlot, watch, onActivated, onBeforeUnmount, withDirectives, vShow, vModelDynamic, createTextVNode, createCommentVNode, Fragment, renderList, vModelText, onDeactivated, onUnmounted, createApp, watchEffect, Transition, withCtx, KeepAlive, resolveDynamicComponent} from "vue";
import {injectHook, withModifiers, createVNode, inject, provide, reactive, computed, nextTick, getCurrentInstance, onBeforeMount, onMounted, onBeforeActivate, onBeforeDeactivate, openBlock, createBlock, mergeProps, toDisplayString, ref, defineComponent, resolveComponent, toHandlers, renderSlot, watch, onActivated, onBeforeUnmount, withDirectives, vShow, vModelDynamic, createTextVNode, createCommentVNode, Fragment, renderList, vModelText, onDeactivated, onUnmounted, createApp, watchEffect, Transition, withCtx, KeepAlive, resolveDynamicComponent} from "vue";
import {once, passive, normalizeTarget, invokeArrayFns, NAVBAR_HEIGHT, parseQuery, PRIMARY_COLOR, removeLeadingSlash, getLen, ON_REACH_BOTTOM_DISTANCE, decodedQuery, plusReady, debounce, updateElementStyle, addFont, scrollTo} from "@dcloudio/uni-shared";
import {useRoute, createRouter, createWebHistory, createWebHashHistory, useRouter, isNavigationFailure, RouterView} from "vue-router";
function applyOptions(options, instance2, publicThis) {
......@@ -623,6 +623,12 @@ var safeAreaInsets = {
offChange
};
var out = safeAreaInsets;
const onTouchmovePrevent = /* @__PURE__ */ withModifiers(() => {
}, [
"prevent"
]);
const onTouchmoveStop = /* @__PURE__ */ withModifiers(() => {
}, ["stop"]);
function getWindowOffset() {
const style2 = document.documentElement.style;
const top = parseInt(style2.getPropertyValue("--window-top"));
......@@ -636,9 +642,170 @@ function getWindowOffset() {
right: right ? right + out.right : 0
};
}
const style = document.documentElement.style;
function updateCssVar(cssVars) {
Object.keys(cssVars).forEach((name) => {
style.setProperty(name, cssVars[name]);
});
}
function updatePageCssVar(cssVars) {
return updateCssVar(cssVars);
}
const sheetsMap = new Map();
function updateStyle(id2, content) {
let style2 = sheetsMap.get(id2);
if (style2 && !(style2 instanceof HTMLStyleElement)) {
removeStyle(id2);
style2 = void 0;
}
if (!style2) {
style2 = document.createElement("style");
style2.setAttribute("type", "text/css");
style2.innerHTML = content;
document.head.appendChild(style2);
} else {
style2.innerHTML = content;
}
sheetsMap.set(id2, style2);
}
function removeStyle(id2) {
let style2 = sheetsMap.get(id2);
if (style2) {
if (style2 instanceof CSSStyleSheet) {
document.adoptedStyleSheets.indexOf(style2);
document.adoptedStyleSheets = document.adoptedStyleSheets.filter((s) => s !== style2);
} else {
document.head.removeChild(style2);
}
sheetsMap.delete(id2);
}
}
function PolySymbol(name) {
return Symbol(process.env.NODE_ENV !== "production" ? "[uni-app]: " + name : name);
}
function rpx2px(str) {
if (typeof str === "string") {
const res = parseInt(str) || 0;
if (str.indexOf("rpx") !== -1 || str.indexOf("upx") !== -1) {
return uni.upx2px(res);
}
return res;
}
return str;
}
const ICON_PATH_CANCEL = "M20.928 10.176l-4.928 4.928-4.928-4.928-0.896 0.896 4.928 4.928-4.928 4.928 0.896 0.896 4.928-4.928 4.928 4.928 0.896-0.896-4.928-4.928 4.928-4.928-0.896-0.896zM16 2.080q-3.776 0-7.040 1.888-3.136 1.856-4.992 4.992-1.888 3.264-1.888 7.040t1.888 7.040q1.856 3.136 4.992 4.992 3.264 1.888 7.040 1.888t7.040-1.888q3.136-1.856 4.992-4.992 1.888-3.264 1.888-7.040t-1.888-7.040q-1.856-3.136-4.992-4.992-3.264-1.888-7.040-1.888zM16 28.64q-3.424 0-6.4-1.728-2.848-1.664-4.512-4.512-1.728-2.976-1.728-6.4t1.728-6.4q1.664-2.848 4.512-4.512 2.976-1.728 6.4-1.728t6.4 1.728q2.848 1.664 4.512 4.512 1.728 2.976 1.728 6.4t-1.728 6.4q-1.664 2.848-4.512 4.512-2.976 1.728-6.4 1.728z";
const ICON_PATH_CLEAR = "M16 0q-4.352 0-8.064 2.176-3.616 2.144-5.76 5.76-2.176 3.712-2.176 8.064t2.176 8.064q2.144 3.616 5.76 5.76 3.712 2.176 8.064 2.176t8.064-2.176q3.616-2.144 5.76-5.76 2.176-3.712 2.176-8.064t-2.176-8.064q-2.144-3.616-5.76-5.76-3.712-2.176-8.064-2.176zM22.688 21.408q0.32 0.32 0.304 0.752t-0.336 0.736-0.752 0.304-0.752-0.32l-5.184-5.376-5.376 5.184q-0.32 0.32-0.752 0.304t-0.736-0.336-0.304-0.752 0.32-0.752l5.376-5.184-5.184-5.376q-0.32-0.32-0.304-0.752t0.336-0.752 0.752-0.304 0.752 0.336l5.184 5.376 5.376-5.184q0.32-0.32 0.752-0.304t0.752 0.336 0.304 0.752-0.336 0.752l-5.376 5.184 5.184 5.376z";
const ICON_PATH_DOWNLOAD = "M15.808 1.696q-3.776 0-7.072 1.984-3.2 1.888-5.088 5.152-1.952 3.392-1.952 7.36 0 3.776 1.952 7.072 1.888 3.2 5.088 5.088 3.296 1.952 7.072 1.952 3.968 0 7.36-1.952 3.264-1.888 5.152-5.088 1.984-3.296 1.984-7.072 0-4-1.984-7.36-1.888-3.264-5.152-5.152-3.36-1.984-7.36-1.984zM20.864 18.592l-3.776 4.928q-0.448 0.576-1.088 0.576t-1.088-0.576l-3.776-4.928q-0.448-0.576-0.24-0.992t0.944-0.416h2.976v-8.928q0-0.256 0.176-0.432t0.4-0.176h1.216q0.224 0 0.4 0.176t0.176 0.432v8.928h2.976q0.736 0 0.944 0.416t-0.24 0.992z";
const ICON_PATH_INFO = "M15.808 0.128q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.176 3.776-2.176 8.16 0 4.224 2.176 7.872 2.080 3.552 5.632 5.632 3.648 2.176 7.872 2.176 4.384 0 8.16-2.176 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.416-2.176-8.16-2.112-3.616-5.728-5.728-3.744-2.176-8.16-2.176zM16.864 23.776q0 0.064-0.064 0.064h-1.568q-0.096 0-0.096-0.064l-0.256-11.328q0-0.064 0.064-0.064h2.112q0.096 0 0.064 0.064l-0.256 11.328zM16 10.88q-0.576 0-0.976-0.4t-0.4-0.96 0.4-0.96 0.976-0.4 0.976 0.4 0.4 0.96-0.4 0.96-0.976 0.4z";
const ICON_PATH_SEARCH = "M20.928 22.688q-1.696 1.376-3.744 2.112-2.112 0.768-4.384 0.768-3.488 0-6.464-1.728-2.88-1.696-4.576-4.608-1.76-2.976-1.76-6.464t1.76-6.464q1.696-2.88 4.576-4.576 2.976-1.76 6.464-1.76t6.464 1.76q2.912 1.696 4.608 4.576 1.728 2.976 1.728 6.464 0 2.272-0.768 4.384-0.736 2.048-2.112 3.744l9.312 9.28-1.824 1.824-9.28-9.312zM12.8 23.008q2.784 0 5.184-1.376 2.304-1.376 3.68-3.68 1.376-2.4 1.376-5.184t-1.376-5.152q-1.376-2.336-3.68-3.68-2.4-1.408-5.184-1.408t-5.152 1.408q-2.336 1.344-3.68 3.68-1.408 2.368-1.408 5.152t1.408 5.184q1.344 2.304 3.68 3.68 2.368 1.376 5.152 1.376zM12.8 23.008v0z";
const ICON_PATH_SUCCESS_NO_CIRCLE = "M1.952 18.080q-0.32-0.352-0.416-0.88t0.128-0.976l0.16-0.352q0.224-0.416 0.64-0.528t0.8 0.176l6.496 4.704q0.384 0.288 0.912 0.272t0.88-0.336l17.312-14.272q0.352-0.288 0.848-0.256t0.848 0.352l-0.416-0.416q0.32 0.352 0.32 0.816t-0.32 0.816l-18.656 18.912q-0.32 0.352-0.8 0.352t-0.8-0.32l-7.936-8.064z";
const ICON_PATH_SUCCESS = "M15.808 0.16q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM24.832 11.328l-11.264 11.104q-0.032 0.032-0.112 0.032t-0.112-0.032l-5.216-5.376q-0.096-0.128 0-0.288l0.704-0.96q0.032-0.064 0.112-0.064t0.112 0.032l4.256 3.264q0.064 0.032 0.144 0.032t0.112-0.032l10.336-8.608q0.064-0.064 0.144-0.064t0.112 0.064l0.672 0.672q0.128 0.128 0 0.224z";
const ICON_PATH_WAITING = "M15.84 0.096q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM23.008 21.92l-0.512 0.896q-0.096 0.128-0.224 0.064l-8-3.808q-0.096-0.064-0.16-0.128-0.128-0.096-0.128-0.288l0.512-12.096q0-0.064 0.048-0.112t0.112-0.048h1.376q0.064 0 0.112 0.048t0.048 0.112l0.448 10.848 6.304 4.256q0.064 0.064 0.080 0.128t-0.016 0.128z";
const ICON_PATH_WARN = "M15.808 0.16q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM15.136 8.672h1.728q0.128 0 0.224 0.096t0.096 0.256l-0.384 10.24q0 0.064-0.048 0.112t-0.112 0.048h-1.248q-0.096 0-0.144-0.048t-0.048-0.112l-0.384-10.24q0-0.16 0.096-0.256t0.224-0.096zM16 23.328q-0.48 0-0.832-0.352t-0.352-0.848 0.352-0.848 0.832-0.352 0.832 0.352 0.352 0.848-0.352 0.848-0.832 0.352z";
function createSvgIconVNode(path, color = "#000", size = 27) {
return createVNode("svg", {
width: size,
height: size,
viewBox: "0 0 32 32"
}, [
createVNode("path", {
d: path,
fill: color
}, null, 8, ["d", "fill"])
], 8, ["width", "height"]);
}
function disableScrollListener(evt) {
evt.preventDefault();
}
let testReachBottomTimer;
let lastScrollHeight = 0;
function createScrollListener({
onPageScroll,
onReachBottom,
onReachBottomDistance
}) {
let ticking = false;
let hasReachBottom = false;
let reachBottomLocking = true;
const isReachBottom = () => {
const {scrollHeight} = document.documentElement;
const windowHeight = window.innerHeight;
const scrollY = window.scrollY;
const isBottom = scrollY > 0 && scrollHeight > windowHeight && scrollY + windowHeight + onReachBottomDistance >= scrollHeight;
const heightChanged = Math.abs(scrollHeight - lastScrollHeight) > onReachBottomDistance;
if (isBottom && (!hasReachBottom || heightChanged)) {
lastScrollHeight = scrollHeight;
hasReachBottom = true;
return true;
}
if (!isBottom && hasReachBottom) {
hasReachBottom = false;
}
return false;
};
const trigger = () => {
onPageScroll && onPageScroll(window.pageYOffset);
function testReachBottom() {
if (isReachBottom()) {
onReachBottom && onReachBottom();
reachBottomLocking = false;
setTimeout(function() {
reachBottomLocking = true;
}, 350);
return true;
}
}
if (onReachBottom && reachBottomLocking) {
if (testReachBottom())
;
else {
testReachBottomTimer = setTimeout(testReachBottom, 300);
}
}
ticking = false;
};
return function onScroll() {
clearTimeout(testReachBottomTimer);
if (!ticking) {
requestAnimationFrame(trigger);
}
ticking = true;
};
}
function getRealRoute(fromRoute, toRoute) {
if (!toRoute) {
toRoute = fromRoute;
if (toRoute.indexOf("/") === 0) {
return toRoute;
}
const pages = getCurrentPages();
if (pages.length) {
fromRoute = pages[pages.length - 1].$page.route;
} else {
fromRoute = "";
}
} else {
if (toRoute.indexOf("/") === 0) {
return toRoute;
}
}
if (toRoute.indexOf("./") === 0) {
return getRealRoute(fromRoute, toRoute.substr(2));
}
const toRouteArray = toRoute.split("/");
const toRouteLength = toRouteArray.length;
let i2 = 0;
for (; i2 < toRouteLength && toRouteArray[i2] === ".."; i2++) {
}
toRouteArray.splice(0, i2);
toRoute = toRouteArray.join("/");
const fromRouteArray = fromRoute.length > 0 ? fromRoute.split("/") : [];
fromRouteArray.splice(fromRouteArray.length - i2 - 1, i2 + 1);
return "/" + fromRouteArray.concat(toRouteArray).join("/");
}
const isClickEvent = (val) => val.type === "click";
const isMouseEvent = (val) => val.type.indexOf("mouse") === 0;
function $normalizeNativeEvent(evt) {
function $nne(evt) {
const {currentTarget} = evt;
if (!(evt instanceof Event) || !(currentTarget instanceof HTMLElement)) {
return evt;
......@@ -723,7 +890,7 @@ function normalizeTouchEvent(touches, top) {
var instance = /* @__PURE__ */ Object.freeze({
__proto__: null,
[Symbol.toStringTag]: "Module",
$normalizeNativeEvent
$nne
});
const CLASS_RE = /^\s+|\s+$/g;
const WXS_CLASS_RE = /\s+/;
......@@ -1030,144 +1197,6 @@ function initService(app) {
initSubscribe();
initAppConfig(app._context.config);
}
function PolySymbol(name) {
return Symbol(process.env.NODE_ENV !== "production" ? "[uni-app]: " + name : name);
}
function rpx2px(str) {
if (typeof str === "string") {
const res = parseInt(str) || 0;
if (str.indexOf("rpx") !== -1 || str.indexOf("upx") !== -1) {
return uni.upx2px(res);
}
return res;
}
return str;
}
const ICON_PATH_CANCEL = "M20.928 10.176l-4.928 4.928-4.928-4.928-0.896 0.896 4.928 4.928-4.928 4.928 0.896 0.896 4.928-4.928 4.928 4.928 0.896-0.896-4.928-4.928 4.928-4.928-0.896-0.896zM16 2.080q-3.776 0-7.040 1.888-3.136 1.856-4.992 4.992-1.888 3.264-1.888 7.040t1.888 7.040q1.856 3.136 4.992 4.992 3.264 1.888 7.040 1.888t7.040-1.888q3.136-1.856 4.992-4.992 1.888-3.264 1.888-7.040t-1.888-7.040q-1.856-3.136-4.992-4.992-3.264-1.888-7.040-1.888zM16 28.64q-3.424 0-6.4-1.728-2.848-1.664-4.512-4.512-1.728-2.976-1.728-6.4t1.728-6.4q1.664-2.848 4.512-4.512 2.976-1.728 6.4-1.728t6.4 1.728q2.848 1.664 4.512 4.512 1.728 2.976 1.728 6.4t-1.728 6.4q-1.664 2.848-4.512 4.512-2.976 1.728-6.4 1.728z";
const ICON_PATH_CLEAR = "M16 0q-4.352 0-8.064 2.176-3.616 2.144-5.76 5.76-2.176 3.712-2.176 8.064t2.176 8.064q2.144 3.616 5.76 5.76 3.712 2.176 8.064 2.176t8.064-2.176q3.616-2.144 5.76-5.76 2.176-3.712 2.176-8.064t-2.176-8.064q-2.144-3.616-5.76-5.76-3.712-2.176-8.064-2.176zM22.688 21.408q0.32 0.32 0.304 0.752t-0.336 0.736-0.752 0.304-0.752-0.32l-5.184-5.376-5.376 5.184q-0.32 0.32-0.752 0.304t-0.736-0.336-0.304-0.752 0.32-0.752l5.376-5.184-5.184-5.376q-0.32-0.32-0.304-0.752t0.336-0.752 0.752-0.304 0.752 0.336l5.184 5.376 5.376-5.184q0.32-0.32 0.752-0.304t0.752 0.336 0.304 0.752-0.336 0.752l-5.376 5.184 5.184 5.376z";
const ICON_PATH_DOWNLOAD = "M15.808 1.696q-3.776 0-7.072 1.984-3.2 1.888-5.088 5.152-1.952 3.392-1.952 7.36 0 3.776 1.952 7.072 1.888 3.2 5.088 5.088 3.296 1.952 7.072 1.952 3.968 0 7.36-1.952 3.264-1.888 5.152-5.088 1.984-3.296 1.984-7.072 0-4-1.984-7.36-1.888-3.264-5.152-5.152-3.36-1.984-7.36-1.984zM20.864 18.592l-3.776 4.928q-0.448 0.576-1.088 0.576t-1.088-0.576l-3.776-4.928q-0.448-0.576-0.24-0.992t0.944-0.416h2.976v-8.928q0-0.256 0.176-0.432t0.4-0.176h1.216q0.224 0 0.4 0.176t0.176 0.432v8.928h2.976q0.736 0 0.944 0.416t-0.24 0.992z";
const ICON_PATH_INFO = "M15.808 0.128q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.176 3.776-2.176 8.16 0 4.224 2.176 7.872 2.080 3.552 5.632 5.632 3.648 2.176 7.872 2.176 4.384 0 8.16-2.176 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.416-2.176-8.16-2.112-3.616-5.728-5.728-3.744-2.176-8.16-2.176zM16.864 23.776q0 0.064-0.064 0.064h-1.568q-0.096 0-0.096-0.064l-0.256-11.328q0-0.064 0.064-0.064h2.112q0.096 0 0.064 0.064l-0.256 11.328zM16 10.88q-0.576 0-0.976-0.4t-0.4-0.96 0.4-0.96 0.976-0.4 0.976 0.4 0.4 0.96-0.4 0.96-0.976 0.4z";
const ICON_PATH_SEARCH = "M20.928 22.688q-1.696 1.376-3.744 2.112-2.112 0.768-4.384 0.768-3.488 0-6.464-1.728-2.88-1.696-4.576-4.608-1.76-2.976-1.76-6.464t1.76-6.464q1.696-2.88 4.576-4.576 2.976-1.76 6.464-1.76t6.464 1.76q2.912 1.696 4.608 4.576 1.728 2.976 1.728 6.464 0 2.272-0.768 4.384-0.736 2.048-2.112 3.744l9.312 9.28-1.824 1.824-9.28-9.312zM12.8 23.008q2.784 0 5.184-1.376 2.304-1.376 3.68-3.68 1.376-2.4 1.376-5.184t-1.376-5.152q-1.376-2.336-3.68-3.68-2.4-1.408-5.184-1.408t-5.152 1.408q-2.336 1.344-3.68 3.68-1.408 2.368-1.408 5.152t1.408 5.184q1.344 2.304 3.68 3.68 2.368 1.376 5.152 1.376zM12.8 23.008v0z";
const ICON_PATH_SUCCESS_NO_CIRCLE = "M1.952 18.080q-0.32-0.352-0.416-0.88t0.128-0.976l0.16-0.352q0.224-0.416 0.64-0.528t0.8 0.176l6.496 4.704q0.384 0.288 0.912 0.272t0.88-0.336l17.312-14.272q0.352-0.288 0.848-0.256t0.848 0.352l-0.416-0.416q0.32 0.352 0.32 0.816t-0.32 0.816l-18.656 18.912q-0.32 0.352-0.8 0.352t-0.8-0.32l-7.936-8.064z";
const ICON_PATH_SUCCESS = "M15.808 0.16q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM24.832 11.328l-11.264 11.104q-0.032 0.032-0.112 0.032t-0.112-0.032l-5.216-5.376q-0.096-0.128 0-0.288l0.704-0.96q0.032-0.064 0.112-0.064t0.112 0.032l4.256 3.264q0.064 0.032 0.144 0.032t0.112-0.032l10.336-8.608q0.064-0.064 0.144-0.064t0.112 0.064l0.672 0.672q0.128 0.128 0 0.224z";
const ICON_PATH_WAITING = "M15.84 0.096q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM23.008 21.92l-0.512 0.896q-0.096 0.128-0.224 0.064l-8-3.808q-0.096-0.064-0.16-0.128-0.128-0.096-0.128-0.288l0.512-12.096q0-0.064 0.048-0.112t0.112-0.048h1.376q0.064 0 0.112 0.048t0.048 0.112l0.448 10.848 6.304 4.256q0.064 0.064 0.080 0.128t-0.016 0.128z";
const ICON_PATH_WARN = "M15.808 0.16q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM15.136 8.672h1.728q0.128 0 0.224 0.096t0.096 0.256l-0.384 10.24q0 0.064-0.048 0.112t-0.112 0.048h-1.248q-0.096 0-0.144-0.048t-0.048-0.112l-0.384-10.24q0-0.16 0.096-0.256t0.224-0.096zM16 23.328q-0.48 0-0.832-0.352t-0.352-0.848 0.352-0.848 0.832-0.352 0.832 0.352 0.352 0.848-0.352 0.848-0.832 0.352z";
function createSvgIconVNode(path, color = "#000", size = 27) {
return createVNode("svg", {
width: size,
height: size,
viewBox: "0 0 32 32"
}, [
createVNode("path", {
d: path,
fill: color
}, null, 8, ["d", "fill"])
], 8, ["width", "height"]);
}
const onTouchmovePrevent = /* @__PURE__ */ withModifiers(() => {
}, [
"prevent"
]);
const onTouchmoveStop = /* @__PURE__ */ withModifiers(() => {
}, ["stop"]);
function disableScrollListener(evt) {
evt.preventDefault();
}
let testReachBottomTimer;
let lastScrollHeight = 0;
function createScrollListener({
onPageScroll,
onReachBottom,
onReachBottomDistance
}) {
let ticking = false;
let hasReachBottom = false;
let reachBottomLocking = true;
const isReachBottom = () => {
const {scrollHeight} = document.documentElement;
const windowHeight = window.innerHeight;
const scrollY = window.scrollY;
const isBottom = scrollY > 0 && scrollHeight > windowHeight && scrollY + windowHeight + onReachBottomDistance >= scrollHeight;
const heightChanged = Math.abs(scrollHeight - lastScrollHeight) > onReachBottomDistance;
if (isBottom && (!hasReachBottom || heightChanged)) {
lastScrollHeight = scrollHeight;
hasReachBottom = true;
return true;
}
if (!isBottom && hasReachBottom) {
hasReachBottom = false;
}
return false;
};
const trigger = () => {
onPageScroll && onPageScroll(window.pageYOffset);
function testReachBottom() {
if (isReachBottom()) {
onReachBottom && onReachBottom();
reachBottomLocking = false;
setTimeout(function() {
reachBottomLocking = true;
}, 350);
return true;
}
}
if (onReachBottom && reachBottomLocking) {
if (testReachBottom())
;
else {
testReachBottomTimer = setTimeout(testReachBottom, 300);
}
}
ticking = false;
};
return function onScroll() {
clearTimeout(testReachBottomTimer);
if (!ticking) {
requestAnimationFrame(trigger);
}
ticking = true;
};
}
function getRealRoute(fromRoute, toRoute) {
if (!toRoute) {
toRoute = fromRoute;
if (toRoute.indexOf("/") === 0) {
return toRoute;
}
const pages = getCurrentPages();
if (pages.length) {
fromRoute = pages[pages.length - 1].$page.route;
} else {
fromRoute = "";
}
} else {
if (toRoute.indexOf("/") === 0) {
return toRoute;
}
}
if (toRoute.indexOf("./") === 0) {
return getRealRoute(fromRoute, toRoute.substr(2));
}
const toRouteArray = toRoute.split("/");
const toRouteLength = toRouteArray.length;
let i2 = 0;
for (; i2 < toRouteLength && toRouteArray[i2] === ".."; i2++) {
}
toRouteArray.splice(0, i2);
toRoute = toRouteArray.join("/");
const fromRouteArray = fromRoute.length > 0 ? fromRoute.split("/") : [];
fromRouteArray.splice(fromRouteArray.length - i2 - 1, i2 + 1);
return "/" + fromRouteArray.concat(toRouteArray).join("/");
}
const style = document.documentElement.style;
function updateCssVar$1(cssVars) {
Object.keys(cssVars).forEach((name) => {
style.setProperty(name, cssVars[name]);
});
}
function updatePageCssVar(cssVars) {
return updateCssVar$1(cssVars);
}
function errorHandler(err, instance2, info) {
if (!instance2) {
throw err;
......@@ -1275,43 +1304,6 @@ function normalizePageMeta(pageMeta) {
}
return pageMeta;
}
const sheetsMap = new Map();
function updateStyle(id2, content) {
let style2 = sheetsMap.get(id2);
if (style2 && !(style2 instanceof HTMLStyleElement)) {
removeStyle(id2);
style2 = void 0;
}
if (!style2) {
style2 = document.createElement("style");
style2.setAttribute("type", "text/css");
style2.innerHTML = content;
document.head.appendChild(style2);
} else {
style2.innerHTML = content;
}
sheetsMap.set(id2, style2);
}
function removeStyle(id2) {
let style2 = sheetsMap.get(id2);
if (style2) {
if (style2 instanceof CSSStyleSheet) {
document.adoptedStyleSheets.indexOf(style2);
document.adoptedStyleSheets = document.adoptedStyleSheets.filter((s) => s !== style2);
} else {
document.head.removeChild(style2);
}
sheetsMap.delete(id2);
}
}
const documentElement = document.documentElement;
let styleObj;
function updateCssVar(name, value) {
if (!styleObj) {
styleObj = documentElement.style;
}
styleObj.setProperty(name, value);
}
PolySymbol(process.env.NODE_ENV !== "production" ? "layout" : "l");
let tabBar;
function useTabBar() {
......@@ -13396,13 +13388,20 @@ function createTabBarMidButtonTsx(color, iconPath, midButton, tabBar2, index2, o
src: getRealPath(iconPath)
}, null, 12, ["src"])], 4), createTabBarItemBdTsx(color, iconPath, midButton, tabBar2)], 12, ["onClick"]);
}
const CSS_VARS = ["--status-bar-height", "--top-window-height", "--window-left", "--window-right", "--window-margin", "--tab-bar-height"];
const DEFAULT_CSS_VAR_VALUE = "0px";
updateCssVar({
"--status-bar-height": DEFAULT_CSS_VAR_VALUE,
"--top-window-height": DEFAULT_CSS_VAR_VALUE,
"--window-left": DEFAULT_CSS_VAR_VALUE,
"--window-right": DEFAULT_CSS_VAR_VALUE,
"--window-margin": DEFAULT_CSS_VAR_VALUE,
"--tab-bar-height": DEFAULT_CSS_VAR_VALUE
});
var LayoutComponent = defineComponent({
name: "Layout",
setup(_props, {
emit
}) {
useCssVar();
const keepAliveRoute = __UNI_FEATURE_PAGES__ && useKeepAliveRoute();
__UNI_FEATURE_TOPWINDOW__ && useTopWindow();
__UNI_FEATURE_LEFTWINDOW__ && useLeftWindow();
......@@ -13418,9 +13417,6 @@ var LayoutComponent = defineComponent({
};
}
});
function useCssVar() {
CSS_VARS.forEach((name) => updateCssVar(name, "0px"));
}
function useAppClass(showTabBar2) {
const showMaxWidth = ref(false);
return computed(() => {
......
......@@ -2,7 +2,6 @@ import {
ref,
withCtx,
computed,
onMounted,
ComputedRef,
KeepAlive,
openBlock,
......@@ -17,6 +16,7 @@ import {
import { RouterView, useRoute } from 'vue-router'
import { updateCssVar } from '@dcloudio/uni-core'
import { useTabBar } from '../../setup/state'
import { useKeepAliveRoute } from '../../setup/page'
......@@ -24,19 +24,18 @@ import TabBar from './tabBar'
type KeepAliveRoute = ReturnType<typeof useKeepAliveRoute>
const CSS_VARS = [
'--status-bar-height',
'--top-window-height',
'--window-left',
'--window-right',
'--window-margin',
'--tab-bar-height',
]
const DEFAULT_CSS_VAR_VALUE = '0px'
updateCssVar({
'--status-bar-height': DEFAULT_CSS_VAR_VALUE,
'--top-window-height': DEFAULT_CSS_VAR_VALUE,
'--window-left': DEFAULT_CSS_VAR_VALUE,
'--window-right': DEFAULT_CSS_VAR_VALUE,
'--window-margin': DEFAULT_CSS_VAR_VALUE,
'--tab-bar-height': DEFAULT_CSS_VAR_VALUE,
})
export default defineComponent({
name: 'Layout',
setup(_props, { emit }) {
useCssVar()
const keepAliveRoute = (__UNI_FEATURE_PAGES__ &&
useKeepAliveRoute()) as KeepAliveRoute
const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow()
......@@ -57,11 +56,6 @@ export default defineComponent({
}
},
})
import { updateCssVar } from '../../../helpers/dom'
function useCssVar() {
CSS_VARS.forEach((name) => updateCssVar(name, '0px'))
}
function useAppClass(showTabBar?: ComputedRef<boolean>) {
const showMaxWidth = ref(false)
......
......@@ -3,9 +3,10 @@ import { extend, isArray } from '@vue/shared'
import { Input } from '@dcloudio/uni-components'
import { getRealPath } from '@dcloudio/uni-platform'
import {
ICON_PATH_SEARCH,
createSvgIconVNode,
invokeHook,
updateStyle,
createSvgIconVNode,
ICON_PATH_SEARCH,
} from '@dcloudio/uni-core'
import { usePageMeta } from '../../setup/provide'
import {
......@@ -13,8 +14,6 @@ import {
usePageHeadTransparentBackgroundColor,
} from './transparent'
import { updateStyle } from '../../../helpers/dom'
const ICON_PATH_BACK =
'M21.781 7.844l-9.063 8.594 9.063 8.594q0.25 0.25 0.25 0.609t-0.25 0.578q-0.25 0.25-0.578 0.25t-0.578-0.25l-9.625-9.125q-0.156-0.125-0.203-0.297t-0.047-0.359q0-0.156 0.047-0.328t0.203-0.297l9.625-9.125q0.25-0.25 0.578-0.25t0.578 0.25q0.25 0.219 0.25 0.578t-0.25 0.578z'
......
const sheetsMap = new Map()
export function updateStyle(id: string, content: string) {
let style = sheetsMap.get(id)
if (style && !(style instanceof HTMLStyleElement)) {
removeStyle(id)
style = undefined
}
if (!style) {
style = document.createElement('style')
style.setAttribute('type', 'text/css')
style.innerHTML = content
document.head.appendChild(style)
} else {
style.innerHTML = content
}
sheetsMap.set(id, style)
}
export function removeStyle(id: string) {
let style = sheetsMap.get(id)
if (style) {
if (style instanceof CSSStyleSheet) {
// @ts-ignore
const index = document.adoptedStyleSheets.indexOf(style)
// @ts-ignore
document.adoptedStyleSheets = document.adoptedStyleSheets.filter(
(s: CSSStyleSheet) => s !== style
)
} else {
document.head.removeChild(style)
}
sheetsMap.delete(id)
}
}
const screen = window.screen
const documentElement = document.documentElement
let styleObj: CSSStyleDeclaration
export function updateCssVar(name: string, value: string) {
if (!styleObj) {
styleObj = documentElement.style
}
styleObj.setProperty(name, value)
}
export function checkMinWidth(minWidth: number) {
const sizes = [
window.outerWidth,
......
......@@ -33,7 +33,7 @@ export function uniPagesJsonPlugin(
if (id.endsWith(PAGES_JSON_JS)) {
return {
code:
registerGlobalCode +
(config.define!.__UNI_FEATURE_RPX__ ? registerGlobalCode : '') +
(options.command === 'serve' ? registerDevServerGlobalCode : '') +
parsePagesJson(code, config, options),
map: { mappings: '' },
......
......@@ -24,6 +24,7 @@ interface PagesFeatures {
interface ManifestFeatures {
wx: boolean
wxs: boolean
rpx: boolean
promise: boolean
longpress: boolean
routerMode: '"hash"' | '"history"'
......@@ -158,6 +159,7 @@ function resolveManifestFeature(
const features: ManifestFeatures = {
wx: false,
wxs: true,
rpx: true,
promise: false,
longpress: true,
routerMode: '"hash"',
......@@ -217,6 +219,7 @@ export function getFeatures(
const {
wx,
wxs,
rpx,
nvue,
i18nEn,
i18nEs,
......@@ -245,6 +248,7 @@ export function getFeatures(
return {
__UNI_FEATURE_WX__: wx, // 是否启用小程序的组件实例 API,如:selectComponent 等(uni-core/src/service/plugin/appConfig)
__UNI_FEATURE_WXS__: wxs, // 是否启用 wxs 支持,如:getComponentDescriptor 等(uni-core/src/view/plugin/appConfig)
__UNI_FEATURE_RPX__: rpx, // 是否启用运行时 rpx 支持
__UNI_FEATURE_PROMISE__: promise, // 是否启用旧版本的 promise 支持(即返回[err,res]的格式),默认返回标准
__UNI_FEATURE_LONGPRESS__: longpress, // 是否启用longpress
__UNI_FEATURE_I18N_EN__: i18nEn, // 是否启用en
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册