zyouan 2 ヶ月 前
コミット
ef838de814
3 ファイル変更13 行追加8 行削除
  1. 1 0
      jsconfig.json
  2. 4 4
      src/config/router.config.js
  3. 8 4
      src/permission.js

+ 1 - 0
jsconfig.json

@@ -1,6 +1,7 @@
 {
   "compilerOptions": {
     "target": "es6",
+    "base": "/manager/",
     "baseUrl": "/manager/",
     "publicPath":"/manager/",
     "paths": {

+ 4 - 4
src/config/router.config.js

@@ -13,10 +13,10 @@ export const asyncRouterMap = [
     name: 'list',
     component: BasicLayout,
     meta: { title: '订单' },
-    redirect: '/list/table-list',
+    redirect: '/manager/list/table-list',
     children: [
       {
-        path: '/list/table-list/:pageNo([1-9]\\d*)?',
+        path: '/manager/list/table-list/:pageNo([1-9]\\d*)?',
         name: 'TableListWrapper',
         hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
         component: () => import('@/views/list/TableList'),
@@ -355,9 +355,9 @@ export const asyncRouterMap = [
  */
 export const constantRouterMap = [
   {
-    path: '/user',
+    path: '/manager/user',
     component: UserLayout,
-    redirect: '/user/login',
+    redirect: '/manager/user/login',
     hidden: true,
     children: [
       {

+ 8 - 4
src/permission.js

@@ -10,8 +10,8 @@ import { i18nRender } from '@/locales'
 NProgress.configure({ showSpinner: false }) // NProgress Configuration
 
 const allowList = ['login', 'register', 'registerResult'] // no redirect allowList
-const loginRoutePath = '/user/login'
-const defaultRoutePath = '/list/table-list'
+const loginRoutePath = '/manager/user/login'
+const defaultRoutePath = '/manager/list/table-list'
 
 router.beforeEach((to, from, next) => {
   to.meta && typeof to.meta.title !== 'undefined' && setDocumentTitle(`${i18nRender(to.meta.title)} - ${domTitle}`)
@@ -86,8 +86,12 @@ router.beforeEach((to, from, next) => {
       console.log('Router guard - white list path, proceeding')
       next()
     } else {
-      console.log('Router guard - redirecting to login')
-      next({ path: loginRoutePath, query: { redirect: to.fullPath } })
+      console.log('Router guard - redirecting to login' + to.fullPath)
+      if (to.fullPath === '/404') {
+        next({ path: loginRoutePath })
+      } else {
+        next({ path: loginRoutePath, query: { redirect: to.fullPath } })
+      }
       NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
     }
   }