Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
1e233109
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
725
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1e233109
编写于
2月 23, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: app lifecycle
上级
6f15a5a1
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
344 addition
and
162 deletion
+344
-162
packages/uni-api/src/service/base/interceptor.ts
packages/uni-api/src/service/base/interceptor.ts
+6
-17
packages/uni-api/src/service/lifecycle/app.ts
packages/uni-api/src/service/lifecycle/app.ts
+67
-10
packages/uni-app-plus/dist/uni-app-service.es.js
packages/uni-app-plus/dist/uni-app-service.es.js
+87
-12
packages/uni-app-plus/src/service/api/index.ts
packages/uni-app-plus/src/service/api/index.ts
+10
-0
packages/uni-app-plus/src/service/framework/app/initAppLaunch.ts
...s/uni-app-plus/src/service/framework/app/initAppLaunch.ts
+2
-0
packages/uni-core/src/helpers/hook.ts
packages/uni-core/src/helpers/hook.ts
+15
-1
packages/uni-h5-vite/lib/api.json
packages/uni-h5-vite/lib/api.json
+10
-0
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+87
-18
packages/uni-h5/src/framework/setup/index.ts
packages/uni-h5/src/framework/setup/index.ts
+2
-0
packages/uni-h5/src/service/api/index.ts
packages/uni-h5/src/service/api/index.ts
+10
-0
packages/uni-mp-alipay/dist/uni.api.esm.js
packages/uni-mp-alipay/dist/uni.api.esm.js
+6
-13
packages/uni-mp-baidu/dist/uni.api.esm.js
packages/uni-mp-baidu/dist/uni.api.esm.js
+6
-13
packages/uni-mp-kuaishou/dist/uni.api.esm.js
packages/uni-mp-kuaishou/dist/uni.api.esm.js
+6
-13
packages/uni-mp-lark/dist/uni.api.esm.js
packages/uni-mp-lark/dist/uni.api.esm.js
+6
-13
packages/uni-mp-qq/dist/uni.api.esm.js
packages/uni-mp-qq/dist/uni.api.esm.js
+6
-13
packages/uni-mp-toutiao/dist/uni.api.esm.js
packages/uni-mp-toutiao/dist/uni.api.esm.js
+6
-13
packages/uni-mp-weixin/dist/uni.api.esm.js
packages/uni-mp-weixin/dist/uni.api.esm.js
+6
-13
packages/uni-quickapp-webview/dist/uni.api.esm.js
packages/uni-quickapp-webview/dist/uni.api.esm.js
+6
-13
未找到文件。
packages/uni-api/src/service/base/interceptor.ts
浏览文件 @
1e233109
import
{
isArray
,
isFunction
,
isPlainObject
}
from
'
@vue/shared
'
import
{
isArray
,
isFunction
,
isPlainObject
,
remove
}
from
'
@vue/shared
'
import
{
HOOKS
,
...
...
@@ -38,12 +38,11 @@ function removeInterceptorHook(
if
(
!
interceptors
||
!
interceptor
)
{
return
}
Object
.
keys
(
interceptor
).
forEach
((
hook
)
=>
{
if
(
isFunction
(
interceptor
[
hook
as
HOOKS
]))
{
removeHook
(
interceptors
[
hook
as
HOOKS
],
interceptor
[
hook
as
HOOKS
]
as
Function
)
Object
.
keys
(
interceptor
).
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
as
HOOKS
]
const
hook
=
interceptor
[
name
as
HOOKS
]
if
(
isArray
(
hooks
)
&&
isFunction
(
hook
))
{
remove
(
hooks
,
hook
)
}
})
}
...
...
@@ -72,16 +71,6 @@ function dedupeHooks(hooks: Function[]) {
return
res
}
function
removeHook
(
hooks
:
Function
[]
|
undefined
,
hook
:
Function
)
{
if
(
!
hooks
)
{
return
}
const
index
=
hooks
.
indexOf
(
hook
)
if
(
index
!==
-
1
)
{
hooks
.
splice
(
index
,
1
)
}
}
export
const
addInterceptor
=
defineSyncApi
(
API_ADD_INTERCEPTOR
,
(
method
:
string
|
Interceptor
,
interceptor
:
Interceptor
|
undefined
)
=>
{
...
...
packages/uni-api/src/service/lifecycle/app.ts
浏览文件 @
1e233109
import
{
getEnterOptions
,
getLaunchOptions
}
from
'
@dcloudio/uni-platform
'
import
{
ON_HIDE
,
ON_SHOW
}
from
'
@dcloudio/uni-shared
'
import
{
defineSyncApi
}
from
'
../../helpers/api
'
import
{
ON_ERROR
,
ON_HIDE
,
ON_PAGE_NOT_FOUND
,
ON_SHOW
,
ON_UNHANDLE_REJECTION
,
}
from
'
@dcloudio/uni-shared
'
import
{
ComponentInternalInstance
,
injectHook
}
from
'
vue
'
import
{
removeHook
}
from
'
@dcloudio/uni-core
'
import
{
remove
}
from
'
@vue/shared
'
import
{
defineSyncApi
}
from
'
../../helpers/api
'
type
AppShowHook
=
(
options
:
UniApp
.
LaunchOptionsApp
)
=>
void
type
AppHideHook
=
()
=>
void
interface
AppHooks
{
onUnhandledRejection
:
UniApp
.
OnUnhandledRejectionCallback
[]
onPageNotFound
:
UniApp
.
OnPageNotFoundCallback
[]
onError
:
UniApp
.
OnAppErrorCallback
[]
onShow
:
AppShowHook
[]
onHide
:
AppHideHook
[]
}
const
appHooks
:
AppHooks
=
{
[
ON_UNHANDLE_REJECTION
]:
[],
[
ON_PAGE_NOT_FOUND
]:
[],
[
ON_ERROR
]:
[],
[
ON_SHOW
]:
[],
[
ON_HIDE
]:
[],
}
...
...
@@ -24,21 +38,64 @@ function onAppHook(type: keyof AppHooks, hook: (...args: any[]) => void) {
appHooks
[
type
].
push
(
hook
)
}
export
function
injectAppHooks
(
appInstance
:
ComponentInternalInstance
)
{
Object
.
keys
(
appHooks
).
forEach
((
type
)
=>
{
appHooks
[
type
as
keyof
AppHooks
].
forEach
((
hook
)
=>
{
injectHook
(
type
,
hook
,
appInstance
)
})
})
}
function
offAppHook
(
type
:
keyof
AppHooks
,
hook
:
(...
args
:
any
[])
=>
void
)
{
const
app
=
getApp
({
allowDefault
:
true
})
if
(
app
&&
app
.
$vm
)
{
return
removeHook
(
app
.
$vm
,
type
,
hook
)
}
remove
(
appHooks
[
type
]
as
Function
[],
hook
)
}
export
function
onUnhandledRejection
(
hook
:
UniApp
.
OnUnhandledRejectionCallback
)
{
onAppHook
(
ON_UNHANDLE_REJECTION
,
hook
)
}
export
function
offUnhandledRejection
(
hook
:
UniApp
.
OnUnhandledRejectionCallback
)
{
offAppHook
(
ON_UNHANDLE_REJECTION
,
hook
)
}
export
function
onPageNotFound
(
hook
:
UniApp
.
OnPageNotFoundCallback
)
{
onAppHook
(
ON_PAGE_NOT_FOUND
,
hook
)
}
export
function
offPageNotFound
(
hook
:
UniApp
.
OnPageNotFoundCallback
)
{
offAppHook
(
ON_PAGE_NOT_FOUND
,
hook
)
}
export
function
onError
(
hook
:
UniApp
.
OnAppErrorCallback
)
{
onAppHook
(
ON_ERROR
,
hook
)
}
export
function
offError
(
hook
:
UniApp
.
OnAppErrorCallback
)
{
offAppHook
(
ON_ERROR
,
hook
)
}
export
function
onAppShow
(
hook
:
AppShowHook
)
{
onAppHook
(
ON_SHOW
,
hook
)
}
export
function
offAppShow
(
hook
:
AppShowHook
)
{
offAppHook
(
ON_SHOW
,
hook
)
}
export
function
onAppHide
(
hook
:
AppHideHook
)
{
onAppHook
(
ON_HIDE
,
hook
)
}
export
function
injectAppHooks
(
type
:
keyof
AppHooks
,
appInstance
:
ComponentInternalInstance
)
{
appHooks
[
type
].
forEach
((
hook
)
=>
{
injectHook
(
type
,
hook
,
appInstance
)
})
export
function
offAppHide
(
hook
:
AppHideHook
)
{
offAppHook
(
ON_HIDE
,
hook
)
}
type
API_TYPE_GET_ENTER_OPTIONS_SYNC
=
typeof
uni
.
getLaunchOptionsSync
...
...
packages/uni-app-plus/dist/uni-app-service.es.js
浏览文件 @
1e233109
...
...
@@ -106,6 +106,12 @@ var serviceContext = (function (vue) {
: {};
(process.env.NODE_ENV !== 'production') ? Object.freeze([]) : [];
const extend = Object.assign;
const remove = (arr, el) => {
const i = arr.indexOf(el);
if (i > -1) {
arr.splice(i, 1);
}
};
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
const hasOwn$1 = (val, key) => hasOwnProperty$1.call(val, key);
const isArray$1 = Array.isArray;
...
...
@@ -2172,6 +2178,13 @@ var serviceContext = (function (vue) {
};
}
function removeHook(vm, name, hook) {
const hooks = vm.$[name];
if (!isArray$1(hooks)) {
return;
}
remove(hooks, hook);
}
function invokeHook(vm, name, args) {
if (isString(vm)) {
args = name;
...
...
@@ -9863,9 +9876,11 @@ var serviceContext = (function (vue) {
if (!interceptors || !interceptor) {
return;
}
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook])) {
removeHook(interceptors[hook], interceptor[hook]);
Object.keys(interceptor).forEach((name) => {
const hooks = interceptors[name];
const hook = interceptor[name];
if (isArray$1(hooks) && isFunction(hook)) {
remove(hooks, hook);
}
});
}
...
...
@@ -9888,15 +9903,6 @@ var serviceContext = (function (vue) {
}
return res;
}
function removeHook(hooks, hook) {
if (!hooks) {
return;
}
const index = hooks.indexOf(hook);
if (index !== -1) {
hooks.splice(index, 1);
}
}
const addInterceptor = defineSyncApi(API_ADD_INTERCEPTOR, (method, interceptor) => {
if (typeof method === 'string' && isPlainObject(interceptor)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
...
...
@@ -11652,6 +11658,64 @@ var serviceContext = (function (vue) {
});
});
const appHooks = {
[ON_UNHANDLE_REJECTION]: [],
[ON_PAGE_NOT_FOUND]: [],
[ON_ERROR]: [],
[ON_SHOW]: [],
[ON_HIDE]: [],
};
function onAppHook(type, hook) {
const app = getApp({ allowDefault: true });
if (app && app.$vm) {
return vue.injectHook(type, hook, app.$vm.$);
}
appHooks[type].push(hook);
}
function injectAppHooks(appInstance) {
Object.keys(appHooks).forEach((type) => {
appHooks[type].forEach((hook) => {
vue.injectHook(type, hook, appInstance);
});
});
}
function offAppHook(type, hook) {
const app = getApp({ allowDefault: true });
if (app && app.$vm) {
return removeHook(app.$vm, type, hook);
}
remove(appHooks[type], hook);
}
function onUnhandledRejection(hook) {
onAppHook(ON_UNHANDLE_REJECTION, hook);
}
function offUnhandledRejection(hook) {
offAppHook(ON_UNHANDLE_REJECTION, hook);
}
function onPageNotFound(hook) {
onAppHook(ON_PAGE_NOT_FOUND, hook);
}
function offPageNotFound(hook) {
offAppHook(ON_PAGE_NOT_FOUND, hook);
}
function onError(hook) {
onAppHook(ON_ERROR, hook);
}
function offError(hook) {
offAppHook(ON_ERROR, hook);
}
function onAppShow(hook) {
onAppHook(ON_SHOW, hook);
}
function offAppShow(hook) {
offAppHook(ON_SHOW, hook);
}
function onAppHide(hook) {
onAppHook(ON_HIDE, hook);
}
function offAppHide(hook) {
offAppHook(ON_HIDE, hook);
}
const API_GET_ENTER_OPTIONS_SYNC = 'getEnterOptionsSync';
const getEnterOptionsSync = defineSyncApi(API_GET_ENTER_OPTIONS_SYNC, () => {
return getEnterOptions();
...
...
@@ -17527,6 +17591,7 @@ var serviceContext = (function (vue) {
// }
function initAppLaunch(appVm) {
injectAppHooks(appVm.$);
const { entryPagePath, entryPageQuery, referrerInfo } = __uniConfig;
const args = initLaunchOptions({
path: entryPagePath,
...
...
@@ -19958,6 +20023,16 @@ var serviceContext = (function (vue) {
getPushCid: getPushCid,
onPushMessage: onPushMessage,
offPushMessage: offPushMessage,
onAppHide: onAppHide,
onAppShow: onAppShow,
onError: onError,
onPageNotFound: onPageNotFound,
onUnhandledRejection: onUnhandledRejection,
offAppHide: offAppHide,
offAppShow: offAppShow,
offError: offError,
offPageNotFound: offPageNotFound,
offUnhandledRejection: offUnhandledRejection,
invokePushCallback: invokePushCallback,
setStorageSync: setStorageSync,
setStorage: setStorage,
...
...
packages/uni-app-plus/src/service/api/index.ts
浏览文件 @
1e233109
...
...
@@ -118,6 +118,16 @@ export {
getPushCid
,
onPushMessage
,
offPushMessage
,
onAppHide
,
onAppShow
,
onError
,
onPageNotFound
,
onUnhandledRejection
,
offAppHide
,
offAppShow
,
offError
,
offPageNotFound
,
offUnhandledRejection
,
// 内部使用
invokePushCallback
,
}
from
'
@dcloudio/uni-api
'
packages/uni-app-plus/src/service/framework/app/initAppLaunch.ts
浏览文件 @
1e233109
import
{
invokeHook
}
from
'
@dcloudio/uni-core
'
import
{
injectAppHooks
}
from
'
@dcloudio/uni-api
'
import
{
ON_LAUNCH
,
ON_SHOW
,
ON_HIDE
}
from
'
@dcloudio/uni-shared
'
import
{
ComponentPublicInstance
}
from
'
vue
'
import
{
initLaunchOptions
}
from
'
./utils
'
export
function
initAppLaunch
(
appVm
:
ComponentPublicInstance
)
{
injectAppHooks
(
appVm
.
$
)
const
{
entryPagePath
,
entryPageQuery
,
referrerInfo
}
=
__uniConfig
const
args
=
initLaunchOptions
({
path
:
entryPagePath
,
...
...
packages/uni-core/src/helpers/hook.ts
浏览文件 @
1e233109
import
{
ComponentPublicInstance
}
from
'
vue
'
import
{
isString
}
from
'
@vue/shared
'
import
{
isString
,
isArray
,
remove
}
from
'
@vue/shared
'
import
{
invokeArrayFns
}
from
'
@dcloudio/uni-shared
'
import
{
getCurrentPageVm
}
from
'
./page
'
export
function
removeHook
(
vm
:
ComponentPublicInstance
,
name
:
string
,
hook
:
Function
)
{
const
hooks
=
(
vm
.
$
as
unknown
as
{
[
name
:
string
]:
Function
[]
})[
name
as
string
]
if
(
!
isArray
(
hooks
))
{
return
}
remove
(
hooks
,
hook
)
}
export
function
invokeHook
(
name
:
string
,
args
?:
unknown
):
unknown
export
function
invokeHook
(
id
:
number
,
name
:
string
,
args
?:
unknown
):
unknown
export
function
invokeHook
(
...
...
packages/uni-h5-vite/lib/api.json
浏览文件 @
1e233109
...
...
@@ -75,22 +75,32 @@
"navigateBack"
,
"navigateTo"
,
"offAccelerometerChange"
,
"offAppHide"
,
"offAppShow"
,
"offCompassChange"
,
"offError"
,
"offNetworkStatusChange"
,
"offPageNotFound"
,
"offPushMessage"
,
"offUnhandledRejection"
,
"offWindowResize"
,
"onAccelerometerChange"
,
"onAppHide"
,
"onAppShow"
,
"onCompassChange"
,
"onError"
,
"onGyroscopeChange"
,
"onLocaleChange"
,
"onMemoryWarning"
,
"onNetworkStatusChange"
,
"onPageNotFound"
,
"onPushMessage"
,
"onSocketClose"
,
"onSocketError"
,
"onSocketMessage"
,
"onSocketOpen"
,
"onTabBarMidButtonTap"
,
"onUnhandledRejection"
,
"onUserCaptureScreen"
,
"onWindowResize"
,
"openDocument"
,
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
1e233109
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, 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";
import { withModifiers, createVNode, getCurrentInstance, ref, defineComponent, openBlock, createElementBlock, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, mergeProps,
injectHook, reactive, onActivated, onMounted, nextTick, 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 { isString, extend,
isArray, remove, stringifyStyle, parseStringStyle, isPlainObject, isFunction, capitalize, camelize
, 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,
ON_UNHANDLE_REJECTION, ON_PAGE_NOT_FOUND,
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";
...
...
@@ -887,6 +887,13 @@ function initPageInternalInstance(openType, url, pageQuery, meta, eventChannel)
statusBarStyle: meta.navigationBar.titleColor === "#000000" ? "dark" : "light"
};
}
function removeHook(vm, name, hook) {
const hooks = vm.$[name];
if (!isArray(hooks)) {
return;
}
remove(hooks, hook);
}
function invokeHook(vm, name, args) {
if (isString(vm)) {
args = name;
...
...
@@ -2843,9 +2850,11 @@ function removeInterceptorHook(interceptors2, interceptor) {
if (!interceptors2 || !interceptor) {
return;
}
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook])) {
removeHook(interceptors2[hook], interceptor[hook]);
Object.keys(interceptor).forEach((name) => {
const hooks = interceptors2[name];
const hook = interceptor[name];
if (isArray(hooks) && isFunction(hook)) {
remove(hooks, hook);
}
});
}
...
...
@@ -2862,15 +2871,6 @@ function dedupeHooks(hooks) {
}
return res;
}
function removeHook(hooks, hook) {
if (!hooks) {
return;
}
const index2 = hooks.indexOf(hook);
if (index2 !== -1) {
hooks.splice(index2, 1);
}
}
const addInterceptor = /* @__PURE__ */ defineSyncApi(API_ADD_INTERCEPTOR, (method, interceptor) => {
if (typeof method === "string" && isPlainObject(interceptor)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
...
...
@@ -4473,6 +4473,64 @@ const getSelectedTextRange$1 = /* @__PURE__ */ defineAsyncApi(API_GET_SELECTED_T
}
});
});
const appHooks = {
[ON_UNHANDLE_REJECTION]: [],
[ON_PAGE_NOT_FOUND]: [],
[ON_ERROR]: [],
[ON_SHOW]: [],
[ON_HIDE]: []
};
function onAppHook(type, hook) {
const app = getApp({ allowDefault: true });
if (app && app.$vm) {
return injectHook(type, hook, app.$vm.$);
}
appHooks[type].push(hook);
}
function injectAppHooks(appInstance) {
Object.keys(appHooks).forEach((type) => {
appHooks[type].forEach((hook) => {
injectHook(type, hook, appInstance);
});
});
}
function offAppHook(type, hook) {
const app = getApp({ allowDefault: true });
if (app && app.$vm) {
return removeHook(app.$vm, type, hook);
}
remove(appHooks[type], hook);
}
function onUnhandledRejection(hook) {
onAppHook(ON_UNHANDLE_REJECTION, hook);
}
function offUnhandledRejection(hook) {
offAppHook(ON_UNHANDLE_REJECTION, hook);
}
function onPageNotFound(hook) {
onAppHook(ON_PAGE_NOT_FOUND, hook);
}
function offPageNotFound(hook) {
offAppHook(ON_PAGE_NOT_FOUND, hook);
}
function onError(hook) {
onAppHook(ON_ERROR, hook);
}
function offError(hook) {
offAppHook(ON_ERROR, hook);
}
function onAppShow(hook) {
onAppHook(ON_SHOW, hook);
}
function offAppShow(hook) {
offAppHook(ON_SHOW, hook);
}
function onAppHide(hook) {
onAppHook(ON_HIDE, hook);
}
function offAppHide(hook) {
offAppHook(ON_HIDE, hook);
}
const API_GET_ENTER_OPTIONS_SYNC = "getEnterOptionsSync";
const getEnterOptionsSync = /* @__PURE__ */ defineSyncApi(API_GET_ENTER_OPTIONS_SYNC, () => {
return getEnterOptions();
...
...
@@ -14130,7 +14188,8 @@ function setupApp(comp) {
setup(instance2) {
const route = usePageRoute();
const onLaunch = () => {
const { onLaunch: onLaunch2, onShow, onPageNotFound } = instance2;
injectAppHooks(instance2);
const { onLaunch: onLaunch2, onShow, onPageNotFound: onPageNotFound2 } = instance2;
const path = route.path.slice(1);
const launchOptions2 = initLaunchOptions({
path: path || __uniRoutes[0].meta.route,
...
...
@@ -14147,7 +14206,7 @@ function setupApp(comp) {
query: {},
scene: 1001
};
onPageNotFound
&& invokeArrayFns$1(onPageNotFound
, pageNotFoundOptions);
onPageNotFound
2 && invokeArrayFns$1(onPageNotFound2
, pageNotFoundOptions);
}
}
};
...
...
@@ -19842,6 +19901,16 @@ var api = {
getPushCid,
onPushMessage,
offPushMessage,
onAppHide,
onAppShow,
onError,
onPageNotFound,
onUnhandledRejection,
offAppHide,
offAppShow,
offError,
offPageNotFound,
offUnhandledRejection,
invokePushCallback,
cssVar,
cssEnv,
...
...
@@ -22004,4 +22073,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, off
CompassChange, 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 };
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, off
AppHide, offAppShow, offCompassChange, offError, offNetworkStatusChange, offPageNotFound, offPushMessage, offUnhandledRejection, offWindowResize, onAccelerometerChange, onAppHide, onAppShow, onCompassChange, onError, onGyroscopeChange, onLocaleChange, onMemoryWarning, onNetworkStatusChange, onPageNotFound, onPushMessage, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUnhandledRejection
, 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 };
packages/uni-h5/src/framework/setup/index.ts
浏览文件 @
1e233109
...
...
@@ -22,6 +22,7 @@ import {
ON_WEB_INVOKE_APP_SERVICE
,
WEB_INVOKE_APPSERVICE
,
}
from
'
@dcloudio/uni-shared
'
import
{
injectAppHooks
}
from
'
@dcloudio/uni-api
'
import
{
subscribeViewMethod
,
unsubscribeViewMethod
}
from
'
@dcloudio/uni-core
'
import
{
LayoutComponent
}
from
'
../..
'
import
{
initApp
}
from
'
./app
'
...
...
@@ -139,6 +140,7 @@ export function setupApp(comp: any) {
return
route
.
query
}
const
onLaunch
=
()
=>
{
injectAppHooks
(
instance
)
const
{
onLaunch
,
onShow
,
onPageNotFound
}
=
instance
const
path
=
route
.
path
.
slice
(
1
)
const
launchOptions
=
initLaunchOptions
({
...
...
packages/uni-h5/src/service/api/index.ts
浏览文件 @
1e233109
...
...
@@ -100,6 +100,16 @@ export {
getPushCid
,
onPushMessage
,
offPushMessage
,
onAppHide
,
onAppShow
,
onError
,
onPageNotFound
,
onUnhandledRejection
,
offAppHide
,
offAppShow
,
offError
,
offPageNotFound
,
offUnhandledRejection
,
// 内部使用
invokePushCallback
,
}
from
'
@dcloudio/uni-api
'
...
...
packages/uni-mp-alipay/dist/uni.api.esm.js
浏览文件 @
1e233109
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
extend
}
from
'
@vue/shared
'
;
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
remove
,
extend
}
from
'
@vue/shared
'
;
let
vueApp
;
const
createVueAppHooks
=
[];
...
...
@@ -499,9 +499,11 @@ function removeInterceptorHook(interceptors, interceptor) {
if
(
!
interceptors
||
!
interceptor
)
{
return
;
}
Object
.
keys
(
interceptor
).
forEach
((
hook
)
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
removeHook
(
interceptors
[
hook
],
interceptor
[
hook
]);
Object
.
keys
(
interceptor
).
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
];
const
hook
=
interceptor
[
name
];
if
(
isArray
(
hooks
)
&&
isFunction
(
hook
))
{
remove
(
hooks
,
hook
);
}
});
}
...
...
@@ -524,15 +526,6 @@ function dedupeHooks(hooks) {
}
return
res
;
}
function
removeHook
(
hooks
,
hook
)
{
if
(
!
hooks
)
{
return
;
}
const
index
=
hooks
.
indexOf
(
hook
);
if
(
index
!==
-
1
)
{
hooks
.
splice
(
index
,
1
);
}
}
const
addInterceptor
=
defineSyncApi
(
API_ADD_INTERCEPTOR
,
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
...
...
packages/uni-mp-baidu/dist/uni.api.esm.js
浏览文件 @
1e233109
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
extend
}
from
'
@vue/shared
'
;
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
remove
,
extend
}
from
'
@vue/shared
'
;
let
vueApp
;
const
createVueAppHooks
=
[];
...
...
@@ -499,9 +499,11 @@ function removeInterceptorHook(interceptors, interceptor) {
if
(
!
interceptors
||
!
interceptor
)
{
return
;
}
Object
.
keys
(
interceptor
).
forEach
((
hook
)
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
removeHook
(
interceptors
[
hook
],
interceptor
[
hook
]);
Object
.
keys
(
interceptor
).
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
];
const
hook
=
interceptor
[
name
];
if
(
isArray
(
hooks
)
&&
isFunction
(
hook
))
{
remove
(
hooks
,
hook
);
}
});
}
...
...
@@ -524,15 +526,6 @@ function dedupeHooks(hooks) {
}
return
res
;
}
function
removeHook
(
hooks
,
hook
)
{
if
(
!
hooks
)
{
return
;
}
const
index
=
hooks
.
indexOf
(
hook
);
if
(
index
!==
-
1
)
{
hooks
.
splice
(
index
,
1
);
}
}
const
addInterceptor
=
defineSyncApi
(
API_ADD_INTERCEPTOR
,
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
...
...
packages/uni-mp-kuaishou/dist/uni.api.esm.js
浏览文件 @
1e233109
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
extend
}
from
'
@vue/shared
'
;
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
remove
,
extend
}
from
'
@vue/shared
'
;
let
vueApp
;
const
createVueAppHooks
=
[];
...
...
@@ -499,9 +499,11 @@ function removeInterceptorHook(interceptors, interceptor) {
if
(
!
interceptors
||
!
interceptor
)
{
return
;
}
Object
.
keys
(
interceptor
).
forEach
((
hook
)
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
removeHook
(
interceptors
[
hook
],
interceptor
[
hook
]);
Object
.
keys
(
interceptor
).
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
];
const
hook
=
interceptor
[
name
];
if
(
isArray
(
hooks
)
&&
isFunction
(
hook
))
{
remove
(
hooks
,
hook
);
}
});
}
...
...
@@ -524,15 +526,6 @@ function dedupeHooks(hooks) {
}
return
res
;
}
function
removeHook
(
hooks
,
hook
)
{
if
(
!
hooks
)
{
return
;
}
const
index
=
hooks
.
indexOf
(
hook
);
if
(
index
!==
-
1
)
{
hooks
.
splice
(
index
,
1
);
}
}
const
addInterceptor
=
defineSyncApi
(
API_ADD_INTERCEPTOR
,
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
...
...
packages/uni-mp-lark/dist/uni.api.esm.js
浏览文件 @
1e233109
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
extend
}
from
'
@vue/shared
'
;
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
remove
,
extend
}
from
'
@vue/shared
'
;
let
vueApp
;
const
createVueAppHooks
=
[];
...
...
@@ -499,9 +499,11 @@ function removeInterceptorHook(interceptors, interceptor) {
if
(
!
interceptors
||
!
interceptor
)
{
return
;
}
Object
.
keys
(
interceptor
).
forEach
((
hook
)
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
removeHook
(
interceptors
[
hook
],
interceptor
[
hook
]);
Object
.
keys
(
interceptor
).
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
];
const
hook
=
interceptor
[
name
];
if
(
isArray
(
hooks
)
&&
isFunction
(
hook
))
{
remove
(
hooks
,
hook
);
}
});
}
...
...
@@ -524,15 +526,6 @@ function dedupeHooks(hooks) {
}
return
res
;
}
function
removeHook
(
hooks
,
hook
)
{
if
(
!
hooks
)
{
return
;
}
const
index
=
hooks
.
indexOf
(
hook
);
if
(
index
!==
-
1
)
{
hooks
.
splice
(
index
,
1
);
}
}
const
addInterceptor
=
defineSyncApi
(
API_ADD_INTERCEPTOR
,
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
...
...
packages/uni-mp-qq/dist/uni.api.esm.js
浏览文件 @
1e233109
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
extend
}
from
'
@vue/shared
'
;
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
remove
,
extend
}
from
'
@vue/shared
'
;
let
vueApp
;
const
createVueAppHooks
=
[];
...
...
@@ -499,9 +499,11 @@ function removeInterceptorHook(interceptors, interceptor) {
if
(
!
interceptors
||
!
interceptor
)
{
return
;
}
Object
.
keys
(
interceptor
).
forEach
((
hook
)
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
removeHook
(
interceptors
[
hook
],
interceptor
[
hook
]);
Object
.
keys
(
interceptor
).
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
];
const
hook
=
interceptor
[
name
];
if
(
isArray
(
hooks
)
&&
isFunction
(
hook
))
{
remove
(
hooks
,
hook
);
}
});
}
...
...
@@ -524,15 +526,6 @@ function dedupeHooks(hooks) {
}
return
res
;
}
function
removeHook
(
hooks
,
hook
)
{
if
(
!
hooks
)
{
return
;
}
const
index
=
hooks
.
indexOf
(
hook
);
if
(
index
!==
-
1
)
{
hooks
.
splice
(
index
,
1
);
}
}
const
addInterceptor
=
defineSyncApi
(
API_ADD_INTERCEPTOR
,
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
...
...
packages/uni-mp-toutiao/dist/uni.api.esm.js
浏览文件 @
1e233109
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
extend
}
from
'
@vue/shared
'
;
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
remove
,
extend
}
from
'
@vue/shared
'
;
let
vueApp
;
const
createVueAppHooks
=
[];
...
...
@@ -499,9 +499,11 @@ function removeInterceptorHook(interceptors, interceptor) {
if
(
!
interceptors
||
!
interceptor
)
{
return
;
}
Object
.
keys
(
interceptor
).
forEach
((
hook
)
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
removeHook
(
interceptors
[
hook
],
interceptor
[
hook
]);
Object
.
keys
(
interceptor
).
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
];
const
hook
=
interceptor
[
name
];
if
(
isArray
(
hooks
)
&&
isFunction
(
hook
))
{
remove
(
hooks
,
hook
);
}
});
}
...
...
@@ -524,15 +526,6 @@ function dedupeHooks(hooks) {
}
return
res
;
}
function
removeHook
(
hooks
,
hook
)
{
if
(
!
hooks
)
{
return
;
}
const
index
=
hooks
.
indexOf
(
hook
);
if
(
index
!==
-
1
)
{
hooks
.
splice
(
index
,
1
);
}
}
const
addInterceptor
=
defineSyncApi
(
API_ADD_INTERCEPTOR
,
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
...
...
packages/uni-mp-weixin/dist/uni.api.esm.js
浏览文件 @
1e233109
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
extend
}
from
'
@vue/shared
'
;
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
remove
,
extend
}
from
'
@vue/shared
'
;
let
vueApp
;
const
createVueAppHooks
=
[];
...
...
@@ -463,9 +463,11 @@ function removeInterceptorHook(interceptors, interceptor) {
if
(
!
interceptors
||
!
interceptor
)
{
return
;
}
Object
.
keys
(
interceptor
).
forEach
((
hook
)
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
removeHook
(
interceptors
[
hook
],
interceptor
[
hook
]);
Object
.
keys
(
interceptor
).
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
];
const
hook
=
interceptor
[
name
];
if
(
isArray
(
hooks
)
&&
isFunction
(
hook
))
{
remove
(
hooks
,
hook
);
}
});
}
...
...
@@ -488,15 +490,6 @@ function dedupeHooks(hooks) {
}
return
res
;
}
function
removeHook
(
hooks
,
hook
)
{
if
(
!
hooks
)
{
return
;
}
const
index
=
hooks
.
indexOf
(
hook
);
if
(
index
!==
-
1
)
{
hooks
.
splice
(
index
,
1
);
}
}
const
addInterceptor
=
defineSyncApi
(
API_ADD_INTERCEPTOR
,
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
...
...
packages/uni-quickapp-webview/dist/uni.api.esm.js
浏览文件 @
1e233109
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
extend
}
from
'
@vue/shared
'
;
import
{
isArray
,
hasOwn
,
isString
,
isPlainObject
,
isObject
,
capitalize
,
toRawType
,
makeMap
,
isFunction
,
isPromise
,
remove
,
extend
}
from
'
@vue/shared
'
;
let
vueApp
;
const
createVueAppHooks
=
[];
...
...
@@ -499,9 +499,11 @@ function removeInterceptorHook(interceptors, interceptor) {
if
(
!
interceptors
||
!
interceptor
)
{
return
;
}
Object
.
keys
(
interceptor
).
forEach
((
hook
)
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
removeHook
(
interceptors
[
hook
],
interceptor
[
hook
]);
Object
.
keys
(
interceptor
).
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
];
const
hook
=
interceptor
[
name
];
if
(
isArray
(
hooks
)
&&
isFunction
(
hook
))
{
remove
(
hooks
,
hook
);
}
});
}
...
...
@@ -524,15 +526,6 @@ function dedupeHooks(hooks) {
}
return
res
;
}
function
removeHook
(
hooks
,
hook
)
{
if
(
!
hooks
)
{
return
;
}
const
index
=
hooks
.
indexOf
(
hook
);
if
(
index
!==
-
1
)
{
hooks
.
splice
(
index
,
1
);
}
}
const
addInterceptor
=
defineSyncApi
(
API_ADD_INTERCEPTOR
,
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录