调整router版本
This commit is contained in:
46
node_modules/uni-simple-router/src/public/beforeProxyHook.ts
generated
vendored
46
node_modules/uni-simple-router/src/public/beforeProxyHook.ts
generated
vendored
@@ -1,46 +0,0 @@
|
||||
import { voidFun } from '../helpers/utils';
|
||||
import { warn } from '../helpers/warn';
|
||||
import { Router, vueHookNameRule } from '../options/base';
|
||||
|
||||
export function beforeProxyHook(
|
||||
Vim:any,
|
||||
router:Router
|
||||
):boolean {
|
||||
const hookOptions = Vim.$options;
|
||||
const {beforeProxyHooks} = router.options;
|
||||
if (hookOptions == null) {
|
||||
return false;
|
||||
}
|
||||
if (beforeProxyHooks == null) {
|
||||
return false;
|
||||
}
|
||||
const keyArray = Object.keys(beforeProxyHooks) as Array<vueHookNameRule>;
|
||||
for (let i = 0; i < keyArray.length; i++) {
|
||||
const key = keyArray[i];
|
||||
const hooksArray:Array<Function>|null = hookOptions[key];
|
||||
if (hooksArray) {
|
||||
const beforeProxyFun = beforeProxyHooks[key];
|
||||
for (let j = 0; j < hooksArray.length; j++) {
|
||||
const hookFun = hooksArray[j];
|
||||
if (hookFun.toString().includes($npm_package_name)) {
|
||||
continue
|
||||
}
|
||||
const [oldHook] = hooksArray.splice(j, 1, function myReplace(this: any, ...args:Array<any>) {
|
||||
const pluginMarkId = $npm_package_name;
|
||||
voidFun(pluginMarkId);
|
||||
|
||||
if (beforeProxyFun) {
|
||||
beforeProxyFun.call(this, args, (options) => {
|
||||
oldHook.apply(this, options)
|
||||
}, router);
|
||||
} else {
|
||||
oldHook.apply(this, args)
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
warn(`beforeProxyHooks ===> 当前组件不适合${key},或者 hook: ${key} 不存在,已为你规避处理,可以忽略。`, router)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
4
node_modules/uni-simple-router/src/public/hooks.ts
generated
vendored
4
node_modules/uni-simple-router/src/public/hooks.ts
generated
vendored
@@ -18,7 +18,6 @@ import {
|
||||
} from '../helpers/utils'
|
||||
import { navjump } from './methods';
|
||||
import { proxyH5Mount } from '../H5/proxyHook';
|
||||
import { addKeepAliveInclude } from '../H5/patch';
|
||||
import { tabIndexSelect } from '../app/appPatch';
|
||||
|
||||
export const ERRORHOOK:Array<(error:navErrorRule, router:Router)=>void> = [
|
||||
@@ -34,10 +33,7 @@ export const HOOKLIST: hookListRule = [
|
||||
router.$lockStatus = false;
|
||||
if (router.options.platform === 'h5') {
|
||||
proxyH5Mount(router);
|
||||
// 【Fixe】 https://github.com/SilurianYang/uni-simple-router/issues/316 2021年12月10日14:30:13
|
||||
addKeepAliveInclude(router);
|
||||
}
|
||||
router.runId++;
|
||||
return callHook(router.lifeCycle.routerAfterHooks[0], to, from, router, next, false)
|
||||
}
|
||||
];
|
||||
|
||||
5
node_modules/uni-simple-router/src/public/methods.ts
generated
vendored
5
node_modules/uni-simple-router/src/public/methods.ts
generated
vendored
@@ -64,11 +64,6 @@ export function navjump(
|
||||
level = +to;
|
||||
} else {
|
||||
level = to.delta || 1;
|
||||
// 主要剥离事件函数
|
||||
animation = {
|
||||
...animation || {},
|
||||
...(to as uniBackApiRule)
|
||||
}
|
||||
}
|
||||
if (router.options.platform === 'h5') {
|
||||
(router.$route as any).go(-level);
|
||||
|
||||
35
node_modules/uni-simple-router/src/public/rewrite.ts
generated
vendored
35
node_modules/uni-simple-router/src/public/rewrite.ts
generated
vendored
@@ -27,7 +27,6 @@ import {
|
||||
} from '../helpers/warn'
|
||||
|
||||
import {uniOriginJump} from './uniOrigin'
|
||||
import { HomeNvueSwitchTab } from '../app/appPatch';
|
||||
|
||||
const rewrite: Array<reNavMethodRule|reNotNavMethodRule> = [
|
||||
'navigateTo',
|
||||
@@ -36,19 +35,6 @@ const rewrite: Array<reNavMethodRule|reNotNavMethodRule> = [
|
||||
'switchTab',
|
||||
'navigateBack'
|
||||
];
|
||||
const cacheOldMethod:{
|
||||
navigateTo:Function;
|
||||
redirectTo:Function;
|
||||
reLaunch:Function;
|
||||
switchTab:Function;
|
||||
navigateBack:Function;
|
||||
} = {
|
||||
navigateTo: () => {},
|
||||
redirectTo: () => {},
|
||||
reLaunch: () => {},
|
||||
switchTab: () => {},
|
||||
navigateBack: () => {}
|
||||
}
|
||||
|
||||
export function rewriteMethod(
|
||||
router:Router
|
||||
@@ -56,20 +42,14 @@ export function rewriteMethod(
|
||||
if (router.options.keepUniOriginNav === false) {
|
||||
rewrite.forEach(name => {
|
||||
const oldMethod: Function = uni[name];
|
||||
cacheOldMethod[name] = oldMethod;
|
||||
uni[name] = async function(
|
||||
uni[name] = function(
|
||||
params:originMixins|{from:string}|navtoRule,
|
||||
originCall:boolean = false,
|
||||
callOkCb?:Function,
|
||||
forceNav?:boolean
|
||||
):Promise<void> {
|
||||
|
||||
):void {
|
||||
if (originCall) {
|
||||
if (router.options.platform === 'app-plus') {
|
||||
await HomeNvueSwitchTab(router, (params as navtoRule), cacheOldMethod['reLaunch']);
|
||||
}
|
||||
uniOriginJump(router, oldMethod, name, params as originMixins, callOkCb, forceNav)
|
||||
|
||||
} else {
|
||||
if (router.options.platform === 'app-plus') {
|
||||
if (Object.keys(router.appMain).length === 0) {
|
||||
@@ -81,8 +61,6 @@ export function rewriteMethod(
|
||||
}
|
||||
callRouterMethod(params as uniNavApiRule, name, router);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
})
|
||||
}
|
||||
@@ -104,7 +82,8 @@ function callRouterMethod(
|
||||
if (funName === 'reLaunch' && JSON.stringify(option) === '{"url":"/"}') {
|
||||
warn(
|
||||
`uni-app 原生方法:reLaunch({url:'/'}) 默认被重写啦!你可以使用 this.$Router.replaceAll() 或者 uni.reLaunch({url:'/?xxx=xxx'})`,
|
||||
router
|
||||
router,
|
||||
true
|
||||
);
|
||||
funName = 'navigateBack';
|
||||
option = {
|
||||
@@ -134,13 +113,15 @@ function callRouterMethod(
|
||||
if (getDataType<string | string[]>(finallyPath) === '[object Array]') {
|
||||
warn(
|
||||
`uni-app 原生方法跳转路径为:${path}。此路为是tab页面时,不允许设置 alias 为数组的情况,并且不能为动态路由!当然你可以通过通配符*解决!`,
|
||||
router
|
||||
router,
|
||||
true
|
||||
);
|
||||
}
|
||||
if ((finallyPath as string) === '*') {
|
||||
warn(
|
||||
`uni-app 原生方法跳转路径为:${path}。在路由表中找不到相关路由表!当然你可以通过通配符*解决!`,
|
||||
router
|
||||
router,
|
||||
true
|
||||
);
|
||||
}
|
||||
// Fixe h5 端无法触发 onTabItemTap hook 2021年6月3日17:26:47
|
||||
|
||||
11
node_modules/uni-simple-router/src/public/router.ts
generated
vendored
11
node_modules/uni-simple-router/src/public/router.ts
generated
vendored
@@ -10,14 +10,11 @@ import {rewriteMethod} from '../public/rewrite'
|
||||
let AppReadyResolve:PromiseResolve = () => {};
|
||||
const AppReady:Promise<void> = new Promise(resolve => (AppReadyResolve = resolve));
|
||||
|
||||
function createRouter(
|
||||
params: InstantiateConfig
|
||||
):Router {
|
||||
function createRouter(params: InstantiateConfig):Router {
|
||||
const options = assertNewOptions<InstantiateConfig>(params);
|
||||
const router:Router = {
|
||||
options,
|
||||
mount: [],
|
||||
runId: 0,
|
||||
Vue: null,
|
||||
proxyHookDeps: proxyHookDeps,
|
||||
appMain: {},
|
||||
@@ -109,11 +106,7 @@ function createRouter(
|
||||
return router;
|
||||
}
|
||||
|
||||
function RouterMount(
|
||||
Vim:any,
|
||||
router:Router,
|
||||
el:string | undefined = '#app'
|
||||
) :void|never {
|
||||
function RouterMount(Vim:any, router:Router, el:string | undefined = '#app') :void|never {
|
||||
if (getDataType<Array<any>>(router.mount) === '[object Array]') {
|
||||
router.mount.push({
|
||||
app: Vim,
|
||||
|
||||
Reference in New Issue
Block a user