提交 357d19ea 编写于 作者: fxy060608's avatar fxy060608

chore: merge

......@@ -103,7 +103,7 @@ export * from './protocols/ad/fullScreenVideoAd'
export * from './protocols/ad/interstitialAd'
export * from './protocols/ad/interactiveAd'
export { onCreateVueApp } from '@dcloudio/uni-vue'
export { onCreateVueApp } from '@dcloudio/uni-shared'
// helpers
export {
......
import { isArray as isArray$1, hasOwn as hasOwn$1, isString, isPlainObject, isObject as isObject$1, toRawType, capitalize, makeMap, isFunction, isPromise, extend, toTypeString } from '@vue/shared';
import { LINEFEED, once, I18N_JSON_DELIMITERS, Emitter, addLeadingSlash, resolveComponentInstance, invokeArrayFns, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, SCHEME_RE, DATA_RE, cacheStringFunction, parseQuery, ON_ERROR, callOptions, PRIMARY_COLOR, removeLeadingSlash, getLen, formatLog, TABBAR_HEIGHT, NAVBAR_HEIGHT, ON_THEME_CHANGE, ON_KEYBOARD_HEIGHT_CHANGE, BACKGROUND_COLOR, ON_NAVIGATION_BAR_BUTTON_TAP, stringifyQuery as stringifyQuery$1, debounce, ON_PULL_DOWN_REFRESH, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_BACK_PRESS, UniNode, NODE_TYPE_PAGE, ACTION_TYPE_PAGE_CREATE, ACTION_TYPE_PAGE_CREATED, ACTION_TYPE_PAGE_SCROLL, ACTION_TYPE_INSERT, ACTION_TYPE_CREATE, ACTION_TYPE_REMOVE, ACTION_TYPE_ADD_EVENT, ACTION_TYPE_ADD_WXS_EVENT, ACTION_TYPE_REMOVE_EVENT, ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_REMOVE_ATTRIBUTE, ACTION_TYPE_SET_TEXT, ON_READY, ON_UNLOAD, EventChannel, ON_REACH_BOTTOM_DISTANCE, parseUrl, ON_TAB_ITEM_TAP, ON_LAUNCH, ACTION_TYPE_EVENT, createUniEvent, ON_WXS_INVOKE_CALL_METHOD, WEB_INVOKE_APPSERVICE } from '@dcloudio/uni-shared';
import { LINEFEED, once, I18N_JSON_DELIMITERS, Emitter, addLeadingSlash, resolveComponentInstance, invokeArrayFns, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, SCHEME_RE, DATA_RE, cacheStringFunction, parseQuery, ON_ERROR, callOptions, PRIMARY_COLOR, removeLeadingSlash, getLen, formatLog, TABBAR_HEIGHT, NAVBAR_HEIGHT, ON_THEME_CHANGE, ON_KEYBOARD_HEIGHT_CHANGE, BACKGROUND_COLOR, ON_NAVIGATION_BAR_BUTTON_TAP, stringifyQuery as stringifyQuery$1, debounce, ON_PULL_DOWN_REFRESH, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_BACK_PRESS, UniNode, NODE_TYPE_PAGE, ACTION_TYPE_PAGE_CREATE, ACTION_TYPE_PAGE_CREATED, ACTION_TYPE_PAGE_SCROLL, ACTION_TYPE_INSERT, ACTION_TYPE_CREATE, ACTION_TYPE_REMOVE, ACTION_TYPE_ADD_EVENT, ACTION_TYPE_ADD_WXS_EVENT, ACTION_TYPE_REMOVE_EVENT, ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_REMOVE_ATTRIBUTE, ACTION_TYPE_SET_TEXT, ON_READY, ON_UNLOAD, EventChannel, ON_REACH_BOTTOM_DISTANCE, parseUrl, onCreateVueApp, ON_TAB_ITEM_TAP, ON_LAUNCH, ACTION_TYPE_EVENT, createUniEvent, ON_WXS_INVOKE_CALL_METHOD, WEB_INVOKE_APPSERVICE } from '@dcloudio/uni-shared';
import { ref, createVNode, render, queuePostFlushCb, getCurrentInstance, onMounted, nextTick, onBeforeUnmount } from 'vue';
/*
......@@ -12439,13 +12439,6 @@ const CreateInteractiveAdProtocol = {
},
};
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
}
function warpPlusSuccessCallback(resolve, after) {
return function successCallback(data) {
delete data.code;
......
import { isString, isArray, isFunction } from '@vue/shared';
import { invokeArrayFns, ON_LOAD, LINEFEED, ON_SHOW, RENDERJS_MODULES, WXS_PROTOCOL, formatLog, WXS_MODULES, UniLifecycleHooks, ON_ERROR } from '@dcloudio/uni-shared';
import { invokeArrayFns, ON_LOAD, LINEFEED, ON_SHOW, RENDERJS_MODULES, WXS_PROTOCOL, formatLog, WXS_MODULES, UniLifecycleHooks, ON_ERROR, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
import { nextTick, injectHook } from 'vue';
function getCurrentPage() {
......@@ -250,13 +250,6 @@ function uniIdMixin(globalProperties) {
};
}
let vueApp;
const createVueAppHooks = [];
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
function initApp(app) {
const appConfig = app._context.config;
if (isFunction(app._component.onError)) {
......
[
"onCreateVueApp",
"$emit",
"$off",
"$on",
......@@ -80,7 +81,6 @@
"offWindowResize",
"onAccelerometerChange",
"onCompassChange",
"onCreateVueApp",
"onGyroscopeChange",
"onLocaleChange",
"onMemoryWarning",
......
......@@ -1455,151 +1455,6 @@ const SetNavigationBarTitleProtocol = {
};
const API_SHOW_NAVIGATION_BAR_LOADING = "showNavigationBarLoading";
const API_HIDE_NAVIGATION_BAR_LOADING = "hideNavigationBarLoading";
function injectLifecycleHook(name, hook, publicThis, instance) {
if (shared.isFunction(hook)) {
vue.injectHook(name, hook.bind(publicThis), instance);
}
}
function initHooks(options, instance, publicThis) {
const mpType = options.mpType || publicThis.$mpType;
Object.keys(options).forEach((name) => {
if (name.indexOf("on") === 0) {
const hooks = options[name];
if (shared.isArray(hooks)) {
hooks.forEach((hook) => injectLifecycleHook(name, hook, publicThis, instance));
} else {
injectLifecycleHook(name, hooks, publicThis, instance);
}
}
});
if (mpType === "page") {
instance.__isVisible = true;
try {
invokeHook(publicThis, uniShared.ON_LOAD, instance.attrs.__pageQuery);
delete instance.attrs.__pageQuery;
} catch (e2) {
console.error(e2.message + uniShared.LINEFEED + e2.stack);
}
vue.nextTick(() => {
invokeHook(publicThis, uniShared.ON_SHOW);
});
}
}
function applyOptions(options, instance, publicThis) {
initHooks(options, instance, publicThis);
}
function set(target, key, val) {
return target[key] = val;
}
function errorHandler(err, instance, info) {
if (!instance) {
throw err;
}
const app = getApp();
if (!app || !app.$vm) {
throw err;
}
{
invokeHook(app.$vm, uniShared.ON_ERROR, err);
}
}
function mergeAsArray(to, from) {
return to ? [...new Set([].concat(to, from))] : from;
}
function initOptionMergeStrategies(optionMergeStrategies) {
uniShared.UniLifecycleHooks.forEach((name) => {
optionMergeStrategies[name] = mergeAsArray;
});
}
let realAtob;
const b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
if (typeof atob !== "function") {
realAtob = function(str) {
str = String(str).replace(/[\t\n\f\r ]+/g, "");
if (!b64re.test(str)) {
throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
}
str += "==".slice(2 - (str.length & 3));
var bitmap;
var result = "";
var r1;
var r2;
var i = 0;
for (; i < str.length; ) {
bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 | (r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) : String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
}
return result;
};
} else {
realAtob = atob;
}
function b64DecodeUnicode(str) {
return decodeURIComponent(realAtob(str).split("").map(function(c) {
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
}).join(""));
}
function getCurrentUserInfo() {
const token = uni.getStorageSync("uni_id_token") || "";
const tokenArr = token.split(".");
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0
};
}
let userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error("\u83B7\u53D6\u5F53\u524D\u7528\u6237\u4FE1\u606F\u51FA\u9519\uFF0C\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F\u4E3A\uFF1A" + error.message);
}
userInfo.tokenExpired = userInfo.exp * 1e3;
delete userInfo.exp;
delete userInfo.iat;
return userInfo;
}
function uniIdMixin(globalProperties) {
globalProperties.uniIDHasRole = function(roleId) {
const { role } = getCurrentUserInfo();
return role.indexOf(roleId) > -1;
};
globalProperties.uniIDHasPermission = function(permissionId) {
const { permission } = getCurrentUserInfo();
return this.uniIDHasRole("admin") || permission.indexOf(permissionId) > -1;
};
globalProperties.uniIDTokenValid = function() {
const { tokenExpired } = getCurrentUserInfo();
return tokenExpired > Date.now();
};
}
const createVueAppHooks = [];
function invokeCreateVueAppHook(app) {
createVueAppHooks.forEach((hook) => hook(app));
}
function initApp$1(app) {
const appConfig = app._context.config;
if (shared.isFunction(app._component.onError)) {
appConfig.errorHandler = errorHandler;
}
initOptionMergeStrategies(appConfig.optionMergeStrategies);
const globalProperties = appConfig.globalProperties;
{
if (__UNI_FEATURE_UNI_CLOUD__) {
uniIdMixin(globalProperties);
}
}
{
globalProperties.$set = set;
globalProperties.$applyOptions = applyOptions;
}
{
invokeCreateVueAppHook(app);
}
}
function saveImage(base64, dirname, callback) {
callback(null, base64);
}
......@@ -6687,6 +6542,147 @@ function useContextInfo(_id) {
const id = _id || vm.id || `context${index$g++}`;
return `${type}.${id}`;
}
function injectLifecycleHook(name, hook, publicThis, instance) {
if (shared.isFunction(hook)) {
vue.injectHook(name, hook.bind(publicThis), instance);
}
}
function initHooks(options, instance, publicThis) {
const mpType = options.mpType || publicThis.$mpType;
Object.keys(options).forEach((name) => {
if (name.indexOf("on") === 0) {
const hooks = options[name];
if (shared.isArray(hooks)) {
hooks.forEach((hook) => injectLifecycleHook(name, hook, publicThis, instance));
} else {
injectLifecycleHook(name, hooks, publicThis, instance);
}
}
});
if (mpType === "page") {
instance.__isVisible = true;
try {
invokeHook(publicThis, uniShared.ON_LOAD, instance.attrs.__pageQuery);
delete instance.attrs.__pageQuery;
} catch (e2) {
console.error(e2.message + uniShared.LINEFEED + e2.stack);
}
vue.nextTick(() => {
invokeHook(publicThis, uniShared.ON_SHOW);
});
}
}
function applyOptions(options, instance, publicThis) {
initHooks(options, instance, publicThis);
}
function set(target, key, val) {
return target[key] = val;
}
function errorHandler(err, instance, info) {
if (!instance) {
throw err;
}
const app = getApp();
if (!app || !app.$vm) {
throw err;
}
{
invokeHook(app.$vm, uniShared.ON_ERROR, err);
}
}
function mergeAsArray(to, from) {
return to ? [...new Set([].concat(to, from))] : from;
}
function initOptionMergeStrategies(optionMergeStrategies) {
uniShared.UniLifecycleHooks.forEach((name) => {
optionMergeStrategies[name] = mergeAsArray;
});
}
let realAtob;
const b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
if (typeof atob !== "function") {
realAtob = function(str) {
str = String(str).replace(/[\t\n\f\r ]+/g, "");
if (!b64re.test(str)) {
throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
}
str += "==".slice(2 - (str.length & 3));
var bitmap;
var result = "";
var r1;
var r2;
var i = 0;
for (; i < str.length; ) {
bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 | (r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) : String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
}
return result;
};
} else {
realAtob = atob;
}
function b64DecodeUnicode(str) {
return decodeURIComponent(realAtob(str).split("").map(function(c) {
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
}).join(""));
}
function getCurrentUserInfo() {
const token = uni.getStorageSync("uni_id_token") || "";
const tokenArr = token.split(".");
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0
};
}
let userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error("\u83B7\u53D6\u5F53\u524D\u7528\u6237\u4FE1\u606F\u51FA\u9519\uFF0C\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F\u4E3A\uFF1A" + error.message);
}
userInfo.tokenExpired = userInfo.exp * 1e3;
delete userInfo.exp;
delete userInfo.iat;
return userInfo;
}
function uniIdMixin(globalProperties) {
globalProperties.uniIDHasRole = function(roleId) {
const { role } = getCurrentUserInfo();
return role.indexOf(roleId) > -1;
};
globalProperties.uniIDHasPermission = function(permissionId) {
const { permission } = getCurrentUserInfo();
return this.uniIDHasRole("admin") || permission.indexOf(permissionId) > -1;
};
globalProperties.uniIDTokenValid = function() {
const { tokenExpired } = getCurrentUserInfo();
return tokenExpired > Date.now();
};
}
function initApp$1(app) {
const appConfig = app._context.config;
if (shared.isFunction(app._component.onError)) {
appConfig.errorHandler = errorHandler;
}
initOptionMergeStrategies(appConfig.optionMergeStrategies);
const globalProperties = appConfig.globalProperties;
{
if (__UNI_FEATURE_UNI_CLOUD__) {
uniIdMixin(globalProperties);
}
}
{
globalProperties.$set = set;
globalProperties.$applyOptions = applyOptions;
}
{
uniShared.invokeCreateVueAppHook(app);
}
}
const pageMetaKey = PolySymbol(process.env.NODE_ENV !== "production" ? "UniPageMeta" : "upm");
function usePageMeta() {
return vue.inject(pageMetaKey);
......
import { withModifiers, createVNode, getCurrentInstance, ref, defineComponent, openBlock, createElementBlock, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, mergeProps, nextTick, injectHook, reactive, onActivated, onMounted, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, Comment, createTextVNode, onBeforeActivate, onBeforeDeactivate, createBlock, renderList, onDeactivated, createApp, Transition, effectScope, withCtx, KeepAlive, resolveDynamicComponent, createElementVNode, normalizeStyle, renderSlot } from "vue";
import { withModifiers, createVNode, getCurrentInstance, ref, defineComponent, openBlock, createElementBlock, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, mergeProps, reactive, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, Comment, createTextVNode, injectHook, onBeforeActivate, onBeforeDeactivate, createBlock, renderList, onDeactivated, createApp, Transition, effectScope, withCtx, KeepAlive, resolveDynamicComponent, createElementVNode, normalizeStyle, renderSlot } from "vue";
import { isString, extend, stringifyStyle, parseStringStyle, isPlainObject, isFunction, capitalize, camelize, isArray, hasOwn, isObject, toRawType, makeMap as makeMap$1, isPromise, hyphenate, invokeArrayFns as invokeArrayFns$1 } from "@vue/shared";
import { once, UNI_STORAGE_LOCALE, I18N_JSON_DELIMITERS, Emitter, passive, initCustomDatasetOnce, resolveComponentInstance, addLeadingSlash, invokeArrayFns, resolveOwnerVm, resolveOwnerEl, ON_WXS_INVOKE_CALL_METHOD, normalizeTarget, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, EventChannel, SCHEME_RE, DATA_RE, getCustomDataset, LINEFEED, ON_ERROR, callOptions, PRIMARY_COLOR, removeLeadingSlash, getLen, ON_LOAD, UniLifecycleHooks, debounce, NAVBAR_HEIGHT, parseQuery, ON_UNLOAD, ON_REACH_BOTTOM_DISTANCE, decodedQuery, WEB_INVOKE_APPSERVICE, ON_WEB_INVOKE_APP_SERVICE, updateElementStyle, ON_BACK_PRESS, parseUrl, addFont, scrollTo, RESPONSIVE_MIN_WIDTH, formatDateTime, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_PULL_DOWN_REFRESH } from "@dcloudio/uni-shared";
import { once, UNI_STORAGE_LOCALE, I18N_JSON_DELIMITERS, Emitter, passive, initCustomDatasetOnce, resolveComponentInstance, addLeadingSlash, invokeArrayFns, resolveOwnerVm, resolveOwnerEl, ON_WXS_INVOKE_CALL_METHOD, normalizeTarget, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, EventChannel, SCHEME_RE, DATA_RE, getCustomDataset, LINEFEED, ON_ERROR, callOptions, PRIMARY_COLOR, removeLeadingSlash, getLen, debounce, ON_LOAD, UniLifecycleHooks, invokeCreateVueAppHook, NAVBAR_HEIGHT, parseQuery, ON_UNLOAD, ON_REACH_BOTTOM_DISTANCE, decodedQuery, WEB_INVOKE_APPSERVICE, ON_WEB_INVOKE_APP_SERVICE, updateElementStyle, ON_BACK_PRESS, parseUrl, addFont, scrollTo, RESPONSIVE_MIN_WIDTH, onCreateVueApp, formatDateTime, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_PULL_DOWN_REFRESH } from "@dcloudio/uni-shared";
export { onCreateVueApp } from "@dcloudio/uni-shared";
import { initVueI18n, isI18nStr, 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";
const isEnableLocale = /* @__PURE__ */ once(() => typeof __uniConfig !== "undefined" && __uniConfig.locales && !!Object.keys(__uniConfig.locales).length);
......@@ -5417,159 +5418,6 @@ const SetTabBarBadgeOptions = {
}
}, IndexOptions.formatArgs)
};
function injectLifecycleHook(name, hook, publicThis, instance2) {
if (isFunction(hook)) {
injectHook(name, hook.bind(publicThis), instance2);
}
}
function initHooks(options, instance2, publicThis) {
const mpType = options.mpType || publicThis.$mpType;
Object.keys(options).forEach((name) => {
if (name.indexOf("on") === 0) {
const hooks = options[name];
if (isArray(hooks)) {
hooks.forEach((hook) => injectLifecycleHook(name, hook, publicThis, instance2));
} else {
injectLifecycleHook(name, hooks, publicThis, instance2);
}
}
});
if (mpType === "page") {
instance2.__isVisible = true;
try {
invokeHook(publicThis, ON_LOAD, instance2.attrs.__pageQuery);
delete instance2.attrs.__pageQuery;
} catch (e2) {
console.error(e2.message + LINEFEED + e2.stack);
}
nextTick(() => {
invokeHook(publicThis, ON_SHOW);
});
}
}
function applyOptions(options, instance2, publicThis) {
initHooks(options, instance2, publicThis);
}
function set(target, key, val) {
return target[key] = val;
}
function errorHandler(err, instance2, info) {
if (!instance2) {
throw err;
}
const app = getApp();
if (!app || !app.$vm) {
throw err;
}
{
invokeHook(app.$vm, ON_ERROR, err);
}
}
function mergeAsArray(to, from) {
return to ? [...new Set([].concat(to, from))] : from;
}
function initOptionMergeStrategies(optionMergeStrategies) {
UniLifecycleHooks.forEach((name) => {
optionMergeStrategies[name] = mergeAsArray;
});
}
let realAtob;
const b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
if (typeof atob !== "function") {
realAtob = function(str) {
str = String(str).replace(/[\t\n\f\r ]+/g, "");
if (!b64re.test(str)) {
throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
}
str += "==".slice(2 - (str.length & 3));
var bitmap;
var result = "";
var r1;
var r2;
var i = 0;
for (; i < str.length; ) {
bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 | (r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) : String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
}
return result;
};
} else {
realAtob = atob;
}
function b64DecodeUnicode(str) {
return decodeURIComponent(realAtob(str).split("").map(function(c) {
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
}).join(""));
}
function getCurrentUserInfo() {
const token = uni.getStorageSync("uni_id_token") || "";
const tokenArr = token.split(".");
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0
};
}
let userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error("\u83B7\u53D6\u5F53\u524D\u7528\u6237\u4FE1\u606F\u51FA\u9519\uFF0C\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F\u4E3A\uFF1A" + error.message);
}
userInfo.tokenExpired = userInfo.exp * 1e3;
delete userInfo.exp;
delete userInfo.iat;
return userInfo;
}
function uniIdMixin(globalProperties) {
globalProperties.uniIDHasRole = function(roleId) {
const { role } = getCurrentUserInfo();
return role.indexOf(roleId) > -1;
};
globalProperties.uniIDHasPermission = function(permissionId) {
const { permission } = getCurrentUserInfo();
return this.uniIDHasRole("admin") || permission.indexOf(permissionId) > -1;
};
globalProperties.uniIDTokenValid = function() {
const { tokenExpired } = getCurrentUserInfo();
return tokenExpired > Date.now();
};
}
let vueApp;
const createVueAppHooks = [];
function onCreateVueApp(hook) {
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
function initApp$1(app) {
const appConfig = app._context.config;
if (isFunction(app._component.onError)) {
appConfig.errorHandler = errorHandler;
}
initOptionMergeStrategies(appConfig.optionMergeStrategies);
const globalProperties = appConfig.globalProperties;
{
if (__UNI_FEATURE_UNI_CLOUD__) {
uniIdMixin(globalProperties);
}
}
{
globalProperties.$set = set;
globalProperties.$applyOptions = applyOptions;
}
{
invokeCreateVueAppHook(app);
}
}
const initIntersectionObserverPolyfill = function() {
if (typeof window !== "object") {
return;
......@@ -13649,6 +13497,147 @@ function useContextInfo(_id) {
function getContextInfo(el) {
return el.__uniContextInfo;
}
function injectLifecycleHook(name, hook, publicThis, instance2) {
if (isFunction(hook)) {
injectHook(name, hook.bind(publicThis), instance2);
}
}
function initHooks(options, instance2, publicThis) {
const mpType = options.mpType || publicThis.$mpType;
Object.keys(options).forEach((name) => {
if (name.indexOf("on") === 0) {
const hooks = options[name];
if (isArray(hooks)) {
hooks.forEach((hook) => injectLifecycleHook(name, hook, publicThis, instance2));
} else {
injectLifecycleHook(name, hooks, publicThis, instance2);
}
}
});
if (mpType === "page") {
instance2.__isVisible = true;
try {
invokeHook(publicThis, ON_LOAD, instance2.attrs.__pageQuery);
delete instance2.attrs.__pageQuery;
} catch (e2) {
console.error(e2.message + LINEFEED + e2.stack);
}
nextTick(() => {
invokeHook(publicThis, ON_SHOW);
});
}
}
function applyOptions(options, instance2, publicThis) {
initHooks(options, instance2, publicThis);
}
function set(target, key, val) {
return target[key] = val;
}
function errorHandler(err, instance2, info) {
if (!instance2) {
throw err;
}
const app = getApp();
if (!app || !app.$vm) {
throw err;
}
{
invokeHook(app.$vm, ON_ERROR, err);
}
}
function mergeAsArray(to, from) {
return to ? [...new Set([].concat(to, from))] : from;
}
function initOptionMergeStrategies(optionMergeStrategies) {
UniLifecycleHooks.forEach((name) => {
optionMergeStrategies[name] = mergeAsArray;
});
}
let realAtob;
const b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
if (typeof atob !== "function") {
realAtob = function(str) {
str = String(str).replace(/[\t\n\f\r ]+/g, "");
if (!b64re.test(str)) {
throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
}
str += "==".slice(2 - (str.length & 3));
var bitmap;
var result = "";
var r1;
var r2;
var i = 0;
for (; i < str.length; ) {
bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 | (r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) : String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
}
return result;
};
} else {
realAtob = atob;
}
function b64DecodeUnicode(str) {
return decodeURIComponent(realAtob(str).split("").map(function(c) {
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
}).join(""));
}
function getCurrentUserInfo() {
const token = uni.getStorageSync("uni_id_token") || "";
const tokenArr = token.split(".");
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0
};
}
let userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error("\u83B7\u53D6\u5F53\u524D\u7528\u6237\u4FE1\u606F\u51FA\u9519\uFF0C\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F\u4E3A\uFF1A" + error.message);
}
userInfo.tokenExpired = userInfo.exp * 1e3;
delete userInfo.exp;
delete userInfo.iat;
return userInfo;
}
function uniIdMixin(globalProperties) {
globalProperties.uniIDHasRole = function(roleId) {
const { role } = getCurrentUserInfo();
return role.indexOf(roleId) > -1;
};
globalProperties.uniIDHasPermission = function(permissionId) {
const { permission } = getCurrentUserInfo();
return this.uniIDHasRole("admin") || permission.indexOf(permissionId) > -1;
};
globalProperties.uniIDTokenValid = function() {
const { tokenExpired } = getCurrentUserInfo();
return tokenExpired > Date.now();
};
}
function initApp$1(app) {
const appConfig = app._context.config;
if (isFunction(app._component.onError)) {
appConfig.errorHandler = errorHandler;
}
initOptionMergeStrategies(appConfig.optionMergeStrategies);
const globalProperties = appConfig.globalProperties;
{
if (__UNI_FEATURE_UNI_CLOUD__) {
uniIdMixin(globalProperties);
}
}
{
globalProperties.$set = set;
globalProperties.$applyOptions = applyOptions;
}
{
invokeCreateVueAppHook(app);
}
}
const pageMetaKey = PolySymbol(process.env.NODE_ENV !== "production" ? "UniPageMeta" : "upm");
function usePageMeta() {
return inject(pageMetaKey);
......@@ -22015,4 +22004,4 @@ var index = /* @__PURE__ */ defineSystemComponent({
return openBlock(), createBlock("div", clazz, [loadingVNode]);
}
});
export { $emit, $off, $on, $once, index$8 as Ad, index$7 as AdContentPage, index$6 as AdDraw, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, index$y as Button, index$5 as Camera, index$w as Canvas, index$u as Checkbox, index$v as CheckboxGroup, index$a as CoverImage, index$b as CoverView, index$t as Editor, index$A as Form, index$s as Icon, index$r as Image, Input, index$z as Label, LayoutComponent, index$4 as LivePlayer, index$3 as LivePusher, Map$1 as Map, MovableArea, MovableView, index$q as Navigator, index$2 as PageComponent, index$9 as Picker, PickerView, PickerViewColumn, index$p as Progress, index$n as Radio, index$o as RadioGroup, ResizeSensor, index$m as RichText, ScrollView, index$l as Slider, Swiper, SwiperItem, index$k as Switch, index$j as Text, index$i as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$e as Video, index$h as View, index$d as WebView, addInterceptor, addPhoneContact, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closePreviewImage, closeSocket, connectSocket, createAnimation$1 as createAnimation, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createLivePlayerContext, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, downloadFile, getApp$1 as getApp, getClipboardData, getCurrentPages$1 as getCurrentPages, getEnterOptionsSync, getFileInfo, getImageInfo, getLaunchOptionsSync, getLeftWindowStyle, getLocale, getLocation, getNetworkType, getProvider, getPushCid, getRealPath, getRecorderManager, getRightWindowStyle, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange$1 as getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, interceptors, invokePushCallback, loadFontFace, login, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offPushMessage, offWindowResize, onAccelerometerChange, onCompassChange, onCreateVueApp, onGyroscopeChange, onLocaleChange, onMemoryWarning, onNetworkStatusChange, onPushMessage, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUserCaptureScreen, onWindowResize, openDocument, openLocation, pageScrollTo, index$f as plugin, preloadPage, previewImage, reLaunch, redirectTo, removeInterceptor, removeSavedFileInfo, removeStorage, removeStorageSync, removeTabBarBadge, request, saveFile, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, sendSocketMessage, setClipboardData, setKeepScreenOn, setLeftWindowStyle, setLocale, setNavigationBarColor, setNavigationBarTitle, setPageMeta, setRightWindowStyle, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, setupWindow, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startGyroscope, startPullDownRefresh, stopAccelerometer, stopCompass, stopGyroscope, stopPullDownRefresh, switchTab, uni$1 as uni, uploadFile, upx2px, useI18n, useTabBar, vibrateLong, vibrateShort };
export { $emit, $off, $on, $once, index$8 as Ad, index$7 as AdContentPage, index$6 as AdDraw, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, index$y as Button, index$5 as Camera, index$w as Canvas, index$u as Checkbox, index$v as CheckboxGroup, index$a as CoverImage, index$b as CoverView, index$t as Editor, index$A as Form, index$s as Icon, index$r as Image, Input, index$z as Label, LayoutComponent, index$4 as LivePlayer, index$3 as LivePusher, Map$1 as Map, MovableArea, MovableView, index$q as Navigator, index$2 as PageComponent, index$9 as Picker, PickerView, PickerViewColumn, index$p as Progress, index$n as Radio, index$o as RadioGroup, ResizeSensor, index$m as RichText, ScrollView, index$l as Slider, Swiper, SwiperItem, index$k as Switch, index$j as Text, index$i as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$e as Video, index$h as View, index$d as WebView, addInterceptor, addPhoneContact, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closePreviewImage, closeSocket, connectSocket, createAnimation$1 as createAnimation, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createLivePlayerContext, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, downloadFile, getApp$1 as getApp, getClipboardData, getCurrentPages$1 as getCurrentPages, getEnterOptionsSync, getFileInfo, getImageInfo, getLaunchOptionsSync, getLeftWindowStyle, getLocale, getLocation, getNetworkType, getProvider, getPushCid, getRealPath, getRecorderManager, getRightWindowStyle, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange$1 as getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, interceptors, invokePushCallback, loadFontFace, login, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offPushMessage, offWindowResize, onAccelerometerChange, onCompassChange, onGyroscopeChange, onLocaleChange, onMemoryWarning, onNetworkStatusChange, onPushMessage, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUserCaptureScreen, onWindowResize, openDocument, openLocation, pageScrollTo, index$f as plugin, preloadPage, previewImage, reLaunch, redirectTo, removeInterceptor, removeSavedFileInfo, removeStorage, removeStorageSync, removeTabBarBadge, request, saveFile, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, sendSocketMessage, setClipboardData, setKeepScreenOn, setLeftWindowStyle, setLocale, setNavigationBarColor, setNavigationBarTitle, setPageMeta, setRightWindowStyle, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, setupWindow, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startGyroscope, startPullDownRefresh, stopAccelerometer, stopCompass, stopGyroscope, stopPullDownRefresh, switchTab, uni$1 as uni, uploadFile, upx2px, useI18n, useTabBar, vibrateLong, vibrateShort };
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend } from '@vue/shared';
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const eventChannels = {};
const eventChannelStack = [];
let id = 0;
......@@ -661,24 +679,6 @@ const offPushMessage = (fn) => {
}
};
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const SYNC_API_RE = /^\$|getLocale|setLocale|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
// Context例外情况
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend } from '@vue/shared';
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const eventChannels = {};
const eventChannelStack = [];
let id = 0;
......@@ -661,24 +679,6 @@ const offPushMessage = (fn) => {
}
};
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const SYNC_API_RE = /^\$|getLocale|setLocale|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
// Context例外情况
......
......@@ -18,7 +18,7 @@ import {
offPushMessage,
invokePushCallback,
} from '@dcloudio/uni-api/src/service/plugin/push'
import { invokeCreateVueAppHook, onCreateVueApp } from '@dcloudio/uni-vue'
import { invokeCreateVueAppHook, onCreateVueApp } from '@dcloudio/uni-shared'
import { promisify } from './promise'
import { initWrapper } from './wrapper'
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend } from '@vue/shared';
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const eventChannels = {};
const eventChannelStack = [];
let id = 0;
......@@ -661,24 +679,6 @@ const offPushMessage = (fn) => {
}
};
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const SYNC_API_RE = /^\$|getLocale|setLocale|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
// Context例外情况
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend } from '@vue/shared';
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const eventChannels = {};
const eventChannelStack = [];
let id = 0;
......@@ -661,24 +679,6 @@ const offPushMessage = (fn) => {
}
};
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const SYNC_API_RE = /^\$|getLocale|setLocale|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
// Context例外情况
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend } from '@vue/shared';
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const eventChannels = {};
const eventChannelStack = [];
let id = 0;
......@@ -661,24 +679,6 @@ const offPushMessage = (fn) => {
}
};
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const SYNC_API_RE = /^\$|getLocale|setLocale|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
// Context例外情况
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend } from '@vue/shared';
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const eventChannels = {};
const eventChannelStack = [];
let id = 0;
......@@ -661,24 +679,6 @@ const offPushMessage = (fn) => {
}
};
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const SYNC_API_RE = /^\$|getLocale|setLocale|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
// Context例外情况
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend } from '@vue/shared';
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
function getBaseSystemInfo() {
return wx.getSystemInfoSync()
}
......@@ -625,24 +643,6 @@ const offPushMessage = (fn) => {
}
};
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const SYNC_API_RE = /^\$|getLocale|setLocale|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
// Context例外情况
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend } from '@vue/shared';
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const eventChannels = {};
const eventChannelStack = [];
let id = 0;
......@@ -661,24 +679,6 @@ const offPushMessage = (fn) => {
}
};
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const SYNC_API_RE = /^\$|getLocale|setLocale|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
// Context例外情况
......
......@@ -1294,6 +1294,24 @@ const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = /*#__PURE__*/ (() => {
};
})();
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const E = function () {
// Keep this empty so it's easier to inherit from
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
......@@ -1477,6 +1495,7 @@ exports.getLen = getLen;
exports.getValueByDataPath = getValueByDataPath;
exports.initCustomDatasetOnce = initCustomDatasetOnce;
exports.invokeArrayFns = invokeArrayFns;
exports.invokeCreateVueAppHook = invokeCreateVueAppHook;
exports.isAppNVueNativeTag = isAppNVueNativeTag;
exports.isAppNativeTag = isAppNativeTag;
exports.isBuiltInComponent = isBuiltInComponent;
......@@ -1489,6 +1508,7 @@ exports.isRootHook = isRootHook;
exports.normalizeDataset = normalizeDataset;
exports.normalizeEventType = normalizeEventType;
exports.normalizeTarget = normalizeTarget;
exports.onCreateVueApp = onCreateVueApp;
exports.once = once;
exports.parseEventName = parseEventName;
exports.parseQuery = parseQuery;
......
import type { App } from 'vue';
import type { ComponentInternalInstance } from '@vue/runtime-core';
import { ComponentOptionsBase } from '@vue/runtime-core';
import type { ComponentPublicInstance } from '@vue/runtime-core';
......@@ -122,6 +123,8 @@ export declare function createRpx2Unit(unit: string, unitRatio: number, unitPrec
export declare function createUniEvent(evt: Record<string, any>): UniEvent;
declare type CreateVueAppHook = (app: App) => void;
export declare function customizeEvent(str: string): string;
export declare const DATA_RE: RegExp;
......@@ -242,6 +245,8 @@ export declare type InsertAction = [typeof ACTION_TYPE_INSERT, number, number, n
export declare const invokeArrayFns: (fns: Function[], arg?: any) => any;
export declare function invokeCreateVueAppHook(app: App): void;
export declare function isAppNativeTag(tag: string): boolean;
export declare function isAppNVueNativeTag(tag: string): boolean;
......@@ -476,6 +481,12 @@ export declare const ON_WXS_INVOKE_CALL_METHOD = "onWxsInvokeCallMethod";
export declare function once<T extends (...args: any[]) => any>(fn: T, ctx?: unknown): T;
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
export declare function onCreateVueApp(hook: CreateVueAppHook): void;
declare interface Options {
success?: (res: any) => void;
fail?: (res: any) => void;
......
......@@ -1290,6 +1290,24 @@ const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = /*#__PURE__*/ (() => {
};
})();
let vueApp;
const createVueAppHooks = [];
/**
* 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
* @param hook
*/
function onCreateVueApp(hook) {
// TODO 每个 nvue 页面都会触发
if (vueApp) {
return hook(vueApp);
}
createVueAppHooks.push(hook);
}
function invokeCreateVueAppHook(app) {
vueApp = app;
createVueAppHooks.forEach((hook) => hook(app));
}
const E = function () {
// Keep this empty so it's easier to inherit from
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
......@@ -1347,4 +1365,4 @@ function getEnvLocale() {
return (lang && lang.replace(/[.:].*/, '')) || 'en';
}
export { ACTION_TYPE_ADD_EVENT, ACTION_TYPE_ADD_WXS_EVENT, ACTION_TYPE_CREATE, ACTION_TYPE_EVENT, ACTION_TYPE_INSERT, ACTION_TYPE_PAGE_CREATE, ACTION_TYPE_PAGE_CREATED, ACTION_TYPE_PAGE_SCROLL, ACTION_TYPE_REMOVE, ACTION_TYPE_REMOVE_ATTRIBUTE, ACTION_TYPE_REMOVE_EVENT, ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_SET_TEXT, ATTR_CHANGE_PREFIX, ATTR_CLASS, ATTR_INNER_HTML, ATTR_STYLE, ATTR_TEXT_CONTENT, ATTR_V_OWNER_ID, ATTR_V_RENDERJS, ATTR_V_SHOW, BACKGROUND_COLOR, BUILT_IN_TAGS, BUILT_IN_TAG_NAMES, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, DATA_RE, E$1 as Emitter, EventChannel, EventModifierFlags, I18N_JSON_DELIMITERS, JSON_PROTOCOL, LINEFEED, MINI_PROGRAM_PAGE_RUNTIME_HOOKS, NAVBAR_HEIGHT, NODE_TYPE_COMMENT, NODE_TYPE_ELEMENT, NODE_TYPE_PAGE, NODE_TYPE_TEXT, NVUE_BUILT_IN_TAGS, NVUE_U_BUILT_IN_TAGS, ON_ADD_TO_FAVORITES, ON_APP_ENTER_BACKGROUND, ON_APP_ENTER_FOREGROUND, ON_BACK_PRESS, ON_ERROR, ON_HIDE, ON_KEYBOARD_HEIGHT_CHANGE, ON_LAUNCH, ON_LOAD, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_PAGE_NOT_FOUND, ON_PAGE_SCROLL, ON_PULL_DOWN_REFRESH, ON_REACH_BOTTOM, ON_REACH_BOTTOM_DISTANCE, ON_READY, ON_RESIZE, ON_SHARE_APP_MESSAGE, ON_SHARE_TIMELINE, ON_SHOW, ON_TAB_ITEM_TAP, ON_THEME_CHANGE, ON_UNHANDLE_REJECTION, ON_UNLOAD, ON_WEB_INVOKE_APP_SERVICE, ON_WXS_INVOKE_CALL_METHOD, PLUS_RE, PRIMARY_COLOR, RENDERJS_MODULES, RESPONSIVE_MIN_WIDTH, SCHEME_RE, SELECTED_COLOR, SLOT_DEFAULT_NAME, TABBAR_HEIGHT, TAGS, UNI_SSR, UNI_SSR_DATA, UNI_SSR_GLOBAL_DATA, UNI_SSR_STORE, UNI_SSR_TITLE, UNI_STORAGE_LOCALE, UniBaseNode, UniCommentNode, UniElement, UniEvent, UniInputElement, UniLifecycleHooks, UniNode, UniTextAreaElement, UniTextNode, WEB_INVOKE_APPSERVICE, WXS_MODULES, WXS_PROTOCOL, addFont, addLeadingSlash, cache, cacheStringFunction, callOptions, createIsCustomElement, createRpx2Unit, createUniEvent, customizeEvent, debounce, decode, decodedQuery, defaultMiniProgramRpx2Unit, defaultNVueRpx2Unit, defaultRpx2Unit, dynamicSlotName, forcePatchProp, formatAppLog, formatDateTime, formatH5Log, formatLog, getCustomDataset, getEnvLocale, getLen, getValueByDataPath, initCustomDatasetOnce, invokeArrayFns, isAppNVueNativeTag, isAppNativeTag, isBuiltInComponent, isComponentInternalInstance, isComponentTag, isH5CustomElement, isH5NativeTag, isMiniProgramNativeTag, isRootHook, normalizeDataset, normalizeEventType, normalizeTarget, once, parseEventName, parseQuery, parseUrl, passive, plusReady, removeLeadingSlash, resolveComponentInstance, resolveOwnerEl, resolveOwnerVm, sanitise, scrollTo, stringifyQuery, updateElementStyle };
export { ACTION_TYPE_ADD_EVENT, ACTION_TYPE_ADD_WXS_EVENT, ACTION_TYPE_CREATE, ACTION_TYPE_EVENT, ACTION_TYPE_INSERT, ACTION_TYPE_PAGE_CREATE, ACTION_TYPE_PAGE_CREATED, ACTION_TYPE_PAGE_SCROLL, ACTION_TYPE_REMOVE, ACTION_TYPE_REMOVE_ATTRIBUTE, ACTION_TYPE_REMOVE_EVENT, ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_SET_TEXT, ATTR_CHANGE_PREFIX, ATTR_CLASS, ATTR_INNER_HTML, ATTR_STYLE, ATTR_TEXT_CONTENT, ATTR_V_OWNER_ID, ATTR_V_RENDERJS, ATTR_V_SHOW, BACKGROUND_COLOR, BUILT_IN_TAGS, BUILT_IN_TAG_NAMES, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, DATA_RE, E$1 as Emitter, EventChannel, EventModifierFlags, I18N_JSON_DELIMITERS, JSON_PROTOCOL, LINEFEED, MINI_PROGRAM_PAGE_RUNTIME_HOOKS, NAVBAR_HEIGHT, NODE_TYPE_COMMENT, NODE_TYPE_ELEMENT, NODE_TYPE_PAGE, NODE_TYPE_TEXT, NVUE_BUILT_IN_TAGS, NVUE_U_BUILT_IN_TAGS, ON_ADD_TO_FAVORITES, ON_APP_ENTER_BACKGROUND, ON_APP_ENTER_FOREGROUND, ON_BACK_PRESS, ON_ERROR, ON_HIDE, ON_KEYBOARD_HEIGHT_CHANGE, ON_LAUNCH, ON_LOAD, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_PAGE_NOT_FOUND, ON_PAGE_SCROLL, ON_PULL_DOWN_REFRESH, ON_REACH_BOTTOM, ON_REACH_BOTTOM_DISTANCE, ON_READY, ON_RESIZE, ON_SHARE_APP_MESSAGE, ON_SHARE_TIMELINE, ON_SHOW, ON_TAB_ITEM_TAP, ON_THEME_CHANGE, ON_UNHANDLE_REJECTION, ON_UNLOAD, ON_WEB_INVOKE_APP_SERVICE, ON_WXS_INVOKE_CALL_METHOD, PLUS_RE, PRIMARY_COLOR, RENDERJS_MODULES, RESPONSIVE_MIN_WIDTH, SCHEME_RE, SELECTED_COLOR, SLOT_DEFAULT_NAME, TABBAR_HEIGHT, TAGS, UNI_SSR, UNI_SSR_DATA, UNI_SSR_GLOBAL_DATA, UNI_SSR_STORE, UNI_SSR_TITLE, UNI_STORAGE_LOCALE, UniBaseNode, UniCommentNode, UniElement, UniEvent, UniInputElement, UniLifecycleHooks, UniNode, UniTextAreaElement, UniTextNode, WEB_INVOKE_APPSERVICE, WXS_MODULES, WXS_PROTOCOL, addFont, addLeadingSlash, cache, cacheStringFunction, callOptions, createIsCustomElement, createRpx2Unit, createUniEvent, customizeEvent, debounce, decode, decodedQuery, defaultMiniProgramRpx2Unit, defaultNVueRpx2Unit, defaultRpx2Unit, dynamicSlotName, forcePatchProp, formatAppLog, formatDateTime, formatH5Log, formatLog, getCustomDataset, getEnvLocale, getLen, getValueByDataPath, initCustomDatasetOnce, invokeArrayFns, invokeCreateVueAppHook, isAppNVueNativeTag, isAppNativeTag, isBuiltInComponent, isComponentInternalInstance, isComponentTag, isH5CustomElement, isH5NativeTag, isMiniProgramNativeTag, isRootHook, normalizeDataset, normalizeEventType, normalizeTarget, onCreateVueApp, once, parseEventName, parseQuery, parseUrl, passive, plusReady, removeLeadingSlash, resolveComponentInstance, resolveOwnerEl, resolveOwnerVm, sanitise, scrollTo, stringifyQuery, updateElementStyle };
......@@ -13,6 +13,7 @@ export * from './debounce'
export * from './constants'
export * from './EventChannel'
export * from './lifecycle'
export * from './onCreateVueApp'
export { default as Emitter } from './TinyEmitter'
export * from './node/locale'
import { App } from 'vue'
import { isFunction } from '@vue/shared'
import { invokeCreateVueAppHook } from '@dcloudio/uni-shared'
import { applyOptions } from './componentOptions'
import { set } from './componentInstance'
import { errorHandler, initOptionMergeStrategies } from './appConfig'
import { uniIdMixin } from './uni-id-mixin'
import { invokeCreateVueAppHook } from './onCreateVueApp'
export { onCreateVueApp, invokeCreateVueAppHook } from './onCreateVueApp'
export function initApp(app: App) {
const appConfig = app._context.config
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册