You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.4 KiB
73 lines
1.4 KiB
// 路由
|
|
import {
|
|
RouterMount,
|
|
createRouter
|
|
} from './uni-simple-router.js'
|
|
import store from '@/nxTemp/store'
|
|
const router = createRouter({
|
|
platform: process.env.VUE_APP_PLATFORM,
|
|
applet: {
|
|
animationDuration: 0 //默认 300ms
|
|
},
|
|
routerErrorEach: ({
|
|
type,
|
|
msg
|
|
}) => {
|
|
console.log(55555,type,msg)
|
|
|
|
switch (type) {
|
|
case 3: // APP退出应用
|
|
// #ifdef APP-PLUS
|
|
router.$lockStatus = false;
|
|
uni.showModal({
|
|
title: '提示',
|
|
content: '您确定要退出应用吗?',
|
|
success: function(res) {
|
|
if (res.confirm) {
|
|
plus.runtime.quit();
|
|
}
|
|
}
|
|
});
|
|
// #endif
|
|
break;
|
|
case 2:
|
|
case 0:
|
|
console.log(66666,type)
|
|
router.$lockStatus = false;
|
|
break;
|
|
default:
|
|
console.log(77777,type)
|
|
break;
|
|
}
|
|
|
|
},
|
|
// 通配符,非定义页面,跳转404
|
|
routes: [...ROUTES,
|
|
{
|
|
path: '*',
|
|
redirect: (to) => {
|
|
return {
|
|
name: '404'
|
|
}
|
|
}
|
|
},
|
|
]
|
|
});
|
|
|
|
//全局路由前置守卫
|
|
router.beforeEach((to, from, next) => {
|
|
// 权限控制登录
|
|
next()
|
|
// // 有两个个判断条件,一个是token,还有一个路由元信息
|
|
// let userInfo = Boolean(uni.getStorageSync('userInfo'));
|
|
// // 权限控制
|
|
// if (to.meta && to.meta.auth && !userInfo) {//没有登录信息执行登录操作
|
|
// } else {
|
|
// next()
|
|
// }
|
|
});
|
|
|
|
export {
|
|
router,
|
|
RouterMount
|
|
}
|