提交 0838634f 编写于 作者: Q qiang

feat(h5): topWindow, leftWindow, rightWindow

上级 da1d0bd7
......@@ -38,7 +38,7 @@
"node": ">=10.0.0"
},
"devDependencies": {
"@dcloudio/types": "^2.2.5",
"@dcloudio/types": "^2.2.6",
"@microsoft/api-extractor": "^7.13.2",
"@rollup/plugin-alias": "^3.1.1",
"@rollup/plugin-commonjs": "^17.0.0",
......
......@@ -19,6 +19,7 @@ declare namespace UniApp {
minWidth?: number
}
style?: Record<string, any>
component: any
}
interface UniConfig {
......
......@@ -451,6 +451,19 @@ function normalizePageMeta(pageMeta) {
}
return pageMeta;
}
const screen = window.screen;
const documentElement = document.documentElement;
function checkMinWidth(minWidth) {
const sizes = [
window.outerWidth,
window.outerHeight,
screen.width,
screen.height,
documentElement.clientWidth,
documentElement.clientHeight
];
return Math.max.apply(null, sizes) > minWidth;
}
function getStateId() {
{
return 1;
......@@ -4324,7 +4337,7 @@ const props$i = {
default: ""
}
};
function useState$1(props2) {
function useState$2(props2) {
const value = vue.reactive([...props2.value]);
const state = vue.reactive({
value,
......@@ -4352,7 +4365,7 @@ var PickerView = /* @__PURE__ */ defineBuiltInComponent({
}) {
const rootRef = vue.ref(null);
const trigger = useCustomEvent(rootRef, emit2);
const state = useState$1(props2);
const state = useState$2(props2);
const resizeSensorRef = vue.ref(null);
let columnVNodes = [];
function getItemIndex(vnode) {
......@@ -6337,7 +6350,7 @@ function upx2pxStr(val) {
}
return val || "";
}
function useState(props2) {
function useState$1(props2) {
const interval = vue.computed(() => {
const interval2 = Number(props2.interval);
return isNaN(interval2) ? 5e3 : interval2;
......@@ -6660,7 +6673,7 @@ var index$f = /* @__PURE__ */ defineBuiltInComponent({
const trigger = useCustomEvent(rootRef, emit2);
const slidesWrapperRef = vue.ref(null);
const slideFrameRef = vue.ref(null);
const state = useState(props2);
const state = useState$1(props2);
const slidesStyle = vue.computed(() => {
let style = {};
if (props2.nextMargin || props2.previousMargin) {
......@@ -10563,16 +10576,23 @@ var LayoutComponent = /* @__PURE__ */ defineSystemComponent({
setup(_props, {
emit: emit2
}) {
const rootRef = vue.ref(null);
const keepAliveRoute = __UNI_FEATURE_PAGES__ && useKeepAliveRoute();
__UNI_FEATURE_TOPWINDOW__ && useTopWindow();
__UNI_FEATURE_LEFTWINDOW__ && useLeftWindow();
__UNI_FEATURE_RIGHTWINDOW__ && useRightWindow();
const {
layoutState,
windowState
} = useState();
useMaxWidth(layoutState, rootRef);
const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState);
const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState);
const rightWindow = __UNI_FEATURE_RIGHTWINDOW__ && useRightWindow(layoutState);
const showTabBar = __UNI_FEATURE_TABBAR__ && useShowTabBar();
const clazz2 = useAppClass(showTabBar);
return () => {
const layoutTsx = createLayoutTsx(keepAliveRoute);
const layoutTsx = createLayoutTsx(keepAliveRoute, layoutState, windowState, topWindow, leftWindow, rightWindow);
const tabBarTsx = __UNI_FEATURE_TABBAR__ && createTabBarTsx(showTabBar);
return vue.createVNode("uni-app", {
"ref": rootRef,
"class": clazz2.value
}, [layoutTsx, tabBarTsx], 2);
};
......@@ -10587,14 +10607,119 @@ function useAppClass(showTabBar) {
};
});
}
function createLayoutTsx(keepAliveRoute, topWindow, leftWindow, rightWindow) {
function initMediaQuery(minWidth, callback) {
const mediaQueryList = window.matchMedia("(min-width: " + minWidth + "px)");
if (mediaQueryList.addEventListener) {
mediaQueryList.addEventListener("change", callback);
} else {
mediaQueryList.addListener(callback);
}
return mediaQueryList.matches;
}
function useMaxWidth(layoutState, rootRef) {
const route = vueRouter.useRoute();
function checkMaxWidth() {
const windowWidth = document.body.clientWidth;
const maxWidth = parseInt(String(route.meta.maxWidth || 1190));
let showMaxWidth = false;
if (windowWidth > maxWidth) {
showMaxWidth = true;
} else {
showMaxWidth = false;
}
if (showMaxWidth && maxWidth) {
layoutState.marginWidth = (windowWidth - maxWidth) / 2;
vue.nextTick(() => {
const rootEl = rootRef.value;
if (rootEl) {
rootEl.setAttribute("style", "max-width:" + maxWidth + "px;margin:0 auto;");
}
});
} else {
layoutState.marginWidth = 0;
vue.nextTick(() => {
const rootEl = rootRef.value;
if (rootEl) {
rootEl.removeAttribute("style");
}
});
}
}
vue.watch([() => route.path], checkMaxWidth);
window.addEventListener("resize", checkMaxWidth);
}
function useState() {
const topWindowMediaQuery = vue.ref(false);
const leftWindowMediaQuery = vue.ref(false);
const rightWindowMediaQuery = vue.ref(false);
const showTopWindow = vue.computed(() => __UNI_FEATURE_TOPWINDOW__ && topWindowMediaQuery.value);
const showLeftWindow = vue.computed(() => __UNI_FEATURE_LEFTWINDOW__ && leftWindowMediaQuery.value);
const showRightWindow = vue.computed(() => __UNI_FEATURE_RIGHTWINDOW__ && rightWindowMediaQuery.value);
const layoutState = vue.reactive({
topWindowMediaQuery,
showTopWindow,
apiShowTopWindow: false,
leftWindowMediaQuery,
showLeftWindow,
apiShowLeftWindow: false,
rightWindowMediaQuery,
showRightWindow,
apiShowRightWindow: false,
topWindowHeight: 0,
marginWidth: 0,
leftWindowWidth: 0,
rightWindowWidth: 0,
topWindowStyle: {},
leftWindowStyle: {},
rightWindowStyle: {}
});
const props2 = ["topWindow", "leftWindow", "rightWindow"];
props2.forEach((prop) => {
var _a;
const matchMedia = (_a = __uniConfig[prop]) == null ? void 0 : _a.matchMedia;
let topWindowMinWidth = uniShared.RESPONSIVE_MIN_WIDTH;
if (matchMedia && shared.hasOwn(matchMedia, "minWidth")) {
const minWidth = matchMedia.minWidth;
topWindowMinWidth = checkMinWidth(minWidth) ? minWidth : topWindowMinWidth;
}
const matches = initMediaQuery(topWindowMinWidth, (ev) => {
layoutState[`${prop}MediaQuery`] = ev.matches;
});
layoutState[`${prop}MediaQuery`] = matches;
});
vue.watch(() => layoutState.topWindowHeight, (value) => updateCssVar({
"--top-window-height": value + "px"
}));
vue.watch(() => layoutState.marginWidth, (value) => updateCssVar({
"--window-margin": value + "px"
}));
vue.watch(() => layoutState.leftWindowWidth + layoutState.marginWidth, (value) => updateCssVar({
"--window-left": value + "px"
}));
vue.watch(() => layoutState.rightWindowWidth + layoutState.marginWidth, (value) => updateCssVar({
"--window-right": value + "px"
}));
const windowState = vue.reactive({
matchTopWindow: layoutState.topWindowMediaQuery,
showTopWindow: layoutState.showTopWindow || layoutState.apiShowTopWindow,
matchLeftWindow: layoutState.leftWindowMediaQuery,
showLeftWindow: layoutState.showLeftWindow || layoutState.apiShowLeftWindow,
matchRightWindow: layoutState.rightWindowMediaQuery,
showRightWindow: layoutState.showRightWindow || layoutState.apiShowRightWindow
});
return {
layoutState,
windowState
};
}
function createLayoutTsx(keepAliveRoute, layoutState, windowState, topWindow, leftWindow, rightWindow) {
const routerVNode = __UNI_FEATURE_PAGES__ ? createRouterViewVNode(keepAliveRoute) : createPageVNode();
if (!__UNI_FEATURE_RESPONSIVE__) {
return routerVNode;
}
const topWindowTsx = __UNI_FEATURE_TOPWINDOW__ ? createTopWindowTsx() : null;
const leftWindowTsx = __UNI_FEATURE_LEFTWINDOW__ ? createLeftWindowTsx() : null;
const rightWindowTsx = __UNI_FEATURE_RIGHTWINDOW__ ? createRightWindowTsx() : null;
const topWindowTsx = __UNI_FEATURE_TOPWINDOW__ ? createTopWindowTsx(topWindow, layoutState, windowState) : null;
const leftWindowTsx = __UNI_FEATURE_LEFTWINDOW__ ? createLeftWindowTsx(leftWindow, layoutState, windowState) : null;
const rightWindowTsx = __UNI_FEATURE_RIGHTWINDOW__ ? createRightWindowTsx(rightWindow, layoutState, windowState) : null;
return vue.createVNode("uni-layout", null, [topWindowTsx, vue.createVNode("uni-content", null, [vue.createVNode("uni-main", null, [routerVNode]), leftWindowTsx, rightWindowTsx])]);
}
function useShowTabBar(emit2) {
......@@ -10627,36 +10752,119 @@ function createRouterViewVNode({
_: 1
});
}
function useTopWindow() {
const component = vue.resolveComponent("VUniTopWindow");
function useTopWindow(layoutState) {
const {
component,
style
} = __uniConfig.topWindow;
const windowRef = vue.ref(null);
function updateWindow() {
const instalce = windowRef.value;
const el = instalce.$el;
const height = el.getBoundingClientRect().height;
layoutState.topWindowHeight = height;
}
vue.watch(() => layoutState.showTopWindow || layoutState.apiShowTopWindow, () => vue.nextTick(updateWindow));
layoutState.topWindowStyle = style;
return {
component,
style: component.style,
height: 0,
show: false
windowRef
};
}
function useLeftWindow() {
const component = vue.resolveComponent("VUniLeftWindow");
function useLeftWindow(layoutState) {
const {
component,
style
} = __uniConfig.leftWindow;
const windowRef = vue.ref(null);
function updateWindow() {
const instalce = windowRef.value;
const el = instalce.$el;
const width = el.getBoundingClientRect().width;
layoutState.leftWindowWidth = width;
}
vue.watch(() => layoutState.showLeftWindow || layoutState.apiShowLeftWindow, () => vue.nextTick(updateWindow));
layoutState.leftWindowStyle = style;
return {
component,
style: component.style,
height: 0
windowRef
};
}
function useRightWindow() {
const component = vue.resolveComponent("VUniRightWindow");
function useRightWindow(layoutState) {
const {
component,
style
} = __uniConfig.rightWindow;
const windowRef = vue.ref(null);
function updateWindow() {
const instalce = windowRef.value;
const el = instalce.$el;
const width = el.getBoundingClientRect().width;
layoutState.rightWindowWidth = width;
}
vue.watch(() => layoutState.showRightWindow || layoutState.apiShowRightWindow, () => vue.nextTick(updateWindow));
layoutState.rightWindowStyle = style;
return {
component,
style: component.style,
height: 0
windowRef
};
}
function createTopWindowTsx(topWindow) {
}
function createLeftWindowTsx(leftWindow) {
}
function createRightWindowTsx(leftWindow) {
function createTopWindowTsx(topWindow, layoutState, windowState) {
if (topWindow) {
const {
component: TopWindow,
windowRef
} = topWindow;
return vue.withDirectives(vue.createVNode("uni-top-window", null, [vue.createVNode("div", {
"class": "uni-top-window",
"style": layoutState.topWindowStyle
}, [vue.createVNode(TopWindow, vue.mergeProps({
"ref": windowRef
}, windowState), null, 16)], 4), vue.createVNode("div", {
"class": "uni-top-window--placeholder",
"style": {
height: layoutState.topWindowHeight + "px"
}
}, null, 4)], 512), [[vue.vShow, layoutState.showTopWindow || layoutState.apiShowTopWindow]]);
}
}
function createLeftWindowTsx(leftWindow, layoutState, windowState) {
if (leftWindow) {
const {
component: LeftWindow,
windowRef
} = leftWindow;
return vue.withDirectives(vue.createVNode("uni-left-window", {
"data-show": layoutState.apiShowLeftWindow || void 0,
"style": layoutState.leftWindowStyle
}, [vue.withDirectives(vue.createVNode("div", {
"class": "uni-mask",
"onClick": () => layoutState.apiShowLeftWindow = false
}, null, 8, ["onClick"]), [[vue.vShow, layoutState.apiShowLeftWindow]]), vue.createVNode("div", {
"class": "uni-left-window"
}, [vue.createVNode(LeftWindow, vue.mergeProps({
"ref": windowRef
}, windowState), null, 16)])], 12, ["data-show"]), [[vue.vShow, layoutState.showLeftWindow || layoutState.apiShowLeftWindow]]);
}
}
function createRightWindowTsx(rightWindow, layoutState, windowState) {
if (rightWindow) {
const {
component: RightWindow,
windowRef
} = rightWindow;
return vue.withDirectives(vue.createVNode("uni-right-window", {
"data-show": layoutState.apiShowRightWindow || void 0,
"style": layoutState.rightWindowStyle
}, [vue.withDirectives(vue.createVNode("div", {
"class": "uni-mask",
"onClick": () => layoutState.apiShowRightWindow = false
}, null, 8, ["onClick"]), [[vue.vShow, layoutState.apiShowRightWindow]]), vue.createVNode("div", {
"class": "uni-right-window"
}, [vue.createVNode(RightWindow, vue.mergeProps({
"ref": windowRef
}, windowState), null, 16)])], 12, ["data-show"]), [[vue.vShow, layoutState.showRightWindow || layoutState.apiShowRightWindow]]);
}
}
function hexToRgba(hex) {
let r;
......
import {isFunction, extend, hyphenate, isPlainObject, isString, isArray, hasOwn, isObject, capitalize, toRawType, makeMap as makeMap$1, isPromise, invokeArrayFns as invokeArrayFns$1} from "@vue/shared";
import {injectHook, withModifiers, createVNode, getCurrentInstance, inject, provide, reactive, openBlock, createBlock, mergeProps, toDisplayString, defineComponent, ref, computed, watch, onUnmounted, onBeforeUnmount, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, createTextVNode, onBeforeActivate, onBeforeDeactivate, renderList, onDeactivated, Teleport, createApp, Transition, resolveComponent, withCtx, createCommentVNode, renderSlot, KeepAlive, resolveDynamicComponent} from "vue";
import {once, passive, normalizeTarget, isBuiltInComponent, initCostomDataset, invokeArrayFns, NAVBAR_HEIGHT, parseQuery, PRIMARY_COLOR, debounce, getCostomDataset, callOptions, removeLeadingSlash, getLen, ON_REACH_BOTTOM_DISTANCE, decodedQuery, updateElementStyle, addFont, scrollTo, formatDateTime} from "@dcloudio/uni-shared";
import {injectHook, withModifiers, createVNode, getCurrentInstance, inject, provide, reactive, openBlock, createBlock, mergeProps, toDisplayString, defineComponent, ref, computed, watch, onUnmounted, onBeforeUnmount, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, createTextVNode, onBeforeActivate, onBeforeDeactivate, renderList, onDeactivated, Teleport, createApp, Transition, withCtx, KeepAlive, resolveDynamicComponent, resolveComponent, createCommentVNode, renderSlot} from "vue";
import {once, passive, normalizeTarget, isBuiltInComponent, initCostomDataset, invokeArrayFns, NAVBAR_HEIGHT, parseQuery, PRIMARY_COLOR, debounce, getCostomDataset, callOptions, removeLeadingSlash, getLen, ON_REACH_BOTTOM_DISTANCE, decodedQuery, updateElementStyle, addFont, scrollTo, RESPONSIVE_MIN_WIDTH, formatDateTime} from "@dcloudio/uni-shared";
import {initVueI18n, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT} from "@dcloudio/uni-i18n";
import {useRoute, createRouter, createWebHistory, createWebHashHistory, useRouter, isNavigationFailure, RouterView} from "vue-router";
function applyOptions(options, instance2, publicThis) {
......@@ -1220,6 +1220,19 @@ function normalizePageMeta(pageMeta) {
}
return pageMeta;
}
const screen$1 = window.screen;
const documentElement = document.documentElement;
function checkMinWidth(minWidth) {
const sizes = [
window.outerWidth,
window.outerHeight,
screen$1.width,
screen$1.height,
documentElement.clientWidth,
documentElement.clientHeight
];
return Math.max.apply(null, sizes) > minWidth;
}
function getStateId() {
return history.state && history.state.__id__ || 1;
}
......@@ -6346,7 +6359,7 @@ const props$p = {
default: ""
}
};
function useState$2(props2) {
function useState$3(props2) {
const value = reactive([...props2.value]);
const state2 = reactive({
value,
......@@ -6374,7 +6387,7 @@ var PickerView = /* @__PURE__ */ defineBuiltInComponent({
}) {
const rootRef = ref(null);
const trigger = useCustomEvent(rootRef, emit2);
const state2 = useState$2(props2);
const state2 = useState$3(props2);
const resizeSensorRef = ref(null);
onMounted(() => {
const resizeSensor = resizeSensorRef.value;
......@@ -8610,7 +8623,7 @@ function upx2pxStr(val) {
}
return val || "";
}
function useState$1(props2) {
function useState$2(props2) {
const interval = computed(() => {
const interval2 = Number(props2.interval);
return isNaN(interval2) ? 5e3 : interval2;
......@@ -9039,7 +9052,7 @@ var Swiper = /* @__PURE__ */ defineBuiltInComponent({
const trigger = useCustomEvent(rootRef, emit2);
const slidesWrapperRef = ref(null);
const slideFrameRef = ref(null);
const state2 = useState$1(props2);
const state2 = useState$2(props2);
const slidesStyle = computed(() => {
let style = {};
if (props2.nextMargin || props2.previousMargin) {
......@@ -9597,12 +9610,12 @@ function getRootInfo(fields2) {
info.height = document.documentElement.clientHeight;
}
if (fields2.scrollOffset) {
const documentElement = document.documentElement;
const documentElement2 = document.documentElement;
const body = document.body;
info.scrollLeft = documentElement.scrollLeft || body.scrollLeft || 0;
info.scrollTop = documentElement.scrollTop || body.scrollTop || 0;
info.scrollHeight = documentElement.scrollHeight || body.scrollHeight || 0;
info.scrollWidth = documentElement.scrollWidth || body.scrollWidth || 0;
info.scrollLeft = documentElement2.scrollLeft || body.scrollLeft || 0;
info.scrollTop = documentElement2.scrollTop || body.scrollTop || 0;
info.scrollHeight = documentElement2.scrollHeight || body.scrollHeight || 0;
info.scrollWidth = documentElement2.scrollWidth || body.scrollWidth || 0;
}
return info;
}
......@@ -16716,7 +16729,7 @@ function distance(distance2) {
return "";
}
}
function useState(props2) {
function useState$1(props2) {
const state2 = reactive({
latitude: 0,
longitude: 0,
......@@ -16805,7 +16818,7 @@ var LoctaionPicker = /* @__PURE__ */ defineSystemComponent({
emit: emit2
}) {
usePreventScroll();
const state2 = useState(props2);
const state2 = useState$1(props2);
const {
list: list2,
listState,
......@@ -17786,1734 +17799,2027 @@ const removeTabBarBadge = /* @__PURE__ */ defineAsyncApi(API_REMOVE_TAB_BAR_BADG
const setTabBarBadge = /* @__PURE__ */ defineAsyncApi(API_SET_TAB_BAR_BADGE, (args, {resolve}) => {
setTabBar(API_SET_TAB_BAR_BADGE, args, resolve);
}, SetTabBarBadgeProtocol, SetTabBarBadgeOptions);
var tasks = [];
function onResize() {
tasks.push(setTimeout(() => {
tasks.forEach((task) => clearTimeout(task));
tasks.length = 0;
const {windowWidth, windowHeight, screenWidth, screenHeight} = uni.getSystemInfoSync();
var landscape = Math.abs(Number(window.orientation)) === 90;
var deviceOrientation = landscape ? "landscape" : "portrait";
UniServiceJSBridge.invokeOnCallback(API_ON_WINDOW_RESIZE, {
deviceOrientation,
size: {
windowWidth,
windowHeight,
screenWidth,
screenHeight
}
});
}, 20));
}
const onWindowResize = /* @__PURE__ */ defineOnApi(API_ON_WINDOW_RESIZE, () => {
window.addEventListener("resize", onResize);
});
const offWindowResize = /* @__PURE__ */ defineOffApi(API_OFF_WINDOW_RESIZE, () => {
window.removeEventListener("resize", onResize);
});
var api = /* @__PURE__ */ Object.freeze({
__proto__: null,
[Symbol.toStringTag]: "Module",
upx2px,
addInterceptor,
removeInterceptor,
promiseInterceptor,
arrayBufferToBase64,
base64ToArrayBuffer,
createIntersectionObserver,
createMediaQueryObserver,
createSelectorQuery,
createVideoContext,
createMapContext,
createAnimation,
onTabBarMidButtonTap,
createCanvasContext,
canvasGetImageData,
canvasPutImageData,
canvasToTempFilePath,
getSelectedTextRange,
$on,
$off,
$once,
$emit,
cssVar,
cssEnv,
cssConstant,
cssBackdropFilter,
canIUse,
createInnerAudioContext,
makePhoneCall,
getSystemInfo,
getSystemInfoSync,
onNetworkStatusChange,
offNetworkStatusChange,
getNetworkType,
onAccelerometerChange,
offAccelerometerChange,
startAccelerometer,
stopAccelerometer,
onCompassChange,
offCompassChange,
startCompass,
stopCompass,
vibrateShort,
vibrateLong,
setStorageSync,
setStorage,
getStorageSync,
getStorage,
removeStorageSync,
removeStorage,
clearStorageSync,
clearStorage,
getStorageInfoSync,
getStorageInfo,
getFileInfo,
openDocument,
hideKeyboard,
getImageInfo,
getVideoInfo,
chooseFile,
chooseImage,
previewImage,
chooseVideo,
request,
downloadFile,
uploadFile,
connectSocket,
sendSocketMessage,
closeSocket,
onSocketOpen,
onSocketError,
onSocketMessage,
onSocketClose,
getLocation,
openLocation,
chooseLocation,
navigateBack,
navigateTo,
redirectTo,
reLaunch,
switchTab,
preloadPage,
showModal,
showToast,
showLoading,
hideToast,
hideLoading,
showActionSheet,
loadFontFace,
setNavigationBarColor,
showNavigationBarLoading,
hideNavigationBarLoading,
setNavigationBarTitle,
pageScrollTo,
startPullDownRefresh,
stopPullDownRefresh,
setTabBarItem,
setTabBarStyle,
hideTabBar,
showTabBar,
hideTabBarRedDot,
showTabBarRedDot,
removeTabBarBadge,
setTabBarBadge,
onWindowResize,
offWindowResize
});
const CONTEXT_ID = "MAP_LOCATION";
const ICON_PATH = "data:image/png;base64,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";
var MapLocation = /* @__PURE__ */ defineSystemComponent({
name: "MapLocation",
var TabBar = /* @__PURE__ */ defineSystemComponent({
name: "TabBar",
setup() {
const state2 = reactive({
latitude: 0,
longitude: 0,
rotate: 0
});
{
let compassChangeHandler = function(res) {
state2.rotate = res.direction;
}, updateLocation = function() {
getLocation({
type: "gcj02",
success: (res) => {
state2.latitude = res.latitude;
state2.longitude = res.longitude;
},
complete: () => {
timer = setTimeout(updateLocation, 3e4);
}
});
}, removeLocation = function() {
if (timer) {
clearTimeout(timer);
}
offCompassChange(compassChangeHandler);
};
const onMapReady = inject("onMapReady");
let timer;
onCompassChange(compassChangeHandler);
onMapReady(updateLocation);
onUnmounted(removeLocation);
const addMapChidlContext = inject("addMapChidlContext");
const removeMapChidlContext = inject("removeMapChidlContext");
const context = {
id: CONTEXT_ID,
state: state2
};
addMapChidlContext(context);
onUnmounted(() => removeMapChidlContext(context));
}
const tabBar2 = useTabBar();
useTabBarCssVar(tabBar2);
const onSwitchTab = useSwitchTab(useRoute(), tabBar2);
const {
style,
borderStyle,
placeholderStyle
} = useTabBarStyle(tabBar2);
return () => {
return state2.latitude ? createVNode(MapMarker, mergeProps({
"anchor": {
x: 0.5,
y: 0.5
},
"width": "44",
"height": "44",
"iconPath": ICON_PATH
}, state2), null, 16, ["iconPath"]) : null;
const tabBarItemsTsx = createTabBarItemsTsx(tabBar2, onSwitchTab);
return createVNode("uni-tabbar", {
"class": "uni-tabbar-" + tabBar2.position
}, [createVNode("div", {
"class": "uni-tabbar",
"style": style.value
}, [createVNode("div", {
"class": "uni-tabbar-border",
"style": borderStyle.value
}, null, 4), tabBarItemsTsx], 4), createVNode("div", {
"class": "uni-placeholder",
"style": placeholderStyle.value
}, null, 4)], 2);
};
}
});
const props$1 = {
id: {
type: String,
default: ""
},
latitude: {
type: [String, Number],
default: 39.90374
},
longitude: {
type: [String, Number],
default: 116.397827
},
scale: {
type: [String, Number],
default: 16
},
markers: {
type: Array,
default() {
return [];
}
},
includePoints: {
type: Array,
default() {
return [];
}
},
polyline: {
type: Array,
default() {
return [];
}
},
circles: {
type: Array,
default() {
return [];
}
},
controls: {
type: Array,
default() {
return [];
function useTabBarCssVar(tabBar2) {
watch(() => tabBar2.shown, (value) => {
updatePageCssVar({
"--window-bottom": normalizeWindowBottom(value ? parseInt(tabBar2.height) : 0)
});
});
}
function useSwitchTab(route, tabBar2) {
watchEffect(() => {
const meta = route.meta;
if (meta.isTabBar) {
const pagePath = meta.route;
const index2 = tabBar2.list.findIndex((item) => item.pagePath === pagePath);
if (index2 === -1) {
return;
}
tabBar2.selectedIndex = index2;
}
},
showLocation: {
type: [Boolean, String],
default: false
}
};
function getPoints(points) {
const newPoints = [];
if (Array.isArray(points)) {
points.forEach((point) => {
if (point && point.latitude && point.longitude) {
newPoints.push({
latitude: point.latitude,
longitude: point.longitude
});
return (tabBarItem, index2) => {
const {
type
} = tabBarItem;
return () => {
if (__UNI_FEATURE_TABBAR_MIDBUTTON__ && type === "midButton") {
return UniServiceJSBridge.invokeOnCallback(API_ON_TAB_BAR_MID_BUTTON_TAP);
}
const {
pagePath,
text: text2
} = tabBarItem;
let url = "/" + pagePath;
if (url === __uniRoutes[0].alias) {
url = "/";
}
if (route.path !== url) {
uni.switchTab({
from: "tabBar",
url
});
} else {
invokeHook("onTabItemTap", {
index: index2,
text: text2,
pagePath
});
}
});
}
return newPoints;
};
};
}
function useMap(props2, rootRef, emit2) {
const trigger = useCustomEvent(rootRef, emit2);
const mapRef = ref(null);
let maps2;
let map;
const state2 = reactive({
latitude: Number(props2.latitude),
longitude: Number(props2.longitude),
includePoints: getPoints(props2.includePoints)
});
const onMapReadyCallbacks = [];
let isMapReady;
function onMapReady(callback) {
if (isMapReady) {
callback(map, maps2, trigger);
} else {
onMapReadyCallbacks.push(callback);
}
}
function emitMapReady() {
isMapReady = true;
onMapReadyCallbacks.forEach((callback) => callback(map, maps2, trigger));
onMapReadyCallbacks.length = 0;
}
let isBoundsReady;
const onBoundsReadyCallbacks = [];
function onBoundsReady(callback) {
if (isBoundsReady) {
callback();
} else {
onMapReadyCallbacks.push(callback);
}
}
const contexts = {};
function addMapChidlContext(context) {
contexts[context.id] = context;
}
function removeMapChidlContext(context) {
delete contexts[context.id];
}
watch([() => props2.latitude, () => props2.longitude], ([latitudeVlaue, longitudeVlaue]) => {
const latitude = Number(latitudeVlaue);
const longitude = Number(longitudeVlaue);
if (latitude !== state2.latitude || longitude !== state2.longitude) {
state2.latitude = latitude;
state2.longitude = longitude;
if (map) {
map.setCenter(new maps2.LatLng(latitude, longitude));
const DEFAULT_BG_COLOR = "#f7f7fa";
const BLUR_EFFECT_COLOR_DARK = "rgb(0, 0, 0, 0.8)";
const BLUR_EFFECT_COLOR_LIGHT = "rgb(250, 250, 250, 0.8)";
const BLUR_EFFECT_COLORS = {
dark: BLUR_EFFECT_COLOR_DARK,
light: BLUR_EFFECT_COLOR_LIGHT,
extralight: BLUR_EFFECT_COLOR_LIGHT
};
const BORDER_COLORS = {
white: "rgba(255, 255, 255, 0.33)",
black: "rgba(0, 0, 0, 0.33)"
};
function useTabBarStyle(tabBar2) {
const style = computed(() => {
let backgroundColor = tabBar2.backgroundColor;
const blurEffect = tabBar2.blurEffect;
if (!backgroundColor) {
if (cssBackdropFilter && blurEffect && blurEffect !== "none") {
backgroundColor = BLUR_EFFECT_COLORS[blurEffect];
}
}
return {
backgroundColor: backgroundColor || DEFAULT_BG_COLOR,
backdropFilter: blurEffect !== "none" ? "blur(10px)" : blurEffect
};
});
watch(() => props2.includePoints, (points) => {
state2.includePoints = getPoints(points);
if (isBoundsReady) {
updateBounds();
}
}, {
deep: true
const borderStyle = computed(() => {
const {
borderStyle: borderStyle2
} = tabBar2;
return {
backgroundColor: BORDER_COLORS[borderStyle2] || borderStyle2
};
});
function emitBoundsReady() {
isBoundsReady = true;
onBoundsReadyCallbacks.forEach((callback) => callback());
onBoundsReadyCallbacks.length = 0;
}
function getMapInfo() {
const center = map.getCenter();
const placeholderStyle = computed(() => {
return {
scale: map.getZoom(),
centerLocation: {
latitude: center.getLat(),
longitude: center.getLng()
}
height: tabBar2.height
};
}
function updateCenter() {
map.setCenter(new maps2.LatLng(state2.latitude, state2.longitude));
}
function updateBounds() {
const bounds = new maps2.LatLngBounds();
state2.includePoints.forEach(({
latitude,
longitude
}) => {
const latLng = new maps2.LatLng(latitude, longitude);
bounds.extend(latLng);
});
map.fitBounds(bounds);
}
function initMap() {
const mapEl = mapRef.value;
const center = new maps2.LatLng(state2.latitude, state2.longitude);
const map2 = new maps2.Map(mapEl, {
center,
zoom: Number(props2.scale),
disableDoubleClickZoom: true,
mapTypeControl: false,
zoomControl: false,
scaleControl: false,
panControl: false,
minZoom: 5,
maxZoom: 18,
draggable: true
});
watch(() => props2.scale, (scale) => {
map2.setZoom(Number(scale) || 16);
});
onBoundsReady(() => {
if (state2.includePoints.length) {
updateBounds();
updateCenter();
}
});
const boundsChangedEvent = maps2.event.addListener(map2, "bounds_changed", () => {
boundsChangedEvent.remove();
emitBoundsReady();
});
maps2.event.addListener(map2, "click", () => {
trigger("click", {}, {});
});
maps2.event.addListener(map2, "dragstart", () => {
trigger("regionchange", {}, {
type: "begin",
causedBy: "gesture"
});
});
maps2.event.addListener(map2, "dragend", () => {
trigger("regionchange", {}, Object.assign({
type: "end",
causedBy: "drag"
}, getMapInfo()));
});
maps2.event.addListener(map2, "zoom_changed", () => {
emit2("update:scale", map2.getZoom());
trigger("regionchange", {}, Object.assign({
type: "end",
causedBy: "scale"
}, getMapInfo()));
});
maps2.event.addListener(map2, "center_changed", () => {
const center2 = map2.getCenter();
const latitude = center2.getLat();
const longitude = center2.getLng();
emit2("update:latitude", latitude);
emit2("update:longitude", longitude);
});
return map2;
}
try {
const id2 = useContextInfo();
useSubscribe((type, data = {}) => {
switch (type) {
case "getCenterLocation":
onMapReady(() => {
const center = map.getCenter();
callOptions(data, {
latitude: center.getLat(),
longitude: center.getLng(),
errMsg: `${type}:ok`
});
});
break;
case "moveToLocation":
{
let latitude = Number(data.latitude);
let longitude = Number(data.longitude);
if (!latitude || !longitude) {
const context = contexts[CONTEXT_ID];
if (context) {
latitude = context.state.latitude;
longitude = context.state.longitude;
}
}
if (latitude && longitude) {
state2.latitude = latitude;
state2.longitude = longitude;
if (map) {
map.setCenter(new maps2.LatLng(latitude, longitude));
}
onMapReady(() => {
callOptions(data, `${type}:ok`);
});
} else {
callOptions(data, `${type}:fail`);
}
}
break;
case "translateMarker":
onMapReady(() => {
const context = contexts[data.markerId];
if (context) {
try {
context.translate(data);
} catch (error) {
callOptions(data, `${type}:fail ${error.message}`);
}
callOptions(data, `${type}:ok`);
} else {
callOptions(data, `${type}:fail not found`);
}
});
break;
case "includePoints":
state2.includePoints = getPoints(data.includePoints);
if (isBoundsReady) {
updateBounds();
}
onBoundsReady(() => {
callOptions(data, `${type}:ok`);
});
break;
case "getRegion":
onBoundsReady(() => {
const latLngBounds = map.getBounds();
const southwest = latLngBounds.getSouthWest();
const northeast = latLngBounds.getNorthEast();
callOptions(data, {
southwest: {
latitude: southwest.getLat(),
longitude: southwest.getLng()
},
northeast: {
latitude: northeast.getLat(),
longitude: northeast.getLng()
},
errMsg: `${type}:ok`
});
});
break;
case "getScale":
onMapReady(() => {
callOptions(data, {
scale: map.getZoom(),
errMsg: `${type}:ok`
});
});
break;
}
}, id2, true);
} catch (error) {
}
onMounted(() => {
loadMaps((result) => {
maps2 = result;
map = initMap();
emitMapReady();
trigger("updated", {}, {});
});
});
provide("onMapReady", onMapReady);
provide("addMapChidlContext", addMapChidlContext);
provide("removeMapChidlContext", removeMapChidlContext);
return {
state: state2,
mapRef
style,
borderStyle,
placeholderStyle
};
}
var Map$1 = /* @__PURE__ */ defineBuiltInComponent({
name: "Map",
props: props$1,
emits: ["markertap", "labeltap", "callouttap", "controltap", "regionchange", "tap", "click", "updated", "update:scale", "update:latitude", "update:longitude"],
setup(props2, {
emit: emit2,
slots
function isMidButton(item) {
return item.type === "midButton";
}
function createTabBarItemsTsx(tabBar2, onSwitchTab) {
const {
list: list2,
selectedIndex,
selectedColor,
color
} = tabBar2;
return list2.map((item, index2) => {
const selected = selectedIndex === index2;
const textColor = selected ? selectedColor : color;
const iconPath = (selected ? item.selectedIconPath || item.iconPath : item.iconPath) || "";
if (!__UNI_FEATURE_TABBAR_MIDBUTTON__) {
return createTabBarItemTsx(textColor, iconPath, item, tabBar2, index2, onSwitchTab);
}
return isMidButton(item) ? createTabBarMidButtonTsx(textColor, iconPath, item, tabBar2, index2, onSwitchTab) : createTabBarItemTsx(textColor, iconPath, item, tabBar2, index2, onSwitchTab);
});
}
function createTabBarItemTsx(color, iconPath, tabBarItem, tabBar2, index2, onSwitchTab) {
return createVNode("div", {
"key": index2,
"class": "uni-tabbar__item",
"onClick": onSwitchTab(tabBarItem, index2)
}, [createTabBarItemBdTsx(color, iconPath || "", tabBarItem, tabBar2)], 8, ["onClick"]);
}
function createTabBarItemBdTsx(color, iconPath, tabBarItem, tabBar2) {
const {
height
} = tabBar2;
return createVNode("div", {
"class": "uni-tabbar__bd",
"style": {
height
}
}, [iconPath && createTabBarItemIconTsx(iconPath, tabBarItem, tabBar2), tabBarItem.text && createTabBarItemTextTsx(color, tabBarItem, tabBar2)], 4);
}
function createTabBarItemIconTsx(iconPath, tabBarItem, tabBar2) {
const {
type,
text: text2,
redDot
} = tabBarItem;
const {
iconWidth
} = tabBar2;
const clazz2 = "uni-tabbar__icon" + (text2 ? " uni-tabbar__icon__diff" : "");
const style = {
width: iconWidth,
height: iconWidth
};
return createVNode("div", {
"class": clazz2,
"style": style
}, [type !== "midButton" && createVNode("img", {
"src": getRealPath(iconPath)
}, null, 8, ["src"]), redDot && createTabBarItemRedDotTsx(tabBarItem.badge)], 6);
}
function createTabBarItemTextTsx(color, tabBarItem, tabBar2) {
const {
redDot,
iconPath,
text: text2
} = tabBarItem;
const {
fontSize,
spacing
} = tabBar2;
const style = {
color,
fontSize,
lineHeight: !iconPath ? 1.8 : "normal",
marginTop: !iconPath ? "inherit" : spacing
};
return createVNode("div", {
"class": "uni-tabbar__label",
"style": style
}, [text2, redDot && !iconPath && createTabBarItemRedDotTsx(tabBarItem.badge)], 4);
}
function createTabBarItemRedDotTsx(badge) {
const clazz2 = "uni-tabbar__reddot" + (badge ? " uni-tabbar__badge" : "");
return createVNode("div", {
"class": clazz2
}, [badge], 2);
}
function createTabBarMidButtonTsx(color, iconPath, midButton, tabBar2, index2, onSwitchTab) {
const {
width,
height,
backgroundImage,
iconWidth
} = midButton;
return createVNode("div", {
"key": index2,
"class": "uni-tabbar__item",
"style": {
flex: "0 0 " + width,
position: "relative"
},
"onClick": onSwitchTab(midButton, index2)
}, [createVNode("div", {
"class": "uni-tabbar__mid",
"style": {
width,
height,
backgroundImage: backgroundImage ? "url('" + getRealPath(backgroundImage) + "')" : "none"
}
}, [iconPath && createVNode("img", {
"style": {
width: iconWidth,
height: iconWidth
},
"src": getRealPath(iconPath)
}, null, 12, ["src"])], 4), createTabBarItemBdTsx(color, iconPath, midButton, tabBar2)], 12, ["onClick"]);
}
const DEFAULT_CSS_VAR_VALUE = "0px";
let globalLayoutState;
function getLayoutState() {
return globalLayoutState;
}
var LayoutComponent = /* @__PURE__ */ defineSystemComponent({
name: "Layout",
setup(_props, {
emit: emit2
}) {
const rootRef = ref(null);
initCssVar();
const keepAliveRoute = __UNI_FEATURE_PAGES__ && useKeepAliveRoute();
const {
mapRef
} = useMap(props2, rootRef, emit2);
layoutState,
windowState
} = useState();
useMaxWidth(layoutState, rootRef);
const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState);
const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState);
const rightWindow = __UNI_FEATURE_RIGHTWINDOW__ && useRightWindow(layoutState);
const showTabBar2 = __UNI_FEATURE_TABBAR__ && useShowTabBar();
const clazz2 = useAppClass(showTabBar2);
globalLayoutState = layoutState;
return () => {
return createVNode("uni-map", {
const layoutTsx = createLayoutTsx(keepAliveRoute, layoutState, windowState, topWindow, leftWindow, rightWindow);
const tabBarTsx = __UNI_FEATURE_TABBAR__ && createTabBarTsx(showTabBar2);
return createVNode("uni-app", {
"ref": rootRef,
"id": props2.id
}, [createVNode("div", {
"ref": mapRef,
"style": "width: 100%; height: 100%; position: relative; overflow: hidden"
}, null, 512), props2.markers.map((item) => item.id && createVNode(MapMarker, mergeProps({
"key": item.id
}, item), null, 16)), props2.polyline.map((item) => createVNode(MapPolyline, item, null, 16)), props2.circles.map((item) => createVNode(MapCircle, item, null, 16)), props2.controls.map((item) => createVNode(MapControl, item, null, 16)), props2.showLocation && createVNode(MapLocation, null, null), createVNode("div", {
"style": "position: absolute;top: 0;width: 100%;height: 100%;overflow: hidden;pointer-events: none;"
}, [slots.default && slots.default()])], 8, ["id"]);
"class": clazz2.value
}, [layoutTsx, tabBarTsx], 2);
};
}
});
const props = {
scrollTop: {
type: [String, Number],
default: 0
}
};
var index$4 = /* @__PURE__ */ defineBuiltInComponent({
name: "CoverView",
compatConfig: {
MODE: 3
},
props,
setup(props2, {
slots
}) {
const content = ref(null);
watch(() => props2.scrollTop, (val) => {
setScrollTop(val);
});
function setScrollTop(val) {
let _content = content.value;
if (getComputedStyle(_content).overflowY === "scroll") {
_content.scrollTop = _upx2pxNum(val);
}
function useAppClass(showTabBar2) {
const showMaxWidth = ref(false);
return computed(() => {
return {
"uni-app--showtabbar": showTabBar2 && showTabBar2.value,
"uni-app--maxwidth": showMaxWidth.value
};
});
}
function initCssVar() {
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
});
}
function initMediaQuery(minWidth, callback) {
const mediaQueryList = window.matchMedia("(min-width: " + minWidth + "px)");
if (mediaQueryList.addEventListener) {
mediaQueryList.addEventListener("change", callback);
} else {
mediaQueryList.addListener(callback);
}
return mediaQueryList.matches;
}
function useMaxWidth(layoutState, rootRef) {
const route = useRoute();
function checkMaxWidth() {
const windowWidth = document.body.clientWidth;
const maxWidth = parseInt(String(route.meta.maxWidth || 1190));
let showMaxWidth = false;
if (windowWidth > maxWidth) {
showMaxWidth = true;
} else {
showMaxWidth = false;
}
function _upx2pxNum(val) {
let _val = String(val);
if (/\d+[ur]px$/i.test(_val)) {
_val.replace(/\d+[ur]px$/i, (text2) => {
return String(uni.upx2px(parseFloat(text2)));
});
}
return parseFloat(_val) || 0;
if (showMaxWidth && maxWidth) {
layoutState.marginWidth = (windowWidth - maxWidth) / 2;
nextTick(() => {
const rootEl = rootRef.value;
if (rootEl) {
rootEl.setAttribute("style", "max-width:" + maxWidth + "px;margin:0 auto;");
}
});
} else {
layoutState.marginWidth = 0;
nextTick(() => {
const rootEl = rootRef.value;
if (rootEl) {
rootEl.removeAttribute("style");
}
});
}
onMounted(() => {
setScrollTop(props2.scrollTop);
}
watch([() => route.path], checkMaxWidth);
onMounted(checkMaxWidth);
window.addEventListener("resize", checkMaxWidth);
}
function useState() {
const topWindowMediaQuery = ref(false);
const leftWindowMediaQuery = ref(false);
const rightWindowMediaQuery = ref(false);
const showTopWindow2 = computed(() => __UNI_FEATURE_TOPWINDOW__ && topWindowMediaQuery.value);
const showLeftWindow2 = computed(() => __UNI_FEATURE_LEFTWINDOW__ && leftWindowMediaQuery.value);
const showRightWindow2 = computed(() => __UNI_FEATURE_RIGHTWINDOW__ && rightWindowMediaQuery.value);
const layoutState = reactive({
topWindowMediaQuery,
showTopWindow: showTopWindow2,
apiShowTopWindow: false,
leftWindowMediaQuery,
showLeftWindow: showLeftWindow2,
apiShowLeftWindow: false,
rightWindowMediaQuery,
showRightWindow: showRightWindow2,
apiShowRightWindow: false,
topWindowHeight: 0,
marginWidth: 0,
leftWindowWidth: 0,
rightWindowWidth: 0,
topWindowStyle: {},
leftWindowStyle: {},
rightWindowStyle: {}
});
const props2 = ["topWindow", "leftWindow", "rightWindow"];
props2.forEach((prop) => {
const matchMedia = __uniConfig[prop]?.matchMedia;
let topWindowMinWidth = RESPONSIVE_MIN_WIDTH;
if (matchMedia && hasOwn(matchMedia, "minWidth")) {
const minWidth = matchMedia.minWidth;
topWindowMinWidth = checkMinWidth(minWidth) ? minWidth : topWindowMinWidth;
}
const matches = initMediaQuery(topWindowMinWidth, (ev) => {
layoutState[`${prop}MediaQuery`] = ev.matches;
});
return () => {
return createVNode("uni-cover-view", {
"scroll-top": props2.scrollTop
}, [createVNode("div", {
"ref": content,
"class": "uni-cover-view"
}, [slots.default && slots.default()], 512)], 8, ["scroll-top"]);
};
layoutState[`${prop}MediaQuery`] = matches;
});
watch(() => layoutState.topWindowHeight, (value) => updateCssVar({
"--top-window-height": value + "px"
}));
watch(() => layoutState.marginWidth, (value) => updateCssVar({
"--window-margin": value + "px"
}));
watch(() => layoutState.leftWindowWidth + layoutState.marginWidth, (value) => updateCssVar({
"--window-left": value + "px"
}));
watch(() => layoutState.rightWindowWidth + layoutState.marginWidth, (value) => updateCssVar({
"--window-right": value + "px"
}));
const windowState = reactive({
matchTopWindow: layoutState.topWindowMediaQuery,
showTopWindow: layoutState.showTopWindow || layoutState.apiShowTopWindow,
matchLeftWindow: layoutState.leftWindowMediaQuery,
showLeftWindow: layoutState.showLeftWindow || layoutState.apiShowLeftWindow,
matchRightWindow: layoutState.rightWindowMediaQuery,
showRightWindow: layoutState.showRightWindow || layoutState.apiShowRightWindow
});
return {
layoutState,
windowState
};
}
function createLayoutTsx(keepAliveRoute, layoutState, windowState, topWindow, leftWindow, rightWindow) {
const routerVNode = __UNI_FEATURE_PAGES__ ? createRouterViewVNode(keepAliveRoute) : createPageVNode();
if (!__UNI_FEATURE_RESPONSIVE__) {
return routerVNode;
}
const topWindowTsx = __UNI_FEATURE_TOPWINDOW__ ? createTopWindowTsx(topWindow, layoutState, windowState) : null;
const leftWindowTsx = __UNI_FEATURE_LEFTWINDOW__ ? createLeftWindowTsx(leftWindow, layoutState, windowState) : null;
const rightWindowTsx = __UNI_FEATURE_RIGHTWINDOW__ ? createRightWindowTsx(rightWindow, layoutState, windowState) : null;
return createVNode("uni-layout", null, [topWindowTsx, createVNode("uni-content", null, [createVNode("uni-main", null, [routerVNode]), leftWindowTsx, rightWindowTsx])]);
}
function useShowTabBar(emit2) {
const route = useRoute();
const tabBar2 = useTabBar();
const showTabBar2 = computed(() => route.meta.isTabBar && tabBar2.shown);
updateCssVar({
"--tab-bar-height": tabBar2.height
});
return showTabBar2;
}
function createTabBarTsx(showTabBar2) {
return withDirectives(createVNode(TabBar, null, null, 512), [[vShow, showTabBar2.value]]);
}
function createPageVNode() {
return createVNode(__uniRoutes[0].component);
}
function createRouterViewVNode({
routeKey,
isTabBar,
routeCache: routeCache2
}) {
return createVNode(RouterView, null, {
default: withCtx(({
Component
}) => [(openBlock(), createBlock(KeepAlive, {
matchBy: "key",
cache: routeCache2
}, [(openBlock(), createBlock(resolveDynamicComponent(Component), {
type: isTabBar.value ? "tabBar" : "",
key: routeKey.value
}))], 1032, ["cache"]))]),
_: 1
});
}
function useTopWindow(layoutState) {
const {
component,
style
} = __uniConfig.topWindow;
const windowRef = ref(null);
function updateWindow() {
const instalce = windowRef.value;
const el = instalce.$el;
const height = el.getBoundingClientRect().height;
layoutState.topWindowHeight = height;
}
onMounted(updateWindow);
watch(() => layoutState.showTopWindow || layoutState.apiShowTopWindow, () => nextTick(updateWindow));
layoutState.topWindowStyle = style;
return {
component,
windowRef
};
}
function useLeftWindow(layoutState) {
const {
component,
style
} = __uniConfig.leftWindow;
const windowRef = ref(null);
function updateWindow() {
const instalce = windowRef.value;
const el = instalce.$el;
const width = el.getBoundingClientRect().width;
layoutState.leftWindowWidth = width;
}
onMounted(updateWindow);
watch(() => layoutState.showLeftWindow || layoutState.apiShowLeftWindow, () => nextTick(updateWindow));
layoutState.leftWindowStyle = style;
return {
component,
windowRef
};
}
function useRightWindow(layoutState) {
const {
component,
style
} = __uniConfig.rightWindow;
const windowRef = ref(null);
function updateWindow() {
const instalce = windowRef.value;
const el = instalce.$el;
const width = el.getBoundingClientRect().width;
layoutState.rightWindowWidth = width;
}
onMounted(updateWindow);
watch(() => layoutState.showRightWindow || layoutState.apiShowRightWindow, () => nextTick(updateWindow));
layoutState.rightWindowStyle = style;
return {
component,
windowRef
};
}
function createTopWindowTsx(topWindow, layoutState, windowState) {
if (topWindow) {
const {
component: TopWindow,
windowRef
} = topWindow;
return withDirectives(createVNode("uni-top-window", null, [createVNode("div", {
"class": "uni-top-window",
"style": layoutState.topWindowStyle
}, [createVNode(TopWindow, mergeProps({
"ref": windowRef
}, windowState), null, 16)], 4), createVNode("div", {
"class": "uni-top-window--placeholder",
"style": {
height: layoutState.topWindowHeight + "px"
}
}, null, 4)], 512), [[vShow, layoutState.showTopWindow || layoutState.apiShowTopWindow]]);
}
}
function createLeftWindowTsx(leftWindow, layoutState, windowState) {
if (leftWindow) {
const {
component: LeftWindow,
windowRef
} = leftWindow;
return withDirectives(createVNode("uni-left-window", {
"data-show": layoutState.apiShowLeftWindow || void 0,
"style": layoutState.leftWindowStyle
}, [withDirectives(createVNode("div", {
"class": "uni-mask",
"onClick": () => layoutState.apiShowLeftWindow = false
}, null, 8, ["onClick"]), [[vShow, layoutState.apiShowLeftWindow]]), createVNode("div", {
"class": "uni-left-window"
}, [createVNode(LeftWindow, mergeProps({
"ref": windowRef
}, windowState), null, 16)])], 12, ["data-show"]), [[vShow, layoutState.showLeftWindow || layoutState.apiShowLeftWindow]]);
}
}
function createRightWindowTsx(rightWindow, layoutState, windowState) {
if (rightWindow) {
const {
component: RightWindow,
windowRef
} = rightWindow;
return withDirectives(createVNode("uni-right-window", {
"data-show": layoutState.apiShowRightWindow || void 0,
"style": layoutState.rightWindowStyle
}, [withDirectives(createVNode("div", {
"class": "uni-mask",
"onClick": () => layoutState.apiShowRightWindow = false
}, null, 8, ["onClick"]), [[vShow, layoutState.apiShowRightWindow]]), createVNode("div", {
"class": "uni-right-window"
}, [createVNode(RightWindow, mergeProps({
"ref": windowRef
}, windowState), null, 16)])], 12, ["data-show"]), [[vShow, layoutState.showRightWindow || layoutState.apiShowRightWindow]]);
}
}
var tasks = [];
function onResize() {
tasks.push(setTimeout(() => {
tasks.forEach((task) => clearTimeout(task));
tasks.length = 0;
const {windowWidth, windowHeight, screenWidth, screenHeight} = uni.getSystemInfoSync();
var landscape = Math.abs(Number(window.orientation)) === 90;
var deviceOrientation = landscape ? "landscape" : "portrait";
UniServiceJSBridge.invokeOnCallback(API_ON_WINDOW_RESIZE, {
deviceOrientation,
size: {
windowWidth,
windowHeight,
screenWidth,
screenHeight
}
});
}, 20));
}
const onWindowResize = /* @__PURE__ */ defineOnApi(API_ON_WINDOW_RESIZE, () => {
window.addEventListener("resize", onResize);
});
var index$3 = /* @__PURE__ */ defineBuiltInComponent({
name: "CoverImage",
compatConfig: {
MODE: 3
},
props: {
src: {
type: String,
default: ""
}
},
emits: ["load", "error"],
setup(props2, {
emit: emit2
}) {
const root = ref(null);
const trigger = useCustomEvent(root, emit2);
function load($event) {
trigger("load", $event);
}
function error($event) {
trigger("error", $event);
}
return () => {
const {
src
} = props2;
return createVNode("uni-cover-image", {
"ref": root,
"src": src
}, [createVNode("div", {
"class": "uni-cover-image"
}, [src ? createVNode("img", {
"src": getRealPath(src),
"onLoad": load,
"onError": error
}, null, 40, ["src", "onLoad", "onError"]) : null])], 8, ["src"]);
};
const offWindowResize = /* @__PURE__ */ defineOffApi(API_OFF_WINDOW_RESIZE, () => {
window.removeEventListener("resize", onResize);
});
const showTopWindow = /* @__PURE__ */ defineAsyncApi("showTopWindow", (_, {resolve, reject}) => {
const state2 = getLayoutState();
if (!state2) {
reject();
return;
}
state2.apiShowTopWindow = true;
nextTick(resolve);
});
const {t, getLocale} = useI18n();
function getDefaultStartValue() {
if (this.mode === mode.TIME) {
return "00:00";
const hideTopWindow = /* @__PURE__ */ defineAsyncApi("hideTopWindow", (_, {resolve, reject}) => {
const state2 = getLayoutState();
if (!state2) {
reject();
return;
}
if (this.mode === mode.DATE) {
const year = new Date().getFullYear() - 100;
switch (this.fields) {
case fields.YEAR:
return year.toString();
case fields.MONTH:
return year + "-01";
default:
return year + "-01-01";
}
state2.apiShowTopWindow = false;
nextTick(resolve);
});
const showLeftWindow = /* @__PURE__ */ defineAsyncApi("showLeftWindow", (_, {resolve, reject}) => {
const state2 = getLayoutState();
if (!state2) {
reject();
return;
}
return "";
}
function getDefaultEndValue() {
if (this.mode === mode.TIME) {
return "23:59";
state2.apiShowLeftWindow = true;
nextTick(resolve);
});
const hideLeftWindow = /* @__PURE__ */ defineAsyncApi("hideLeftWindow", (_, {resolve, reject}) => {
const state2 = getLayoutState();
if (!state2) {
reject();
return;
}
if (this.mode === mode.DATE) {
const year = new Date().getFullYear() + 100;
switch (this.fields) {
case fields.YEAR:
return year.toString();
case fields.MONTH:
return year + "-12";
default:
return year + "-12-31";
}
state2.apiShowLeftWindow = false;
nextTick(resolve);
});
const showRightWindow = /* @__PURE__ */ defineAsyncApi("showRightWindow", (_, {resolve, reject}) => {
const state2 = getLayoutState();
if (!state2) {
reject();
return;
}
return "";
}
const mode = {
SELECTOR: "selector",
MULTISELECTOR: "multiSelector",
TIME: "time",
DATE: "date"
};
const fields = {
YEAR: "year",
MONTH: "month",
DAY: "day"
};
const selectorType = {
PICKER: "picker",
SELECT: "select"
};
var _sfc_main$1 = {
name: "Picker",
compatConfig: {
MODE: 3
},
components: {PickerView, PickerViewColumn},
props: {
name: {
type: String,
default: ""
},
range: {
type: Array,
default() {
return [];
}
},
rangeKey: {
type: String,
default: ""
},
value: {
type: [Number, String, Array],
default: 0
},
mode: {
type: String,
default: mode.SELECTOR,
validator(val) {
return Object.values(mode).includes(val);
}
},
fields: {
type: String,
default: ""
},
start: {
type: String,
default: (props2) => {
return getDefaultStartValue.call(props2);
}
},
end: {
type: String,
default: (props2) => {
return getDefaultEndValue.call(props2);
}
},
disabled: {
type: [Boolean, String],
default: false
},
selectorType: {
type: String,
default: ""
}
},
data() {
return {
valueSync: null,
visible: false,
contentVisible: false,
popover: null,
valueChangeSource: "",
timeArray: [],
dateArray: [],
valueArray: [],
oldValueArray: [],
isDesktop: false,
popupStyle: {
content: {},
triangle: {}
}
};
},
computed: {
rangeArray() {
var val = this.range;
switch (this.mode) {
case mode.SELECTOR:
return [val];
case mode.MULTISELECTOR:
return val;
case mode.TIME:
return this.timeArray;
case mode.DATE: {
const dateArray = this.dateArray;
switch (this.fields) {
case fields.YEAR:
return [dateArray[0]];
case fields.MONTH:
return [dateArray[0], dateArray[1]];
default:
return [dateArray[0], dateArray[1], dateArray[2]];
}
}
}
return [];
},
startArray() {
return this._getDateValueArray(this.start, getDefaultStartValue.bind(this)());
},
endArray() {
return this._getDateValueArray(this.end, getDefaultEndValue.bind(this)());
},
selectorTypeComputed() {
const type = this.selectorType;
if (Object.values(selectorType).includes(type)) {
return type;
}
return String(navigator.vendor).indexOf("Apple") === 0 && navigator.maxTouchPoints > 0 ? selectorType.PICKER : selectorType.SELECT;
},
system() {
if (this.mode === mode.DATE && !Object.values(fields).includes(this.fields) && this.isDesktop && /win|mac/i.test(navigator.platform)) {
if (navigator.vendor === "Google Inc.") {
return "chrome";
} else if (/Firefox/.test(navigator.userAgent)) {
return "firefox";
}
}
return "";
}
},
watch: {
visible(val) {
if (val) {
clearTimeout(this.__contentVisibleDelay);
this.contentVisible = val;
this._select();
} else {
this.__contentVisibleDelay = setTimeout(() => {
this.contentVisible = val;
}, 300);
}
},
value: {
deep: true,
handler() {
this._setValueSync();
}
},
mode() {
this._setValueSync();
},
range: {
deep: true,
handler() {
this._setValueSync();
}
},
valueSync: {
deep: true,
handler() {
this._setValueArray();
}
},
valueArray: {
deep: true,
handler(val) {
if (this.mode === mode.TIME || this.mode === mode.DATE) {
const getValue = this.mode === mode.TIME ? this._getTimeValue : this._getDateValue;
const valueArray = this.valueArray;
const startArray = this.startArray;
const endArray = this.endArray;
if (this.mode === mode.DATE) {
const dateArray = this.dateArray;
const max = dateArray[2].length;
const day = Number(dateArray[2][valueArray[2]]) || 1;
const realDay = new Date(`${dateArray[0][valueArray[0]]}/${dateArray[1][valueArray[1]]}/${day}`).getDate();
if (realDay < day) {
valueArray[2] -= realDay + max - day;
}
}
if (getValue(valueArray) < getValue(startArray)) {
this._cloneArray(valueArray, startArray);
} else if (getValue(valueArray) > getValue(endArray)) {
this._cloneArray(valueArray, endArray);
}
}
val.forEach((value, column) => {
if (value !== this.oldValueArray[column]) {
this.oldValueArray[column] = value;
if (this.mode === mode.MULTISELECTOR) {
this.$trigger("columnchange", {}, {
column,
value
});
}
}
});
}
}
},
created() {
initI18nPickerMsgsOnce();
this._createTime();
this._createDate();
this._setValueSync();
usePickerWatch.call(this);
usePickerForm.call(this);
const popup = usePopupStyle(this);
this.isDesktop = popup.isDesktop;
this.popupStyle = popup.popupStyle;
},
mounted() {
this.$trigger = useCustomEvent({value: this.$refs.root}, this.$emit);
},
beforeUnmount() {
this.$refs.picker.remove();
},
methods: {
withWebEvent,
$$t: t,
_show(event) {
if (this.disabled) {
return;
}
this.valueChangeSource = "";
var $picker = this.$refs.picker;
$picker.remove();
(document.querySelector("uni-app") || document.body).appendChild($picker);
$picker.style.display = "block";
const rect = event.currentTarget.getBoundingClientRect();
this.popover = {
top: rect.top,
left: rect.left,
width: rect.width,
height: rect.height
};
setTimeout(() => {
this.visible = true;
}, 20);
},
_getFormData() {
return {
value: this.valueSync,
key: this.name
};
},
_resetFormData() {
switch (this.mode) {
case mode.SELECTOR:
this.valueSync = 0;
break;
case mode.MULTISELECTOR:
this.valueSync = this.value.map((val) => 0);
break;
case mode.DATE:
case mode.TIME:
this.valueSync = "";
break;
}
},
_createTime() {
var hours = [];
var minutes = [];
hours.splice(0, hours.length);
for (let i = 0; i < 24; i++) {
hours.push((i < 10 ? "0" : "") + i);
}
minutes.splice(0, minutes.length);
for (let i = 0; i < 60; i++) {
minutes.push((i < 10 ? "0" : "") + i);
}
this.timeArray.push(hours, minutes);
},
_createDate() {
var years = [];
var year = new Date().getFullYear();
for (let i = year - 150, end = year + 150; i <= end; i++) {
years.push(String(i));
}
var months = [];
for (let i = 1; i <= 12; i++) {
months.push((i < 10 ? "0" : "") + i);
}
var days = [];
for (let i = 1; i <= 31; i++) {
days.push((i < 10 ? "0" : "") + i);
}
this.dateArray.push(years, months, days);
},
_getTimeValue(val) {
return val[0] * 60 + val[1];
},
_getDateValue(val) {
const DAY = 31;
return val[0] * DAY * 12 + (val[1] || 0) * DAY + (val[2] || 0);
},
_cloneArray(val1, val2) {
for (let i = 0; i < val1.length && i < val2.length; i++) {
val1[i] = val2[i];
}
},
_setValueSync() {
let val = this.value;
switch (this.mode) {
case mode.MULTISELECTOR:
{
if (!Array.isArray(val)) {
val = [];
}
if (!Array.isArray(this.valueSync)) {
this.valueSync = [];
}
const length = this.valueSync.length = Math.max(val.length, this.range.length);
for (let index2 = 0; index2 < length; index2++) {
const val0 = Number(val[index2]);
const val1 = Number(this.valueSync[index2]);
const val2 = isNaN(val0) ? isNaN(val1) ? 0 : val1 : val0;
const maxVal = this.range[index2] ? this.range[index2].length - 1 : 0;
this.valueSync.splice(index2, 1, val2 < 0 || val2 > maxVal ? 0 : val2);
}
}
break;
case mode.TIME:
case mode.DATE:
this.valueSync = String(val);
break;
default: {
const valueSync = Number(val);
this.valueSync = valueSync < 0 ? 0 : valueSync;
break;
}
}
},
_setValueArray() {
var val = this.valueSync;
var valueArray;
switch (this.mode) {
case mode.MULTISELECTOR:
valueArray = [...val];
break;
case mode.TIME:
valueArray = this._getDateValueArray(val, formatDateTime({
mode: mode.TIME
}));
break;
case mode.DATE:
valueArray = this._getDateValueArray(val, formatDateTime({
mode: mode.DATE
}));
break;
default:
valueArray = [val];
break;
}
this.oldValueArray = [...valueArray];
this.valueArray = [...valueArray];
},
_getValue() {
var val = this.valueArray;
switch (this.mode) {
case mode.SELECTOR:
return val[0];
case mode.MULTISELECTOR:
return val.map((val2) => val2);
case mode.TIME:
return this.valueArray.map((val2, i) => this.timeArray[i][val2]).join(":");
case mode.DATE:
return this.valueArray.map((val2, i) => this.dateArray[i][val2]).join("-");
}
},
_getDateValueArray(valueStr, defaultValue) {
const splitStr = this.mode === mode.DATE ? "-" : ":";
const array = this.mode === mode.DATE ? this.dateArray : this.timeArray;
let max;
if (this.mode === mode.TIME) {
max = 2;
} else {
switch (this.fields) {
case fields.YEAR:
max = 1;
break;
case fields.MONTH:
max = 2;
break;
default:
max = 3;
break;
state2.apiShowRightWindow = true;
nextTick(resolve);
});
const hideRightWindow = /* @__PURE__ */ defineAsyncApi("hideRightWindow", (_, {resolve, reject}) => {
const state2 = getLayoutState();
if (!state2) {
reject();
return;
}
state2.apiShowRightWindow = false;
nextTick(resolve);
});
const getTopWindowStyle = /* @__PURE__ */ defineSyncApi("getTopWindowStyle", () => {
const state2 = getLayoutState();
return Object.assign({}, state2.topWindowStyle);
});
const setTopWindowStyle = /* @__PURE__ */ defineSyncApi("setTopWindowStyle", (style) => {
const state2 = getLayoutState();
state2.topWindowStyle = style;
});
const getLeftWindowStyle = /* @__PURE__ */ defineSyncApi("getLeftWindowStyle", () => {
const state2 = getLayoutState();
return Object.assign({}, state2.leftWindowStyle);
});
const setLeftWindowStyle = /* @__PURE__ */ defineSyncApi("setLeftWindowStyle", (style) => {
const state2 = getLayoutState();
state2.leftWindowStyle = style;
});
const getRightWindowStyle = /* @__PURE__ */ defineSyncApi("getRightWindowStyle", () => {
const state2 = getLayoutState();
return Object.assign({}, state2.rightWindowStyle);
});
const setRightWindowStyle = /* @__PURE__ */ defineSyncApi("setRightWindowStyle", (style) => {
const state2 = getLayoutState();
state2.rightWindowStyle = style;
});
var api = /* @__PURE__ */ Object.freeze({
__proto__: null,
[Symbol.toStringTag]: "Module",
upx2px,
addInterceptor,
removeInterceptor,
promiseInterceptor,
arrayBufferToBase64,
base64ToArrayBuffer,
createIntersectionObserver,
createMediaQueryObserver,
createSelectorQuery,
createVideoContext,
createMapContext,
createAnimation,
onTabBarMidButtonTap,
createCanvasContext,
canvasGetImageData,
canvasPutImageData,
canvasToTempFilePath,
getSelectedTextRange,
$on,
$off,
$once,
$emit,
cssVar,
cssEnv,
cssConstant,
cssBackdropFilter,
canIUse,
createInnerAudioContext,
makePhoneCall,
getSystemInfo,
getSystemInfoSync,
onNetworkStatusChange,
offNetworkStatusChange,
getNetworkType,
onAccelerometerChange,
offAccelerometerChange,
startAccelerometer,
stopAccelerometer,
onCompassChange,
offCompassChange,
startCompass,
stopCompass,
vibrateShort,
vibrateLong,
setStorageSync,
setStorage,
getStorageSync,
getStorage,
removeStorageSync,
removeStorage,
clearStorageSync,
clearStorage,
getStorageInfoSync,
getStorageInfo,
getFileInfo,
openDocument,
hideKeyboard,
getImageInfo,
getVideoInfo,
chooseFile,
chooseImage,
previewImage,
chooseVideo,
request,
downloadFile,
uploadFile,
connectSocket,
sendSocketMessage,
closeSocket,
onSocketOpen,
onSocketError,
onSocketMessage,
onSocketClose,
getLocation,
openLocation,
chooseLocation,
navigateBack,
navigateTo,
redirectTo,
reLaunch,
switchTab,
preloadPage,
showModal,
showToast,
showLoading,
hideToast,
hideLoading,
showActionSheet,
loadFontFace,
setNavigationBarColor,
showNavigationBarLoading,
hideNavigationBarLoading,
setNavigationBarTitle,
pageScrollTo,
startPullDownRefresh,
stopPullDownRefresh,
setTabBarItem,
setTabBarStyle,
hideTabBar,
showTabBar,
hideTabBarRedDot,
showTabBarRedDot,
removeTabBarBadge,
setTabBarBadge,
onWindowResize,
offWindowResize,
showTopWindow,
hideTopWindow,
showLeftWindow,
hideLeftWindow,
showRightWindow,
hideRightWindow,
getTopWindowStyle,
setTopWindowStyle,
getLeftWindowStyle,
setLeftWindowStyle,
getRightWindowStyle,
setRightWindowStyle
});
const CONTEXT_ID = "MAP_LOCATION";
const ICON_PATH = "data:image/png;base64,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";
var MapLocation = /* @__PURE__ */ defineSystemComponent({
name: "MapLocation",
setup() {
const state2 = reactive({
latitude: 0,
longitude: 0,
rotate: 0
});
{
let compassChangeHandler = function(res) {
state2.rotate = res.direction;
}, updateLocation = function() {
getLocation({
type: "gcj02",
success: (res) => {
state2.latitude = res.latitude;
state2.longitude = res.longitude;
},
complete: () => {
timer = setTimeout(updateLocation, 3e4);
}
});
}, removeLocation = function() {
if (timer) {
clearTimeout(timer);
}
offCompassChange(compassChangeHandler);
};
const onMapReady = inject("onMapReady");
let timer;
onCompassChange(compassChangeHandler);
onMapReady(updateLocation);
onUnmounted(removeLocation);
const addMapChidlContext = inject("addMapChidlContext");
const removeMapChidlContext = inject("removeMapChidlContext");
const context = {
id: CONTEXT_ID,
state: state2
};
addMapChidlContext(context);
onUnmounted(() => removeMapChidlContext(context));
}
return () => {
return state2.latitude ? createVNode(MapMarker, mergeProps({
"anchor": {
x: 0.5,
y: 0.5
},
"width": "44",
"height": "44",
"iconPath": ICON_PATH
}, state2), null, 16, ["iconPath"]) : null;
};
}
});
const props$1 = {
id: {
type: String,
default: ""
},
latitude: {
type: [String, Number],
default: 39.90374
},
longitude: {
type: [String, Number],
default: 116.397827
},
scale: {
type: [String, Number],
default: 16
},
markers: {
type: Array,
default() {
return [];
}
},
includePoints: {
type: Array,
default() {
return [];
}
},
polyline: {
type: Array,
default() {
return [];
}
},
circles: {
type: Array,
default() {
return [];
}
},
controls: {
type: Array,
default() {
return [];
}
},
showLocation: {
type: [Boolean, String],
default: false
}
};
function getPoints(points) {
const newPoints = [];
if (Array.isArray(points)) {
points.forEach((point) => {
if (point && point.latitude && point.longitude) {
newPoints.push({
latitude: point.latitude,
longitude: point.longitude
});
}
const inputArray = String(valueStr).split(splitStr);
let value = [];
for (let i = 0; i < max; i++) {
const val = inputArray[i];
value.push(array[i].indexOf(val));
}
if (value.indexOf(-1) >= 0) {
value = defaultValue ? this._getDateValueArray(defaultValue) : value.map(() => 0);
}
return value;
},
_change() {
this._close();
this.valueChangeSource = "click";
const value = this._getValue();
this.valueSync = Array.isArray(value) ? value.map((val) => val) : value;
this.$trigger("change", {}, {
value
});
},
_cancel($event) {
if (this.system === "firefox") {
const {top, left, width, height} = this.popover;
const {pageX, pageY} = $event;
if (pageX > left && pageX < left + width && pageY > top && pageY < top + height) {
return;
}
});
}
return newPoints;
}
function useMap(props2, rootRef, emit2) {
const trigger = useCustomEvent(rootRef, emit2);
const mapRef = ref(null);
let maps2;
let map;
const state2 = reactive({
latitude: Number(props2.latitude),
longitude: Number(props2.longitude),
includePoints: getPoints(props2.includePoints)
});
const onMapReadyCallbacks = [];
let isMapReady;
function onMapReady(callback) {
if (isMapReady) {
callback(map, maps2, trigger);
} else {
onMapReadyCallbacks.push(callback);
}
}
function emitMapReady() {
isMapReady = true;
onMapReadyCallbacks.forEach((callback) => callback(map, maps2, trigger));
onMapReadyCallbacks.length = 0;
}
let isBoundsReady;
const onBoundsReadyCallbacks = [];
function onBoundsReady(callback) {
if (isBoundsReady) {
callback();
} else {
onMapReadyCallbacks.push(callback);
}
}
const contexts = {};
function addMapChidlContext(context) {
contexts[context.id] = context;
}
function removeMapChidlContext(context) {
delete contexts[context.id];
}
watch([() => props2.latitude, () => props2.longitude], ([latitudeVlaue, longitudeVlaue]) => {
const latitude = Number(latitudeVlaue);
const longitude = Number(longitudeVlaue);
if (latitude !== state2.latitude || longitude !== state2.longitude) {
state2.latitude = latitude;
state2.longitude = longitude;
if (map) {
map.setCenter(new maps2.LatLng(latitude, longitude));
}
this._close();
this.$trigger("cancel", {}, {});
},
_close() {
this.visible = false;
setTimeout(() => {
var $picker = this.$refs.picker;
$picker.remove();
this.$el.prepend($picker);
$picker.style.display = "none";
}, 260);
},
_select() {
if (this.mode === mode.SELECTOR && this.selectorTypeComputed === selectorType.SELECT) {
this.$refs.select.scrollTop = this.valueArray[0] * 34;
}
});
watch(() => props2.includePoints, (points) => {
state2.includePoints = getPoints(points);
if (isBoundsReady) {
updateBounds();
}
}, {
deep: true
});
function emitBoundsReady() {
isBoundsReady = true;
onBoundsReadyCallbacks.forEach((callback) => callback());
onBoundsReadyCallbacks.length = 0;
}
function getMapInfo() {
const center = map.getCenter();
return {
scale: map.getZoom(),
centerLocation: {
latitude: center.getLat(),
longitude: center.getLng()
}
},
_input($event) {
this.valueSync = $event.target.value;
this.$nextTick(() => {
this._change();
});
},
_fixInputPosition($event) {
if (this.system === "chrome") {
const rect = this.$el.getBoundingClientRect();
const style = this.$refs.input.style;
const fontSize = 32;
style.left = `${$event.clientX - rect.left - fontSize * 1.5}px`;
style.top = `${$event.clientY - rect.top - fontSize * 0.5}px`;
};
}
function updateCenter() {
map.setCenter(new maps2.LatLng(state2.latitude, state2.longitude));
}
function updateBounds() {
const bounds = new maps2.LatLngBounds();
state2.includePoints.forEach(({
latitude,
longitude
}) => {
const latLng = new maps2.LatLng(latitude, longitude);
bounds.extend(latLng);
});
map.fitBounds(bounds);
}
function initMap() {
const mapEl = mapRef.value;
const center = new maps2.LatLng(state2.latitude, state2.longitude);
const map2 = new maps2.Map(mapEl, {
center,
zoom: Number(props2.scale),
disableDoubleClickZoom: true,
mapTypeControl: false,
zoomControl: false,
scaleControl: false,
panControl: false,
minZoom: 5,
maxZoom: 18,
draggable: true
});
watch(() => props2.scale, (scale) => {
map2.setZoom(Number(scale) || 16);
});
onBoundsReady(() => {
if (state2.includePoints.length) {
updateBounds();
updateCenter();
}
},
_pickerViewChange(event) {
this.valueArray = this._l10nColumn(event.detail.value, true);
},
_l10nColumn(array, normalize) {
if (this.mode === mode.DATE) {
const locale = getLocale();
if (!locale.startsWith("zh")) {
switch (this.fields) {
case fields.YEAR:
return array;
case fields.MONTH:
return [array[1], array[0]];
default:
switch (locale) {
case "es":
case "fr":
return [array[2], array[1], array[0]];
default:
return normalize ? [array[2], array[0], array[1]] : [array[1], array[2], array[0]];
});
const boundsChangedEvent = maps2.event.addListener(map2, "bounds_changed", () => {
boundsChangedEvent.remove();
emitBoundsReady();
});
maps2.event.addListener(map2, "click", () => {
trigger("click", {}, {});
});
maps2.event.addListener(map2, "dragstart", () => {
trigger("regionchange", {}, {
type: "begin",
causedBy: "gesture"
});
});
maps2.event.addListener(map2, "dragend", () => {
trigger("regionchange", {}, Object.assign({
type: "end",
causedBy: "drag"
}, getMapInfo()));
});
maps2.event.addListener(map2, "zoom_changed", () => {
emit2("update:scale", map2.getZoom());
trigger("regionchange", {}, Object.assign({
type: "end",
causedBy: "scale"
}, getMapInfo()));
});
maps2.event.addListener(map2, "center_changed", () => {
const center2 = map2.getCenter();
const latitude = center2.getLat();
const longitude = center2.getLng();
emit2("update:latitude", latitude);
emit2("update:longitude", longitude);
});
return map2;
}
try {
const id2 = useContextInfo();
useSubscribe((type, data = {}) => {
switch (type) {
case "getCenterLocation":
onMapReady(() => {
const center = map.getCenter();
callOptions(data, {
latitude: center.getLat(),
longitude: center.getLng(),
errMsg: `${type}:ok`
});
});
break;
case "moveToLocation":
{
let latitude = Number(data.latitude);
let longitude = Number(data.longitude);
if (!latitude || !longitude) {
const context = contexts[CONTEXT_ID];
if (context) {
latitude = context.state.latitude;
longitude = context.state.longitude;
}
}
if (latitude && longitude) {
state2.latitude = latitude;
state2.longitude = longitude;
if (map) {
map.setCenter(new maps2.LatLng(latitude, longitude));
}
onMapReady(() => {
callOptions(data, `${type}:ok`);
});
} else {
callOptions(data, `${type}:fail`);
}
}
}
}
return array;
},
_l10nItem(item, index2) {
if (this.mode === mode.DATE) {
const locale = getLocale();
if (locale.startsWith("zh")) {
const array = ["\u5E74", "\u6708", "\u65E5"];
return item + array[index2];
} else if (this.fields !== fields.YEAR && index2 === (this.fields !== fields.MONTH && (locale === "es" || locale === "fr") ? 1 : 0)) {
let array;
switch (locale) {
case "es":
array = [
"enero",
"febrero",
"marzo",
"abril",
"mayo",
"junio",
"\u200B\u200Bjulio",
"agosto",
"septiembre",
"octubre",
"noviembre",
"diciembre"
];
break;
case "fr":
array = [
"janvier",
"f\xE9vrier",
"mars",
"avril",
"mai",
"juin",
"juillet",
"ao\xFBt",
"septembre",
"octobre",
"novembre",
"d\xE9cembre"
];
break;
default:
array = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
break;
break;
case "translateMarker":
onMapReady(() => {
const context = contexts[data.markerId];
if (context) {
try {
context.translate(data);
} catch (error) {
callOptions(data, `${type}:fail ${error.message}`);
}
callOptions(data, `${type}:ok`);
} else {
callOptions(data, `${type}:fail not found`);
}
});
break;
case "includePoints":
state2.includePoints = getPoints(data.includePoints);
if (isBoundsReady) {
updateBounds();
}
return array[Number(item) - 1];
}
onBoundsReady(() => {
callOptions(data, `${type}:ok`);
});
break;
case "getRegion":
onBoundsReady(() => {
const latLngBounds = map.getBounds();
const southwest = latLngBounds.getSouthWest();
const northeast = latLngBounds.getNorthEast();
callOptions(data, {
southwest: {
latitude: southwest.getLat(),
longitude: southwest.getLng()
},
northeast: {
latitude: northeast.getLat(),
longitude: northeast.getLng()
},
errMsg: `${type}:ok`
});
});
break;
case "getScale":
onMapReady(() => {
callOptions(data, {
scale: map.getZoom(),
errMsg: `${type}:ok`
});
});
break;
}
return item;
}
},
setup(props2) {
const booleanAttrs = useBooleanAttr(props2, "disabled");
return {
booleanAttrs
}, id2, true);
} catch (error) {
}
onMounted(() => {
loadMaps((result) => {
maps2 = result;
map = initMap();
emitMapReady();
trigger("updated", {}, {});
});
});
provide("onMapReady", onMapReady);
provide("addMapChidlContext", addMapChidlContext);
provide("removeMapChidlContext", removeMapChidlContext);
return {
state: state2,
mapRef
};
}
var Map$1 = /* @__PURE__ */ defineBuiltInComponent({
name: "Map",
props: props$1,
emits: ["markertap", "labeltap", "callouttap", "controltap", "regionchange", "tap", "click", "updated", "update:scale", "update:latitude", "update:longitude"],
setup(props2, {
emit: emit2,
slots
}) {
const rootRef = ref(null);
const {
mapRef
} = useMap(props2, rootRef, emit2);
return () => {
return createVNode("uni-map", {
"ref": rootRef,
"id": props2.id
}, [createVNode("div", {
"ref": mapRef,
"style": "width: 100%; height: 100%; position: relative; overflow: hidden"
}, null, 512), props2.markers.map((item) => item.id && createVNode(MapMarker, mergeProps({
"key": item.id
}, item), null, 16)), props2.polyline.map((item) => createVNode(MapPolyline, item, null, 16)), props2.circles.map((item) => createVNode(MapCircle, item, null, 16)), props2.controls.map((item) => createVNode(MapControl, item, null, 16)), props2.showLocation && createVNode(MapLocation, null, null), createVNode("div", {
"style": "position: absolute;top: 0;width: 100%;height: 100%;overflow: hidden;pointer-events: none;"
}, [slots.default && slots.default()])], 8, ["id"]);
};
}
});
const props = {
scrollTop: {
type: [String, Number],
default: 0
}
};
function usePickerWatch() {
const {key, disable} = useKeyboard();
watch(() => this.visible, (value) => disable.value = !value);
watchEffect(() => {
const {value} = key;
if (value === "esc") {
this._cancel && this._cancel();
} else if (value === "enter") {
this._change && this._change();
var index$4 = /* @__PURE__ */ defineBuiltInComponent({
name: "CoverView",
compatConfig: {
MODE: 3
},
props,
setup(props2, {
slots
}) {
const content = ref(null);
watch(() => props2.scrollTop, (val) => {
setScrollTop(val);
});
function setScrollTop(val) {
let _content = content.value;
if (getComputedStyle(_content).overflowY === "scroll") {
_content.scrollTop = _upx2pxNum(val);
}
}
});
}
function usePickerForm() {
const uniForm = inject(uniFormKey, false);
if (!!uniForm) {
const field = {
reset: this._resetFormData,
submit: () => {
const data = ["", null];
const {key, value} = this._getFormData();
if (key !== "") {
data[0] = key;
data[1] = value;
}
return data;
function _upx2pxNum(val) {
let _val = String(val);
if (/\d+[ur]px$/i.test(_val)) {
_val.replace(/\d+[ur]px$/i, (text2) => {
return String(uni.upx2px(parseFloat(text2)));
});
}
};
uniForm.addField(field);
onBeforeUnmount(() => {
uniForm.removeField(field);
return parseFloat(_val) || 0;
}
onMounted(() => {
setScrollTop(props2.scrollTop);
});
}
}
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
const _component_PickerViewColumn = resolveComponent("PickerViewColumn");
const _component_PickerView = resolveComponent("PickerView");
return openBlock(), createBlock("uni-picker", mergeProps({ref: "root"}, $setup.booleanAttrs, {
onClick: _cache[13] || (_cache[13] = (() => $options.withWebEvent($options._show))())
}), [
createVNode("div", {
ref: "picker",
class: ["uni-picker-container", `uni-${$props.mode}-${$options.selectorTypeComputed}`],
onWheel: _cache[9] || (_cache[9] = withModifiers(() => {
}, ["prevent"])),
onTouchmove: _cache[10] || (_cache[10] = withModifiers(() => {
}, ["prevent"]))
}, [
createVNode(Transition, {name: "uni-fade"}, {
default: withCtx(() => [
withDirectives(createVNode("div", {
class: "uni-mask uni-picker-mask",
onClick: _cache[1] || (_cache[1] = (() => $options.withWebEvent($options._cancel))()),
onMousemove: _cache[2] || (_cache[2] = (...args) => $options._fixInputPosition && $options._fixInputPosition(...args))
}, null, 544), [
[vShow, $data.visible]
])
]),
_: 1
}),
!$options.system ? (openBlock(), createBlock("div", {
key: 0,
class: [{"uni-picker-toggle": $data.visible}, "uni-picker-custom"],
style: $data.popupStyle.content
}, [
createVNode("div", {
class: "uni-picker-header",
onClick: _cache[5] || (_cache[5] = withModifiers(() => {
}, ["stop"]))
}, [
createVNode("div", {
class: "uni-picker-action uni-picker-action-cancel",
onClick: _cache[3] || (_cache[3] = (() => $options.withWebEvent($options._cancel))())
}, toDisplayString($options.$$t("uni.picker.cancel")), 1),
createVNode("div", {
class: "uni-picker-action uni-picker-action-confirm",
onClick: _cache[4] || (_cache[4] = (...args) => $options._change && $options._change(...args))
}, toDisplayString($options.$$t("uni.picker.done")), 1)
]),
$data.contentVisible ? (openBlock(), createBlock(_component_PickerView, {
key: 0,
value: $options._l10nColumn($data.valueArray),
class: "uni-picker-content",
onChange: _cache[6] || (_cache[6] = (() => $options.withWebEvent($options._pickerViewChange))())
}, {
default: withCtx(() => [
(openBlock(true), createBlock(Fragment, null, renderList($options._l10nColumn($options.rangeArray), (rangeItem, index0) => {
return openBlock(), createBlock(_component_PickerViewColumn, {key: index0}, {
default: withCtx(() => [
(openBlock(true), createBlock(Fragment, null, renderList(rangeItem, (item, index2) => {
return openBlock(), createBlock("div", {
key: index2,
class: "uni-picker-item"
}, toDisplayString(typeof item === "object" ? item[$props.rangeKey] || "" : $options._l10nItem(item, index0)), 1);
}), 128))
]),
_: 2
}, 1024);
}), 128))
]),
_: 1
}, 8, ["value"])) : createCommentVNode("", true),
createVNode("div", {
ref: "select",
class: "uni-picker-select",
onWheel: _cache[7] || (_cache[7] = withModifiers(() => {
}, ["stop"])),
onTouchmove: _cache[8] || (_cache[8] = withModifiers(() => {
}, ["stop"]))
}, [
(openBlock(true), createBlock(Fragment, null, renderList($options.rangeArray[0], (item, index2) => {
return openBlock(), createBlock("div", {
key: index2,
class: ["uni-picker-item", {selected: $data.valueArray[0] === index2}],
onClick: ($event) => {
$data.valueArray[0] = index2;
$options._change();
}
}, toDisplayString(typeof item === "object" ? item[$props.rangeKey] || "" : item), 11, ["onClick"]);
}), 128))
], 544),
createVNode("div", {
style: $data.popupStyle.triangle
}, null, 4)
], 6)) : createCommentVNode("", true)
], 34),
createVNode("div", null, [
renderSlot(_ctx.$slots, "default")
]),
$options.system ? (openBlock(), createBlock("div", {
key: 0,
class: "uni-picker-system",
onMousemove: _cache[12] || (_cache[12] = (() => $options.withWebEvent($options._fixInputPosition))())
}, [
createVNode("input", {
ref: "input",
value: $data.valueSync,
type: $props.mode,
tabindex: "-1",
min: $props.start,
max: $props.end,
class: [$options.system, $data.popupStyle.dock],
onChange: _cache[11] || (_cache[11] = withModifiers((() => $options.withWebEvent($options._input))(), ["stop"]))
}, null, 42, ["value", "type", "min", "max"])
], 32)) : createCommentVNode("", true)
], 16);
}
_sfc_main$1.render = _sfc_render$1;
const UniViewJSBridge$1 = /* @__PURE__ */ extend(ViewJSBridge, {
publishHandler(event, args, pageId) {
UniServiceJSBridge.subscribeHandler(event, args, pageId);
}
});
const uni$1 = api;
const UniServiceJSBridge$1 = /* @__PURE__ */ extend(ServiceJSBridge, {
publishHandler(event, args, pageId) {
UniViewJSBridge.subscribeHandler(pageId + "." + event, args, pageId);
return () => {
return createVNode("uni-cover-view", {
"scroll-top": props2.scrollTop
}, [createVNode("div", {
"ref": content,
"class": "uni-cover-view"
}, [slots.default && slots.default()], 512)], 8, ["scroll-top"]);
};
}
});
var TabBar = /* @__PURE__ */ defineSystemComponent({
name: "TabBar",
setup() {
const tabBar2 = useTabBar();
useTabBarCssVar(tabBar2);
const onSwitchTab = useSwitchTab(useRoute(), tabBar2);
const {
style,
borderStyle,
placeholderStyle
} = useTabBarStyle(tabBar2);
var index$3 = /* @__PURE__ */ defineBuiltInComponent({
name: "CoverImage",
compatConfig: {
MODE: 3
},
props: {
src: {
type: String,
default: ""
}
},
emits: ["load", "error"],
setup(props2, {
emit: emit2
}) {
const root = ref(null);
const trigger = useCustomEvent(root, emit2);
function load($event) {
trigger("load", $event);
}
function error($event) {
trigger("error", $event);
}
return () => {
const tabBarItemsTsx = createTabBarItemsTsx(tabBar2, onSwitchTab);
return createVNode("uni-tabbar", {
"class": "uni-tabbar-" + tabBar2.position
}, [createVNode("div", {
"class": "uni-tabbar",
"style": style.value
}, [createVNode("div", {
"class": "uni-tabbar-border",
"style": borderStyle.value
}, null, 4), tabBarItemsTsx], 4), createVNode("div", {
"class": "uni-placeholder",
"style": placeholderStyle.value
}, null, 4)], 2);
const {
src
} = props2;
return createVNode("uni-cover-image", {
"ref": root,
"src": src
}, [createVNode("div", {
"class": "uni-cover-image"
}, [src ? createVNode("img", {
"src": getRealPath(src),
"onLoad": load,
"onError": error
}, null, 40, ["src", "onLoad", "onError"]) : null])], 8, ["src"]);
};
}
});
function useTabBarCssVar(tabBar2) {
watch(() => tabBar2.shown, (value) => {
updatePageCssVar({
"--window-bottom": normalizeWindowBottom(value ? parseInt(tabBar2.height) : 0)
});
});
const {t, getLocale} = useI18n();
function getDefaultStartValue() {
if (this.mode === mode.TIME) {
return "00:00";
}
if (this.mode === mode.DATE) {
const year = new Date().getFullYear() - 100;
switch (this.fields) {
case fields.YEAR:
return year.toString();
case fields.MONTH:
return year + "-01";
default:
return year + "-01-01";
}
}
return "";
}
function useSwitchTab(route, tabBar2) {
watchEffect(() => {
const meta = route.meta;
if (meta.isTabBar) {
const pagePath = meta.route;
const index2 = tabBar2.list.findIndex((item) => item.pagePath === pagePath);
if (index2 === -1) {
return;
function getDefaultEndValue() {
if (this.mode === mode.TIME) {
return "23:59";
}
if (this.mode === mode.DATE) {
const year = new Date().getFullYear() + 100;
switch (this.fields) {
case fields.YEAR:
return year.toString();
case fields.MONTH:
return year + "-12";
default:
return year + "-12-31";
}
}
return "";
}
const mode = {
SELECTOR: "selector",
MULTISELECTOR: "multiSelector",
TIME: "time",
DATE: "date"
};
const fields = {
YEAR: "year",
MONTH: "month",
DAY: "day"
};
const selectorType = {
PICKER: "picker",
SELECT: "select"
};
var _sfc_main$1 = {
name: "Picker",
compatConfig: {
MODE: 3
},
components: {PickerView, PickerViewColumn},
props: {
name: {
type: String,
default: ""
},
range: {
type: Array,
default() {
return [];
}
},
rangeKey: {
type: String,
default: ""
},
value: {
type: [Number, String, Array],
default: 0
},
mode: {
type: String,
default: mode.SELECTOR,
validator(val) {
return Object.values(mode).includes(val);
}
},
fields: {
type: String,
default: ""
},
start: {
type: String,
default: (props2) => {
return getDefaultStartValue.call(props2);
}
},
end: {
type: String,
default: (props2) => {
return getDefaultEndValue.call(props2);
}
},
disabled: {
type: [Boolean, String],
default: false
},
selectorType: {
type: String,
default: ""
}
},
data() {
return {
valueSync: null,
visible: false,
contentVisible: false,
popover: null,
valueChangeSource: "",
timeArray: [],
dateArray: [],
valueArray: [],
oldValueArray: [],
isDesktop: false,
popupStyle: {
content: {},
triangle: {}
}
};
},
computed: {
rangeArray() {
var val = this.range;
switch (this.mode) {
case mode.SELECTOR:
return [val];
case mode.MULTISELECTOR:
return val;
case mode.TIME:
return this.timeArray;
case mode.DATE: {
const dateArray = this.dateArray;
switch (this.fields) {
case fields.YEAR:
return [dateArray[0]];
case fields.MONTH:
return [dateArray[0], dateArray[1]];
default:
return [dateArray[0], dateArray[1], dateArray[2]];
}
}
}
return [];
},
startArray() {
return this._getDateValueArray(this.start, getDefaultStartValue.bind(this)());
},
endArray() {
return this._getDateValueArray(this.end, getDefaultEndValue.bind(this)());
},
selectorTypeComputed() {
const type = this.selectorType;
if (Object.values(selectorType).includes(type)) {
return type;
}
return String(navigator.vendor).indexOf("Apple") === 0 && navigator.maxTouchPoints > 0 ? selectorType.PICKER : selectorType.SELECT;
},
system() {
if (this.mode === mode.DATE && !Object.values(fields).includes(this.fields) && this.isDesktop && /win|mac/i.test(navigator.platform)) {
if (navigator.vendor === "Google Inc.") {
return "chrome";
} else if (/Firefox/.test(navigator.userAgent)) {
return "firefox";
}
}
return "";
}
},
watch: {
visible(val) {
if (val) {
clearTimeout(this.__contentVisibleDelay);
this.contentVisible = val;
this._select();
} else {
this.__contentVisibleDelay = setTimeout(() => {
this.contentVisible = val;
}, 300);
}
},
value: {
deep: true,
handler() {
this._setValueSync();
}
},
mode() {
this._setValueSync();
},
range: {
deep: true,
handler() {
this._setValueSync();
}
},
valueSync: {
deep: true,
handler() {
this._setValueArray();
}
},
valueArray: {
deep: true,
handler(val) {
if (this.mode === mode.TIME || this.mode === mode.DATE) {
const getValue = this.mode === mode.TIME ? this._getTimeValue : this._getDateValue;
const valueArray = this.valueArray;
const startArray = this.startArray;
const endArray = this.endArray;
if (this.mode === mode.DATE) {
const dateArray = this.dateArray;
const max = dateArray[2].length;
const day = Number(dateArray[2][valueArray[2]]) || 1;
const realDay = new Date(`${dateArray[0][valueArray[0]]}/${dateArray[1][valueArray[1]]}/${day}`).getDate();
if (realDay < day) {
valueArray[2] -= realDay + max - day;
}
}
if (getValue(valueArray) < getValue(startArray)) {
this._cloneArray(valueArray, startArray);
} else if (getValue(valueArray) > getValue(endArray)) {
this._cloneArray(valueArray, endArray);
}
}
val.forEach((value, column) => {
if (value !== this.oldValueArray[column]) {
this.oldValueArray[column] = value;
if (this.mode === mode.MULTISELECTOR) {
this.$trigger("columnchange", {}, {
column,
value
});
}
}
});
}
tabBar2.selectedIndex = index2;
}
});
return (tabBarItem, index2) => {
const {
type
} = tabBarItem;
return () => {
if (__UNI_FEATURE_TABBAR_MIDBUTTON__ && type === "midButton") {
return UniServiceJSBridge.invokeOnCallback(API_ON_TAB_BAR_MID_BUTTON_TAP);
},
created() {
initI18nPickerMsgsOnce();
this._createTime();
this._createDate();
this._setValueSync();
usePickerWatch.call(this);
usePickerForm.call(this);
const popup = usePopupStyle(this);
this.isDesktop = popup.isDesktop;
this.popupStyle = popup.popupStyle;
},
mounted() {
this.$trigger = useCustomEvent({value: this.$refs.root}, this.$emit);
},
beforeUnmount() {
this.$refs.picker.remove();
},
methods: {
withWebEvent,
$$t: t,
_show(event) {
if (this.disabled) {
return;
}
const {
pagePath,
text: text2
} = tabBarItem;
let url = "/" + pagePath;
if (url === __uniRoutes[0].alias) {
url = "/";
this.valueChangeSource = "";
var $picker = this.$refs.picker;
$picker.remove();
(document.querySelector("uni-app") || document.body).appendChild($picker);
$picker.style.display = "block";
const rect = event.currentTarget.getBoundingClientRect();
this.popover = {
top: rect.top,
left: rect.left,
width: rect.width,
height: rect.height
};
setTimeout(() => {
this.visible = true;
}, 20);
},
_getFormData() {
return {
value: this.valueSync,
key: this.name
};
},
_resetFormData() {
switch (this.mode) {
case mode.SELECTOR:
this.valueSync = 0;
break;
case mode.MULTISELECTOR:
this.valueSync = this.value.map((val) => 0);
break;
case mode.DATE:
case mode.TIME:
this.valueSync = "";
break;
}
if (route.path !== url) {
uni.switchTab({
from: "tabBar",
url
});
},
_createTime() {
var hours = [];
var minutes = [];
hours.splice(0, hours.length);
for (let i = 0; i < 24; i++) {
hours.push((i < 10 ? "0" : "") + i);
}
minutes.splice(0, minutes.length);
for (let i = 0; i < 60; i++) {
minutes.push((i < 10 ? "0" : "") + i);
}
this.timeArray.push(hours, minutes);
},
_createDate() {
var years = [];
var year = new Date().getFullYear();
for (let i = year - 150, end = year + 150; i <= end; i++) {
years.push(String(i));
}
var months = [];
for (let i = 1; i <= 12; i++) {
months.push((i < 10 ? "0" : "") + i);
}
var days = [];
for (let i = 1; i <= 31; i++) {
days.push((i < 10 ? "0" : "") + i);
}
this.dateArray.push(years, months, days);
},
_getTimeValue(val) {
return val[0] * 60 + val[1];
},
_getDateValue(val) {
const DAY = 31;
return val[0] * DAY * 12 + (val[1] || 0) * DAY + (val[2] || 0);
},
_cloneArray(val1, val2) {
for (let i = 0; i < val1.length && i < val2.length; i++) {
val1[i] = val2[i];
}
},
_setValueSync() {
let val = this.value;
switch (this.mode) {
case mode.MULTISELECTOR:
{
if (!Array.isArray(val)) {
val = [];
}
if (!Array.isArray(this.valueSync)) {
this.valueSync = [];
}
const length = this.valueSync.length = Math.max(val.length, this.range.length);
for (let index2 = 0; index2 < length; index2++) {
const val0 = Number(val[index2]);
const val1 = Number(this.valueSync[index2]);
const val2 = isNaN(val0) ? isNaN(val1) ? 0 : val1 : val0;
const maxVal = this.range[index2] ? this.range[index2].length - 1 : 0;
this.valueSync.splice(index2, 1, val2 < 0 || val2 > maxVal ? 0 : val2);
}
}
break;
case mode.TIME:
case mode.DATE:
this.valueSync = String(val);
break;
default: {
const valueSync = Number(val);
this.valueSync = valueSync < 0 ? 0 : valueSync;
break;
}
}
},
_setValueArray() {
var val = this.valueSync;
var valueArray;
switch (this.mode) {
case mode.MULTISELECTOR:
valueArray = [...val];
break;
case mode.TIME:
valueArray = this._getDateValueArray(val, formatDateTime({
mode: mode.TIME
}));
break;
case mode.DATE:
valueArray = this._getDateValueArray(val, formatDateTime({
mode: mode.DATE
}));
break;
default:
valueArray = [val];
break;
}
this.oldValueArray = [...valueArray];
this.valueArray = [...valueArray];
},
_getValue() {
var val = this.valueArray;
switch (this.mode) {
case mode.SELECTOR:
return val[0];
case mode.MULTISELECTOR:
return val.map((val2) => val2);
case mode.TIME:
return this.valueArray.map((val2, i) => this.timeArray[i][val2]).join(":");
case mode.DATE:
return this.valueArray.map((val2, i) => this.dateArray[i][val2]).join("-");
}
},
_getDateValueArray(valueStr, defaultValue) {
const splitStr = this.mode === mode.DATE ? "-" : ":";
const array = this.mode === mode.DATE ? this.dateArray : this.timeArray;
let max;
if (this.mode === mode.TIME) {
max = 2;
} else {
invokeHook("onTabItemTap", {
index: index2,
text: text2,
pagePath
});
switch (this.fields) {
case fields.YEAR:
max = 1;
break;
case fields.MONTH:
max = 2;
break;
default:
max = 3;
break;
}
}
const inputArray = String(valueStr).split(splitStr);
let value = [];
for (let i = 0; i < max; i++) {
const val = inputArray[i];
value.push(array[i].indexOf(val));
}
if (value.indexOf(-1) >= 0) {
value = defaultValue ? this._getDateValueArray(defaultValue) : value.map(() => 0);
}
return value;
},
_change() {
this._close();
this.valueChangeSource = "click";
const value = this._getValue();
this.valueSync = Array.isArray(value) ? value.map((val) => val) : value;
this.$trigger("change", {}, {
value
});
},
_cancel($event) {
if (this.system === "firefox") {
const {top, left, width, height} = this.popover;
const {pageX, pageY} = $event;
if (pageX > left && pageX < left + width && pageY > top && pageY < top + height) {
return;
}
}
this._close();
this.$trigger("cancel", {}, {});
},
_close() {
this.visible = false;
setTimeout(() => {
var $picker = this.$refs.picker;
$picker.remove();
this.$el.prepend($picker);
$picker.style.display = "none";
}, 260);
},
_select() {
if (this.mode === mode.SELECTOR && this.selectorTypeComputed === selectorType.SELECT) {
this.$refs.select.scrollTop = this.valueArray[0] * 34;
}
};
};
}
const DEFAULT_BG_COLOR = "#f7f7fa";
const BLUR_EFFECT_COLOR_DARK = "rgb(0, 0, 0, 0.8)";
const BLUR_EFFECT_COLOR_LIGHT = "rgb(250, 250, 250, 0.8)";
const BLUR_EFFECT_COLORS = {
dark: BLUR_EFFECT_COLOR_DARK,
light: BLUR_EFFECT_COLOR_LIGHT,
extralight: BLUR_EFFECT_COLOR_LIGHT
};
const BORDER_COLORS = {
white: "rgba(255, 255, 255, 0.33)",
black: "rgba(0, 0, 0, 0.33)"
};
function useTabBarStyle(tabBar2) {
const style = computed(() => {
let backgroundColor = tabBar2.backgroundColor;
const blurEffect = tabBar2.blurEffect;
if (!backgroundColor) {
if (cssBackdropFilter && blurEffect && blurEffect !== "none") {
backgroundColor = BLUR_EFFECT_COLORS[blurEffect];
},
_input($event) {
this.valueSync = $event.target.value;
this.$nextTick(() => {
this._change();
});
},
_fixInputPosition($event) {
if (this.system === "chrome") {
const rect = this.$el.getBoundingClientRect();
const style = this.$refs.input.style;
const fontSize = 32;
style.left = `${$event.clientX - rect.left - fontSize * 1.5}px`;
style.top = `${$event.clientY - rect.top - fontSize * 0.5}px`;
}
}
return {
backgroundColor: backgroundColor || DEFAULT_BG_COLOR,
backdropFilter: blurEffect !== "none" ? "blur(10px)" : blurEffect
};
});
const borderStyle = computed(() => {
const {
borderStyle: borderStyle2
} = tabBar2;
return {
backgroundColor: BORDER_COLORS[borderStyle2] || borderStyle2
};
});
const placeholderStyle = computed(() => {
return {
height: tabBar2.height
};
});
return {
style,
borderStyle,
placeholderStyle
};
}
function isMidButton(item) {
return item.type === "midButton";
}
function createTabBarItemsTsx(tabBar2, onSwitchTab) {
const {
list: list2,
selectedIndex,
selectedColor,
color
} = tabBar2;
return list2.map((item, index2) => {
const selected = selectedIndex === index2;
const textColor = selected ? selectedColor : color;
const iconPath = (selected ? item.selectedIconPath || item.iconPath : item.iconPath) || "";
if (!__UNI_FEATURE_TABBAR_MIDBUTTON__) {
return createTabBarItemTsx(textColor, iconPath, item, tabBar2, index2, onSwitchTab);
}
return isMidButton(item) ? createTabBarMidButtonTsx(textColor, iconPath, item, tabBar2, index2, onSwitchTab) : createTabBarItemTsx(textColor, iconPath, item, tabBar2, index2, onSwitchTab);
});
}
function createTabBarItemTsx(color, iconPath, tabBarItem, tabBar2, index2, onSwitchTab) {
return createVNode("div", {
"key": index2,
"class": "uni-tabbar__item",
"onClick": onSwitchTab(tabBarItem, index2)
}, [createTabBarItemBdTsx(color, iconPath || "", tabBarItem, tabBar2)], 8, ["onClick"]);
}
function createTabBarItemBdTsx(color, iconPath, tabBarItem, tabBar2) {
const {
height
} = tabBar2;
return createVNode("div", {
"class": "uni-tabbar__bd",
"style": {
height
}
}, [iconPath && createTabBarItemIconTsx(iconPath, tabBarItem, tabBar2), tabBarItem.text && createTabBarItemTextTsx(color, tabBarItem, tabBar2)], 4);
}
function createTabBarItemIconTsx(iconPath, tabBarItem, tabBar2) {
const {
type,
text: text2,
redDot
} = tabBarItem;
const {
iconWidth
} = tabBar2;
const clazz2 = "uni-tabbar__icon" + (text2 ? " uni-tabbar__icon__diff" : "");
const style = {
width: iconWidth,
height: iconWidth
};
return createVNode("div", {
"class": clazz2,
"style": style
}, [type !== "midButton" && createVNode("img", {
"src": getRealPath(iconPath)
}, null, 8, ["src"]), redDot && createTabBarItemRedDotTsx(tabBarItem.badge)], 6);
}
function createTabBarItemTextTsx(color, tabBarItem, tabBar2) {
const {
redDot,
iconPath,
text: text2
} = tabBarItem;
const {
fontSize,
spacing
} = tabBar2;
const style = {
color,
fontSize,
lineHeight: !iconPath ? 1.8 : "normal",
marginTop: !iconPath ? "inherit" : spacing
};
return createVNode("div", {
"class": "uni-tabbar__label",
"style": style
}, [text2, redDot && !iconPath && createTabBarItemRedDotTsx(tabBarItem.badge)], 4);
}
function createTabBarItemRedDotTsx(badge) {
const clazz2 = "uni-tabbar__reddot" + (badge ? " uni-tabbar__badge" : "");
return createVNode("div", {
"class": clazz2
}, [badge], 2);
}
function createTabBarMidButtonTsx(color, iconPath, midButton, tabBar2, index2, onSwitchTab) {
const {
width,
height,
backgroundImage,
iconWidth
} = midButton;
return createVNode("div", {
"key": index2,
"class": "uni-tabbar__item",
"style": {
flex: "0 0 " + width,
position: "relative"
},
"onClick": onSwitchTab(midButton, index2)
}, [createVNode("div", {
"class": "uni-tabbar__mid",
"style": {
width,
height,
backgroundImage: backgroundImage ? "url('" + getRealPath(backgroundImage) + "')" : "none"
_pickerViewChange(event) {
this.valueArray = this._l10nColumn(event.detail.value, true);
},
_l10nColumn(array, normalize) {
if (this.mode === mode.DATE) {
const locale = getLocale();
if (!locale.startsWith("zh")) {
switch (this.fields) {
case fields.YEAR:
return array;
case fields.MONTH:
return [array[1], array[0]];
default:
switch (locale) {
case "es":
case "fr":
return [array[2], array[1], array[0]];
default:
return normalize ? [array[2], array[0], array[1]] : [array[1], array[2], array[0]];
}
}
}
}
return array;
},
_l10nItem(item, index2) {
if (this.mode === mode.DATE) {
const locale = getLocale();
if (locale.startsWith("zh")) {
const array = ["\u5E74", "\u6708", "\u65E5"];
return item + array[index2];
} else if (this.fields !== fields.YEAR && index2 === (this.fields !== fields.MONTH && (locale === "es" || locale === "fr") ? 1 : 0)) {
let array;
switch (locale) {
case "es":
array = [
"enero",
"febrero",
"marzo",
"abril",
"mayo",
"junio",
"\u200B\u200Bjulio",
"agosto",
"septiembre",
"octubre",
"noviembre",
"diciembre"
];
break;
case "fr":
array = [
"janvier",
"f\xE9vrier",
"mars",
"avril",
"mai",
"juin",
"juillet",
"ao\xFBt",
"septembre",
"octobre",
"novembre",
"d\xE9cembre"
];
break;
default:
array = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
break;
}
return array[Number(item) - 1];
}
}
return item;
}
}, [iconPath && createVNode("img", {
"style": {
width: iconWidth,
height: iconWidth
},
"src": getRealPath(iconPath)
}, null, 12, ["src"])], 4), createTabBarItemBdTsx(color, iconPath, midButton, tabBar2)], 12, ["onClick"]);
}
const DEFAULT_CSS_VAR_VALUE = "0px";
var LayoutComponent = /* @__PURE__ */ defineSystemComponent({
name: "Layout",
setup(_props, {
emit: emit2
}) {
initCssVar();
const keepAliveRoute = __UNI_FEATURE_PAGES__ && useKeepAliveRoute();
__UNI_FEATURE_TOPWINDOW__ && useTopWindow();
__UNI_FEATURE_LEFTWINDOW__ && useLeftWindow();
__UNI_FEATURE_RIGHTWINDOW__ && useRightWindow();
const showTabBar2 = __UNI_FEATURE_TABBAR__ && useShowTabBar();
const clazz2 = useAppClass(showTabBar2);
return () => {
const layoutTsx = createLayoutTsx(keepAliveRoute);
const tabBarTsx = __UNI_FEATURE_TABBAR__ && createTabBarTsx(showTabBar2);
return createVNode("uni-app", {
"class": clazz2.value
}, [layoutTsx, tabBarTsx], 2);
};
}
});
function useAppClass(showTabBar2) {
const showMaxWidth = ref(false);
return computed(() => {
},
setup(props2) {
const booleanAttrs = useBooleanAttr(props2, "disabled");
return {
"uni-app--showtabbar": showTabBar2 && showTabBar2.value,
"uni-app--maxwidth": showMaxWidth.value
booleanAttrs
};
});
}
function initCssVar() {
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
});
}
function createLayoutTsx(keepAliveRoute, topWindow, leftWindow, rightWindow) {
const routerVNode = __UNI_FEATURE_PAGES__ ? createRouterViewVNode(keepAliveRoute) : createPageVNode();
if (!__UNI_FEATURE_RESPONSIVE__) {
return routerVNode;
}
const topWindowTsx = __UNI_FEATURE_TOPWINDOW__ ? createTopWindowTsx() : null;
const leftWindowTsx = __UNI_FEATURE_LEFTWINDOW__ ? createLeftWindowTsx() : null;
const rightWindowTsx = __UNI_FEATURE_RIGHTWINDOW__ ? createRightWindowTsx() : null;
return createVNode("uni-layout", null, [topWindowTsx, createVNode("uni-content", null, [createVNode("uni-main", null, [routerVNode]), leftWindowTsx, rightWindowTsx])]);
}
function useShowTabBar(emit2) {
const route = useRoute();
const tabBar2 = useTabBar();
const showTabBar2 = computed(() => route.meta.isTabBar && tabBar2.shown);
updateCssVar({
"--tab-bar-height": tabBar2.height
});
return showTabBar2;
}
function createTabBarTsx(showTabBar2) {
return withDirectives(createVNode(TabBar, null, null, 512), [[vShow, showTabBar2.value]]);
}
function createPageVNode() {
return createVNode(__uniRoutes[0].component);
}
function createRouterViewVNode({
routeKey,
isTabBar,
routeCache: routeCache2
}) {
return createVNode(RouterView, null, {
default: withCtx(({
Component
}) => [(openBlock(), createBlock(KeepAlive, {
matchBy: "key",
cache: routeCache2
}, [(openBlock(), createBlock(resolveDynamicComponent(Component), {
type: isTabBar.value ? "tabBar" : "",
key: routeKey.value
}))], 1032, ["cache"]))]),
_: 1
};
function usePickerWatch() {
const {key, disable} = useKeyboard();
watch(() => this.visible, (value) => disable.value = !value);
watchEffect(() => {
const {value} = key;
if (value === "esc") {
this._cancel && this._cancel();
} else if (value === "enter") {
this._change && this._change();
}
});
}
function useTopWindow() {
const component = resolveComponent("VUniTopWindow");
return {
component,
style: component.style,
height: 0,
show: false
};
}
function useLeftWindow() {
const component = resolveComponent("VUniLeftWindow");
return {
component,
style: component.style,
height: 0
};
}
function useRightWindow() {
const component = resolveComponent("VUniRightWindow");
return {
component,
style: component.style,
height: 0
};
}
function createTopWindowTsx(topWindow) {
}
function createLeftWindowTsx(leftWindow) {
function usePickerForm() {
const uniForm = inject(uniFormKey, false);
if (!!uniForm) {
const field = {
reset: this._resetFormData,
submit: () => {
const data = ["", null];
const {key, value} = this._getFormData();
if (key !== "") {
data[0] = key;
data[1] = value;
}
return data;
}
};
uniForm.addField(field);
onBeforeUnmount(() => {
uniForm.removeField(field);
});
}
}
function createRightWindowTsx(leftWindow) {
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
const _component_PickerViewColumn = resolveComponent("PickerViewColumn");
const _component_PickerView = resolveComponent("PickerView");
return openBlock(), createBlock("uni-picker", mergeProps({ref: "root"}, $setup.booleanAttrs, {
onClick: _cache[13] || (_cache[13] = (() => $options.withWebEvent($options._show))())
}), [
createVNode("div", {
ref: "picker",
class: ["uni-picker-container", `uni-${$props.mode}-${$options.selectorTypeComputed}`],
onWheel: _cache[9] || (_cache[9] = withModifiers(() => {
}, ["prevent"])),
onTouchmove: _cache[10] || (_cache[10] = withModifiers(() => {
}, ["prevent"]))
}, [
createVNode(Transition, {name: "uni-fade"}, {
default: withCtx(() => [
withDirectives(createVNode("div", {
class: "uni-mask uni-picker-mask",
onClick: _cache[1] || (_cache[1] = (() => $options.withWebEvent($options._cancel))()),
onMousemove: _cache[2] || (_cache[2] = (...args) => $options._fixInputPosition && $options._fixInputPosition(...args))
}, null, 544), [
[vShow, $data.visible]
])
]),
_: 1
}),
!$options.system ? (openBlock(), createBlock("div", {
key: 0,
class: [{"uni-picker-toggle": $data.visible}, "uni-picker-custom"],
style: $data.popupStyle.content
}, [
createVNode("div", {
class: "uni-picker-header",
onClick: _cache[5] || (_cache[5] = withModifiers(() => {
}, ["stop"]))
}, [
createVNode("div", {
class: "uni-picker-action uni-picker-action-cancel",
onClick: _cache[3] || (_cache[3] = (() => $options.withWebEvent($options._cancel))())
}, toDisplayString($options.$$t("uni.picker.cancel")), 1),
createVNode("div", {
class: "uni-picker-action uni-picker-action-confirm",
onClick: _cache[4] || (_cache[4] = (...args) => $options._change && $options._change(...args))
}, toDisplayString($options.$$t("uni.picker.done")), 1)
]),
$data.contentVisible ? (openBlock(), createBlock(_component_PickerView, {
key: 0,
value: $options._l10nColumn($data.valueArray),
class: "uni-picker-content",
onChange: _cache[6] || (_cache[6] = (() => $options.withWebEvent($options._pickerViewChange))())
}, {
default: withCtx(() => [
(openBlock(true), createBlock(Fragment, null, renderList($options._l10nColumn($options.rangeArray), (rangeItem, index0) => {
return openBlock(), createBlock(_component_PickerViewColumn, {key: index0}, {
default: withCtx(() => [
(openBlock(true), createBlock(Fragment, null, renderList(rangeItem, (item, index2) => {
return openBlock(), createBlock("div", {
key: index2,
class: "uni-picker-item"
}, toDisplayString(typeof item === "object" ? item[$props.rangeKey] || "" : $options._l10nItem(item, index0)), 1);
}), 128))
]),
_: 2
}, 1024);
}), 128))
]),
_: 1
}, 8, ["value"])) : createCommentVNode("", true),
createVNode("div", {
ref: "select",
class: "uni-picker-select",
onWheel: _cache[7] || (_cache[7] = withModifiers(() => {
}, ["stop"])),
onTouchmove: _cache[8] || (_cache[8] = withModifiers(() => {
}, ["stop"]))
}, [
(openBlock(true), createBlock(Fragment, null, renderList($options.rangeArray[0], (item, index2) => {
return openBlock(), createBlock("div", {
key: index2,
class: ["uni-picker-item", {selected: $data.valueArray[0] === index2}],
onClick: ($event) => {
$data.valueArray[0] = index2;
$options._change();
}
}, toDisplayString(typeof item === "object" ? item[$props.rangeKey] || "" : item), 11, ["onClick"]);
}), 128))
], 544),
createVNode("div", {
style: $data.popupStyle.triangle
}, null, 4)
], 6)) : createCommentVNode("", true)
], 34),
createVNode("div", null, [
renderSlot(_ctx.$slots, "default")
]),
$options.system ? (openBlock(), createBlock("div", {
key: 0,
class: "uni-picker-system",
onMousemove: _cache[12] || (_cache[12] = (() => $options.withWebEvent($options._fixInputPosition))())
}, [
createVNode("input", {
ref: "input",
value: $data.valueSync,
type: $props.mode,
tabindex: "-1",
min: $props.start,
max: $props.end,
class: [$options.system, $data.popupStyle.dock],
onChange: _cache[11] || (_cache[11] = withModifiers((() => $options.withWebEvent($options._input))(), ["stop"]))
}, null, 42, ["value", "type", "min", "max"])
], 32)) : createCommentVNode("", true)
], 16);
}
_sfc_main$1.render = _sfc_render$1;
const UniViewJSBridge$1 = /* @__PURE__ */ extend(ViewJSBridge, {
publishHandler(event, args, pageId) {
UniServiceJSBridge.subscribeHandler(event, args, pageId);
}
});
const uni$1 = api;
const UniServiceJSBridge$1 = /* @__PURE__ */ extend(ServiceJSBridge, {
publishHandler(event, args, pageId) {
UniViewJSBridge.subscribeHandler(pageId + "." + event, args, pageId);
}
});
function hexToRgba(hex) {
let r;
let g2;
......@@ -20261,4 +20567,4 @@ var index = /* @__PURE__ */ defineSystemComponent({
return openBlock(), createBlock("div", clazz, [loadingVNode]);
}
});
export {$emit, $off, $on, $once, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, _sfc_main$2 as Audio, index$r as Button, index$q as Canvas, index$o as Checkbox, index$p as CheckboxGroup, index$3 as CoverImage, index$4 as CoverView, index$n as Editor, index$t as Form, Friction, index$m as Icon, index$l as Image, Input, index$s as Label, LayoutComponent, Map$1 as Map, MovableArea, MovableView, index$k as Navigator, index$2 as PageComponent, _sfc_main$1 as Picker, PickerView, PickerViewColumn, index$j as Progress, index$h as Radio, index$i as RadioGroup, ResizeSensor, index$g as RichText, ScrollView, Scroller, index$f as Slider, Spring, Swiper, SwiperItem, index$e as Switch, index$d as Text, index$c as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$7 as Video, index$b as View, index$6 as WebView, addInterceptor, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closeSocket, connectSocket, createAnimation, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, defineBuiltInComponent, defineSystemComponent, disableScrollBounce, downloadFile, getApp$1 as getApp, getContextInfo, getCurrentPages$1 as getCurrentPages, getFileInfo, getImageInfo, getLocation, getNetworkType, getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getVideoInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, hideToast, initScrollBounce, loadFontFace, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offWindowResize, onAccelerometerChange, onCompassChange, onNetworkStatusChange, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onWindowResize, openDocument, openLocation, pageScrollTo, index$8 as plugin, preloadPage, previewImage, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, removeStorage, removeStorageSync, removeTabBarBadge, request, sendSocketMessage, setNavigationBarColor, setNavigationBarTitle, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setupApp, setupPage, showActionSheet, showLoading, showModal, showNavigationBarLoading, showTabBar, showTabBarRedDot, showToast, startAccelerometer, startCompass, startPullDownRefresh, stopAccelerometer, stopCompass, stopPullDownRefresh, switchTab, uni$1 as uni, uniFormKey, uploadFile, upx2px, useAttrs, useBooleanAttr, useContextInfo, useCustomEvent, useNativeEvent, useOn, useScroller, useSubscribe, useTouchtrack, useUserAction, vibrateLong, vibrateShort, withWebEvent};
export {$emit, $off, $on, $once, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, _sfc_main$2 as Audio, index$r as Button, index$q as Canvas, index$o as Checkbox, index$p as CheckboxGroup, index$3 as CoverImage, index$4 as CoverView, index$n as Editor, index$t as Form, Friction, index$m as Icon, index$l as Image, Input, index$s as Label, LayoutComponent, Map$1 as Map, MovableArea, MovableView, index$k as Navigator, index$2 as PageComponent, _sfc_main$1 as Picker, PickerView, PickerViewColumn, index$j as Progress, index$h as Radio, index$i as RadioGroup, ResizeSensor, index$g as RichText, ScrollView, Scroller, index$f as Slider, Spring, Swiper, SwiperItem, index$e as Switch, index$d as Text, index$c as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$7 as Video, index$b as View, index$6 as WebView, addInterceptor, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closeSocket, connectSocket, createAnimation, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, defineBuiltInComponent, defineSystemComponent, disableScrollBounce, downloadFile, getApp$1 as getApp, getContextInfo, getCurrentPages$1 as getCurrentPages, getFileInfo, getImageInfo, getLeftWindowStyle, getLocation, getNetworkType, getRightWindowStyle, getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, initScrollBounce, loadFontFace, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offWindowResize, onAccelerometerChange, onCompassChange, onNetworkStatusChange, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onWindowResize, openDocument, openLocation, pageScrollTo, index$8 as plugin, preloadPage, previewImage, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, removeStorage, removeStorageSync, removeTabBarBadge, request, sendSocketMessage, setLeftWindowStyle, setNavigationBarColor, setNavigationBarTitle, setRightWindowStyle, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startPullDownRefresh, stopAccelerometer, stopCompass, stopPullDownRefresh, switchTab, uni$1 as uni, uniFormKey, uploadFile, upx2px, useAttrs, useBooleanAttr, useContextInfo, useCustomEvent, useNativeEvent, useOn, useScroller, useSubscribe, useTouchtrack, useUserAction, vibrateLong, vibrateShort, withWebEvent};
......@@ -8,9 +8,14 @@ import {
createBlock,
createVNode,
SetupContext,
resolveComponent,
ConcreteComponent,
resolveDynamicComponent,
defineComponent,
reactive,
onMounted,
ComponentPublicInstance,
Ref,
watch,
nextTick,
} from 'vue'
import { RouterView, useRoute } from 'vue-router'
......@@ -19,6 +24,9 @@ import { defineSystemComponent } from '@dcloudio/uni-components'
import { updateCssVar } from '@dcloudio/uni-core'
import { useTabBar } from '../../setup/state'
import { useKeepAliveRoute } from '../../setup/page'
import { RESPONSIVE_MIN_WIDTH } from '@dcloudio/uni-shared'
import { checkMinWidth } from '../../../helpers/dom'
import { hasOwn } from '@vue/shared'
import TabBar from './tabBar'
......@@ -26,28 +34,40 @@ type KeepAliveRoute = ReturnType<typeof useKeepAliveRoute>
const DEFAULT_CSS_VAR_VALUE = '0px'
let globalLayoutState: LayoutState
export function getLayoutState() {
return globalLayoutState
}
export default /*#__PURE__*/ defineSystemComponent({
name: 'Layout',
setup(_props, { emit }) {
const rootRef: Ref<HTMLElement | null> = ref(null)
!__NODE_JS__ && initCssVar()
const keepAliveRoute = (__UNI_FEATURE_PAGES__ &&
useKeepAliveRoute()) as KeepAliveRoute
const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow()
const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow()
const rightWindow = __UNI_FEATURE_RIGHTWINDOW__ && useRightWindow()
const { layoutState, windowState } = useState()
useMaxWidth(layoutState, rootRef)
const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState)
const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState)
const rightWindow =
__UNI_FEATURE_RIGHTWINDOW__ && useRightWindow(layoutState)
const showTabBar = (__UNI_FEATURE_TABBAR__ &&
useShowTabBar(emit)) as ComputedRef<boolean>
const clazz = useAppClass(showTabBar)
globalLayoutState = layoutState
return () => {
const layoutTsx = createLayoutTsx(
keepAliveRoute,
layoutState,
windowState,
topWindow,
leftWindow,
rightWindow
)
const tabBarTsx = __UNI_FEATURE_TABBAR__ && createTabBarTsx(showTabBar)
return (
<uni-app class={clazz.value}>
<uni-app ref={rootRef} class={clazz.value}>
{layoutTsx}
{tabBarTsx}
</uni-app>
......@@ -76,9 +96,173 @@ function initCssVar() {
'--tab-bar-height': DEFAULT_CSS_VAR_VALUE,
})
}
interface LayoutState {
topWindowMediaQuery: boolean
showTopWindow: boolean
apiShowTopWindow: boolean
leftWindowMediaQuery: boolean
showLeftWindow: boolean
apiShowLeftWindow: boolean
rightWindowMediaQuery: boolean
showRightWindow: boolean
apiShowRightWindow: boolean
topWindowHeight: number
marginWidth: number
leftWindowWidth: number
rightWindowWidth: number
topWindowStyle: unknown
leftWindowStyle: unknown
rightWindowStyle: unknown
}
interface WindowState {
matchTopWindow?: boolean
showTopWindow?: boolean
matchLeftWindow?: boolean
showLeftWindow?: boolean
matchRightWindow?: boolean
showRightWindow?: boolean
}
function initMediaQuery(
minWidth: number,
callback: (ev: MediaQueryListEvent) => void
) {
const mediaQueryList = window.matchMedia('(min-width: ' + minWidth + 'px)')
if (mediaQueryList.addEventListener) {
mediaQueryList.addEventListener('change', callback)
} else {
mediaQueryList.addListener(callback)
}
return mediaQueryList.matches
}
function useMaxWidth(
layoutState: LayoutState,
rootRef: Ref<HTMLElement | null>
) {
const route = useRoute()
function checkMaxWidth() {
const windowWidth = document.body.clientWidth
const maxWidth = parseInt(String(route.meta.maxWidth || 1190))
let showMaxWidth = false
if (windowWidth > maxWidth) {
showMaxWidth = true
} else {
showMaxWidth = false
}
if (showMaxWidth && maxWidth) {
layoutState.marginWidth = (windowWidth - maxWidth) / 2
nextTick(() => {
const rootEl = rootRef.value
if (rootEl) {
rootEl.setAttribute(
'style',
'max-width:' + maxWidth + 'px;margin:0 auto;'
)
}
})
} else {
layoutState.marginWidth = 0
nextTick(() => {
const rootEl = rootRef.value
if (rootEl) {
rootEl.removeAttribute('style')
}
})
}
}
watch([() => route.path], checkMaxWidth)
onMounted(checkMaxWidth)
window.addEventListener('resize', checkMaxWidth)
}
function useState() {
const topWindowMediaQuery = ref(false)
const leftWindowMediaQuery = ref(false)
const rightWindowMediaQuery = ref(false)
const showTopWindow = computed(
() => __UNI_FEATURE_TOPWINDOW__ && topWindowMediaQuery.value
)
const showLeftWindow = computed(
() => __UNI_FEATURE_LEFTWINDOW__ && leftWindowMediaQuery.value
)
const showRightWindow = computed(
() => __UNI_FEATURE_RIGHTWINDOW__ && rightWindowMediaQuery.value
)
const layoutState: LayoutState = reactive({
topWindowMediaQuery,
showTopWindow,
apiShowTopWindow: false,
leftWindowMediaQuery,
showLeftWindow,
apiShowLeftWindow: false,
rightWindowMediaQuery,
showRightWindow,
apiShowRightWindow: false,
topWindowHeight: 0,
marginWidth: 0,
leftWindowWidth: 0,
rightWindowWidth: 0,
topWindowStyle: {},
leftWindowStyle: {},
rightWindowStyle: {},
})
const props: Array<'topWindow' | 'leftWindow' | 'rightWindow'> = [
'topWindow',
'leftWindow',
'rightWindow',
]
type StateProps =
| 'topWindowMediaQuery'
| 'leftWindowMediaQuery'
| 'rightWindowMediaQuery'
props.forEach((prop) => {
const matchMedia = __uniConfig[prop]?.matchMedia
let topWindowMinWidth = RESPONSIVE_MIN_WIDTH
if (matchMedia && hasOwn(matchMedia, 'minWidth')) {
const minWidth = matchMedia.minWidth!
topWindowMinWidth = checkMinWidth(minWidth) ? minWidth : topWindowMinWidth
}
const matches = initMediaQuery(topWindowMinWidth, (ev) => {
layoutState[`${prop}MediaQuery` as StateProps] = ev.matches
})
layoutState[`${prop}MediaQuery` as StateProps] = matches
})
watch(
() => layoutState.topWindowHeight,
(value) => updateCssVar({ '--top-window-height': value + 'px' })
)
watch(
() => layoutState.marginWidth,
(value) => updateCssVar({ '--window-margin': value + 'px' })
)
watch(
() => layoutState.leftWindowWidth + layoutState.marginWidth,
(value) => updateCssVar({ '--window-left': value + 'px' })
)
watch(
() => layoutState.rightWindowWidth + layoutState.marginWidth,
(value) => updateCssVar({ '--window-right': value + 'px' })
)
const windowState: WindowState = reactive({
matchTopWindow: layoutState.topWindowMediaQuery,
showTopWindow: layoutState.showTopWindow || layoutState.apiShowTopWindow,
matchLeftWindow: layoutState.leftWindowMediaQuery,
showLeftWindow: layoutState.showLeftWindow || layoutState.apiShowLeftWindow,
matchRightWindow: layoutState.rightWindowMediaQuery,
showRightWindow:
layoutState.showRightWindow || layoutState.apiShowRightWindow,
})
return {
layoutState,
windowState,
}
}
function createLayoutTsx(
keepAliveRoute: KeepAliveRoute,
layoutState: LayoutState,
windowState: WindowState,
topWindow?: unknown,
leftWindow?: unknown,
rightWindow?: unknown
......@@ -91,13 +275,13 @@ function createLayoutTsx(
return routerVNode
}
const topWindowTsx = __UNI_FEATURE_TOPWINDOW__
? createTopWindowTsx(topWindow)
? createTopWindowTsx(topWindow, layoutState, windowState)
: null
const leftWindowTsx = __UNI_FEATURE_LEFTWINDOW__
? createLeftWindowTsx(leftWindow)
? createLeftWindowTsx(leftWindow, layoutState, windowState)
: null
const rightWindowTsx = __UNI_FEATURE_RIGHTWINDOW__
? createRightWindowTsx(rightWindow)
? createRightWindowTsx(rightWindow, layoutState, windowState)
: null
return (
<uni-layout>
......@@ -157,32 +341,143 @@ function createRouterViewVNode({
})
}
function useTopWindow() {
const component = resolveComponent('VUniTopWindow') as ConcreteComponent
interface WindowComponentInfo {
component: ReturnType<typeof defineComponent>
windowRef: Ref<ComponentPublicInstance | null>
}
function useTopWindow(layoutState: LayoutState): WindowComponentInfo {
const { component, style } = __uniConfig.topWindow!
const windowRef: Ref<ComponentPublicInstance | null> = ref(null)
function updateWindow() {
const instalce = windowRef.value as ComponentPublicInstance
const el: HTMLElement = instalce.$el
const height = el.getBoundingClientRect().height
layoutState.topWindowHeight = height
}
onMounted(updateWindow)
watch(
() => layoutState.showTopWindow || layoutState.apiShowTopWindow,
() => nextTick(updateWindow)
)
layoutState.topWindowStyle = style
return {
component,
style: (component as any).style,
height: 0,
show: false,
windowRef,
}
}
function useLeftWindow() {
const component = resolveComponent('VUniLeftWindow') as ConcreteComponent
function useLeftWindow(layoutState: LayoutState): WindowComponentInfo {
const { component, style } = __uniConfig.leftWindow!
const windowRef: Ref<ComponentPublicInstance | null> = ref(null)
function updateWindow() {
const instalce = windowRef.value as ComponentPublicInstance
const el: HTMLElement = instalce.$el
const width = el.getBoundingClientRect().width
layoutState.leftWindowWidth = width
}
onMounted(updateWindow)
watch(
() => layoutState.showLeftWindow || layoutState.apiShowLeftWindow,
() => nextTick(updateWindow)
)
layoutState.leftWindowStyle = style
return {
component,
style: (component as any).style,
height: 0,
windowRef,
}
}
function useRightWindow() {
const component = resolveComponent('VUniRightWindow') as ConcreteComponent
function useRightWindow(layoutState: LayoutState): WindowComponentInfo {
const { component, style } = __uniConfig.rightWindow!
const windowRef: Ref<ComponentPublicInstance | null> = ref(null)
function updateWindow() {
const instalce = windowRef.value as ComponentPublicInstance
const el: HTMLElement = instalce.$el
const width = el.getBoundingClientRect().width
layoutState.rightWindowWidth = width
}
onMounted(updateWindow)
watch(
() => layoutState.showRightWindow || layoutState.apiShowRightWindow,
() => nextTick(updateWindow)
)
layoutState.rightWindowStyle = style
return {
component,
style: (component as any).style,
height: 0,
windowRef,
}
}
function createTopWindowTsx(topWindow: unknown) {}
function createLeftWindowTsx(leftWindow: unknown) {}
function createRightWindowTsx(leftWindow: unknown) {}
function createTopWindowTsx(
topWindow: unknown,
layoutState: LayoutState,
windowState: WindowState
) {
if (topWindow) {
const { component: TopWindow, windowRef } = topWindow as WindowComponentInfo
return (
<uni-top-window
v-show={layoutState.showTopWindow || layoutState.apiShowTopWindow}
>
<div class="uni-top-window" style={layoutState.topWindowStyle as any}>
<TopWindow ref={windowRef} {...windowState} />
</div>
<div
class="uni-top-window--placeholder"
style={{ height: layoutState.topWindowHeight + 'px' }}
/>
</uni-top-window>
)
}
}
function createLeftWindowTsx(
leftWindow: unknown,
layoutState: LayoutState,
windowState: WindowState
) {
if (leftWindow) {
const { component: LeftWindow, windowRef } =
leftWindow as WindowComponentInfo
return (
<uni-left-window
v-show={layoutState.showLeftWindow || layoutState.apiShowLeftWindow}
data-show={layoutState.apiShowLeftWindow || undefined}
style={layoutState.leftWindowStyle as any}
>
<div
v-show={layoutState.apiShowLeftWindow}
class="uni-mask"
onClick={() => (layoutState.apiShowLeftWindow = false)}
/>
<div class="uni-left-window">
<LeftWindow ref={windowRef} {...windowState} />
</div>
</uni-left-window>
)
}
}
function createRightWindowTsx(
rightWindow: unknown,
layoutState: LayoutState,
windowState: WindowState
) {
if (rightWindow) {
const { component: RightWindow, windowRef } =
rightWindow as WindowComponentInfo
return (
<uni-right-window
v-show={layoutState.showRightWindow || layoutState.apiShowRightWindow}
data-show={layoutState.apiShowRightWindow || undefined}
style={layoutState.rightWindowStyle as any}
>
<div
v-show={layoutState.apiShowRightWindow}
class="uni-mask"
onClick={() => (layoutState.apiShowRightWindow = false)}
/>
<div class="uni-right-window">
<RightWindow ref={windowRef} {...windowState} />
</div>
</uni-right-window>
)
}
}
import { nextTick } from 'vue'
import {
API_ON_WINDOW_RESIZE,
API_TYPE_ON_WINDOW_RESIZE,
......@@ -5,7 +6,10 @@ import {
API_TYPE_OFF_WINDOW_RESIZE,
defineOnApi,
defineOffApi,
defineAsyncApi,
defineSyncApi,
} from '@dcloudio/uni-api'
import { getLayoutState } from '../../../framework/components/layout'
var tasks: number[] = []
......@@ -57,3 +61,117 @@ export const offWindowResize = defineOffApi<API_TYPE_OFF_WINDOW_RESIZE>(
window.removeEventListener('resize', onResize)
}
)
export const showTopWindow = <typeof uni.showTopWindow>(
defineAsyncApi('showTopWindow', (_, { resolve, reject }) => {
const state = getLayoutState()
if (!state) {
reject()
return
}
state.apiShowTopWindow = true
nextTick(resolve)
})
)
export const hideTopWindow = <typeof uni.hideTopWindow>(
defineAsyncApi('hideTopWindow', (_, { resolve, reject }) => {
const state = getLayoutState()
if (!state) {
reject()
return
}
state.apiShowTopWindow = false
nextTick(resolve)
})
)
export const showLeftWindow = <typeof uni.showLeftWindow>(
defineAsyncApi('showLeftWindow', (_, { resolve, reject }) => {
const state = getLayoutState()
if (!state) {
reject()
return
}
state.apiShowLeftWindow = true
nextTick(resolve)
})
)
export const hideLeftWindow = <typeof uni.hideLeftWindow>(
defineAsyncApi('hideLeftWindow', (_, { resolve, reject }) => {
const state = getLayoutState()
if (!state) {
reject()
return
}
state.apiShowLeftWindow = false
nextTick(resolve)
})
)
export const showRightWindow = <typeof uni.showRightWindow>(
defineAsyncApi('showRightWindow', (_, { resolve, reject }) => {
const state = getLayoutState()
if (!state) {
reject()
return
}
state.apiShowRightWindow = true
nextTick(resolve)
})
)
export const hideRightWindow = <typeof uni.hideRightWindow>(
defineAsyncApi('hideRightWindow', (_, { resolve, reject }) => {
const state = getLayoutState()
if (!state) {
reject()
return
}
state.apiShowRightWindow = false
nextTick(resolve)
})
)
export const getTopWindowStyle = <typeof uni.getTopWindowStyle>(
defineSyncApi('getTopWindowStyle', () => {
const state = getLayoutState()
return Object.assign({}, state.topWindowStyle)
})
)
export const setTopWindowStyle = <typeof uni.setTopWindowStyle>(
defineSyncApi('setTopWindowStyle', (style) => {
const state = getLayoutState()
state.topWindowStyle = style
})
)
export const getLeftWindowStyle = <typeof uni.getLeftWindowStyle>(
defineSyncApi('getLeftWindowStyle', () => {
const state = getLayoutState()
return Object.assign({}, state.leftWindowStyle)
})
)
export const setLeftWindowStyle = <typeof uni.setLeftWindowStyle>(
defineSyncApi('setLeftWindowStyle', (style) => {
const state = getLayoutState()
state.leftWindowStyle = style
})
)
export const getRightWindowStyle = <typeof uni.getRightWindowStyle>(
defineSyncApi('getRightWindowStyle', () => {
const state = getLayoutState()
return Object.assign({}, state.rightWindowStyle)
})
)
export const setRightWindowStyle = <typeof uni.setRightWindowStyle>(
defineSyncApi('setRightWindowStyle', (style) => {
const state = getLayoutState()
state.rightWindowStyle = style
})
)
......@@ -7,5 +7,6 @@ declare module 'vue-router' {
topWindow?: boolean
leftWindow?: boolean
rightWindow?: boolean
maxWidth?: string | number
}
}
......@@ -65,6 +65,8 @@ function generatePagesJsonCode(
options.inputDir,
options.platform
)
const { importLayoutComponentsCode, defineLayoutComponentsCode } =
generateLayoutComponentsCode(globalName, pagesJson)
const definePagesCode = generatePagesDefineCode(pagesJson, config)
const uniRoutesCode = generateRoutes(globalName, pagesJson, config, options)
const uniConfigCode = generateConfig(globalName, pagesJson, options)
......@@ -77,9 +79,11 @@ function generatePagesJsonCode(
import { defineAsyncComponent, resolveComponent, createVNode, withCtx, openBlock, createBlock } from 'vue'
import { PageComponent, AsyncLoadingComponent, AsyncErrorComponent } from '@dcloudio/uni-h5'
import { appid, debug, networkTimeout, router, async, sdkConfigs, qqMapKey, nvue } from '${manifestJsonPath}'
${importLayoutComponentsCode}
const extend = Object.assign
${cssCode}
${uniConfigCode}
${defineLayoutComponentsCode}
${definePagesCode}
${uniRoutesCode}
${options.command === 'serve' ? hmrCode : ''}
......@@ -160,6 +164,31 @@ function generateCssCode(
return cssFiles.map((file) => `import '${file}'`).join('\n')
}
function generateLayoutComponentsCode(
globalName: string,
pagesJson: UniApp.PagesJson
) {
const windowNames: Array<'topWindow' | 'leftWindow' | 'rightWindow'> = [
'topWindow',
'leftWindow',
'rightWindow',
]
let importLayoutComponentsCode = ''
let defineLayoutComponentsCode = `${globalName}.__uniLayout = ${globalName}.__uniLayout || {}\n`
windowNames.forEach((name) => {
const windowConfig = pagesJson[name]
if (windowConfig && windowConfig.path) {
importLayoutComponentsCode += `import ${name} from './${windowConfig.path}'\n`
defineLayoutComponentsCode += `${globalName}.__uniConfig.${name}.component = ${name}\n`
}
})
return {
importLayoutComponentsCode,
defineLayoutComponentsCode,
}
}
function generatePageDefineCode(pageOptions: UniApp.PagesJsonPageOptions) {
const pageIdent = normalizePageIdentifier(pageOptions.path)
return `const ${pageIdent}Loader = ()=>import('./${pageOptions.path}?mpType=page')
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册