登录叶细胞
This commit is contained in:
@@ -1,75 +1,31 @@
|
||||
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||
import staticRoutes from '@/router/static'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import NProgress from 'nprogress'
|
||||
import { loading } from '@/utils/loading'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHashHistory(),
|
||||
routes: staticRoutes
|
||||
})
|
||||
|
||||
// router.beforeEach((to, from, next) => {
|
||||
// NProgress.configure({ showSpinner: false })
|
||||
// NProgress.start()
|
||||
// if (!window.existLoading) {
|
||||
// loading.show()
|
||||
// window.existLoading = true
|
||||
// }
|
||||
router.beforeEach((to, from, next) => {
|
||||
NProgress.configure({ showSpinner: false })
|
||||
NProgress.start()
|
||||
if (!window.existLoading) {
|
||||
loading.show()
|
||||
window.existLoading = true
|
||||
}
|
||||
console.log(to)
|
||||
next()
|
||||
})
|
||||
|
||||
// // 按需动态加载页面的语言包-start
|
||||
// let loadPath: string[] = []
|
||||
// const config = useConfig()
|
||||
// if (to.path in langAutoLoadMap) {
|
||||
// loadPath.push(...langAutoLoadMap[to.path as keyof typeof langAutoLoadMap])
|
||||
// }
|
||||
// let prefix = ''
|
||||
// if (isAdminApp(to.fullPath)) {
|
||||
// prefix = './backend/' + config.lang.defaultLang
|
||||
|
||||
// // 去除 path 中的 /admin
|
||||
// const adminPath = to.path.slice(to.path.indexOf(adminBaseRoutePath) + adminBaseRoutePath.length)
|
||||
// if (adminPath) loadPath.push(prefix + adminPath + '.ts')
|
||||
// } else {
|
||||
// prefix = './frontend/' + config.lang.defaultLang
|
||||
// loadPath.push(prefix + to.path + '.ts')
|
||||
// }
|
||||
|
||||
// // 根据路由 name 加载的语言包
|
||||
// if (to.name) {
|
||||
// loadPath.push(prefix + '/' + to.name.toString() + '.ts')
|
||||
// }
|
||||
|
||||
// if (!window.loadLangHandle.publicMessageLoaded) window.loadLangHandle.publicMessageLoaded = []
|
||||
// const publicMessagePath = prefix + '.ts'
|
||||
// if (!window.loadLangHandle.publicMessageLoaded.includes(publicMessagePath)) {
|
||||
// loadPath.push(publicMessagePath)
|
||||
// window.loadLangHandle.publicMessageLoaded.push(publicMessagePath)
|
||||
// }
|
||||
|
||||
// // 去重
|
||||
// loadPath = uniq(loadPath)
|
||||
|
||||
// for (const key in loadPath) {
|
||||
// loadPath[key] = loadPath[key].replaceAll('${lang}', config.lang.defaultLang)
|
||||
// if (loadPath[key] in window.loadLangHandle) {
|
||||
// window.loadLangHandle[loadPath[key]]().then((res: { default: anyObj }) => {
|
||||
// const pathName = loadPath[key].slice(
|
||||
// loadPath[key].lastIndexOf(prefix) + (prefix.length + 1),
|
||||
// loadPath[key].lastIndexOf('.')
|
||||
// )
|
||||
// mergeMessage(res.default, pathName)
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// // 动态加载语言包-end
|
||||
|
||||
// next()
|
||||
// })
|
||||
|
||||
// // 路由加载后
|
||||
// router.afterEach(() => {
|
||||
// if (window.existLoading) {
|
||||
// loading.hide()
|
||||
// }
|
||||
// NProgress.done()
|
||||
// })
|
||||
// 路由加载后
|
||||
router.afterEach(() => {
|
||||
if (window.existLoading) {
|
||||
loading.hide()
|
||||
}
|
||||
NProgress.done()
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
@@ -34,6 +34,14 @@ export const adminBaseRoute = {
|
||||
*/
|
||||
const staticRoutes: Array<RouteRecordRaw> = [
|
||||
adminBaseRoute,
|
||||
{
|
||||
path: '/',
|
||||
redirect: (to) => {
|
||||
return {
|
||||
name: 'adminMainLoading'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
// 管理员登录页 - 不放在 adminBaseRoute.children 因为登录页不需要使用后台的布局
|
||||
path: '/login',
|
||||
@@ -43,7 +51,6 @@ const staticRoutes: Array<RouteRecordRaw> = [
|
||||
title: pageTitle('login')
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
path: '/:path(.*)*',
|
||||
redirect: '/404'
|
||||
@@ -56,6 +63,21 @@ const staticRoutes: Array<RouteRecordRaw> = [
|
||||
meta: {
|
||||
title: pageTitle('notFound') // 页面不存在
|
||||
}
|
||||
},
|
||||
{
|
||||
// 后台找不到页面了-可能是路由未加载上
|
||||
path: adminBaseRoutePath + ':path(.*)*',
|
||||
redirect: (to) => {
|
||||
return {
|
||||
name: 'adminMainLoading',
|
||||
params: {
|
||||
to: JSON.stringify({
|
||||
path: to.path,
|
||||
query: to.query
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user