Browse Source

wanda-adm:feat >修改路由文件,解决报错问题

shaun-sheep 4 years ago
parent
commit
b4007250dd
5 changed files with 37 additions and 204 deletions
  1. 1 1
      package.json
  2. 0 192
      src/router.ts
  3. 29 5
      src/router/index.ts
  4. 5 4
      src/utils/request.ts
  5. 2 2
      src/views/error-page/401.vue

+ 1 - 1
package.json

@@ -14,7 +14,7 @@
   },
   "dependencies": {
     "@babel/runtime": "^7.12.5",
-    "axios": "^0.21.0",
+    "axios": "^0.21.1",
     "core-js": "^3.6.5",
     "element-ui": "^2.14.1",
     "js-cookie": "^2.2.1",

+ 0 - 192
src/router.ts

@@ -1,192 +0,0 @@
-import Vue from 'vue'
-import Router from 'vue-router'
-import Layout from '@/layout/index.vue'
-
-Vue.use(Router)
-
-/*
-  redirect:                     如果设置为“noredirect”,则单击面包屑时不会触发重定向操作
-  meta: {
-    title: 'title'               子菜单和面包屑中显示的名称(推荐)
-    icon: 'svg-name'             侧边栏中显示的图标
-    breadcrumb: false            如果为false,则项目将隐藏在breadcrumb中(默认值为true)
-    hidden: true                 如果为true,此路由将不会显示在侧边栏中(默认为false)
-  }
-*/
-
-export default new Router({
-  mode: 'history',
-  scrollBehavior: (to, from, savedPosition) => {
-    if (savedPosition) {
-      return savedPosition
-    } else {
-      return {x: 0, y: 0}
-    }
-  },
-  base: process.env.BASE_URL,
-  routes: [
-    {
-      path: '/login',
-      component: () => import(/* webpackChunkName: "login" */ '@/views/login/index.vue'),
-      meta: {hidden: true}
-    },
-    {
-      path: '/404',
-      component: () => import(/* webpackChunkName: "404" */ '@/views/error-page/404.vue'),
-      meta: { hidden: true }
-    },
-    {
-      path: '/401',
-      component: () => import(/* webpackChunkName: "401" */ '@/views/error-page/401.vue'),
-      meta: { hidden: true }
-    },
-    {
-      path: '/',
-      redirect: '/project/index',
-      component: Layout,
-      children: [
-        {
-          path: 'project/index',
-          component: () => import(/* webpackChunkName: "project" */ '@/views/project/index.vue'),
-          meta: {
-            title: '项目管理',
-            icon: 'form'
-          }
-        }
-      ]
-    },
-    {
-      path: '/manage',
-      component: Layout,
-      meta: {
-        title: '文件管理',
-        icon: 'example'
-      },
-      children: [
-        {
-          path: 'build',
-          component: () => import(/* webpackChunkName: "build" */ '@/views/manage/build/index.vue'),
-          meta: {
-            title: '建筑楼层管理',
-            icon: 'tree'
-          }
-        },
-        {
-          path: 'model',
-          component: () => import(/* webpackChunkName: "model" */ '@/views/manage/model/index.vue'),
-          meta: {
-            title: '模型修改任务',
-            icon: 'table'
-          }
-        }
-      ]
-    }, {
-      path: '/maintain',
-      component: Layout,
-      redirect: '/maintain/device',
-      meta: {
-        title: '数据维护',
-        icon: 'nested'
-      },
-      children: [
-        {
-          path: 'device',
-          component: () => import(/* webpackChunkName: "device" */ '@/views/maintain/device/index.vue'),
-          meta: {title: '设备'},
-        },
-        {
-          path: 'space',
-          component: () => import(/* webpackChunkName: "space" */ '@/views/maintain/space/index.vue'),
-          meta: {title: '空间'}
-        },
-        {
-          path: 'system',
-          component: () => import(/* webpackChunkName: "system" */ '@/views/maintain/system/index.vue'),
-          meta: {title: '系统'}
-        },
-        {
-          path: 'relationship',
-          component: () => import(/* webpackChunkName: "relationship" */ '@/views/maintain/relationship/index.vue'),
-          meta: {title: '关系'}
-        }
-      ]
-    },
-
-    {
-      path: '/scene',
-      component: Layout,
-      redirect: '/scene/tiepoint',
-      meta: {
-        title: '现场实施',
-        icon: 'nested'
-      },
-      children: [
-        {
-          path: 'tiepoint',
-          component: () => import(/* webpackChunkName: "tiepoint" */ '@/views/scene/tiepoint/index.vue'),
-          meta: {title: '绑点'},
-        },
-        {
-          path: 'system',
-          component: () => import(/* webpackChunkName: "system" */ '@/views/scene/system/index.vue'),
-          meta: {title: '系统图'}
-        },
-        {
-          path: 'plane',
-          component: () => import(/* webpackChunkName: "plane" */ '@/views/scene/plane/index.vue'),
-          meta: {title: '平面图'}
-        }
-      ]
-    },
-    {
-      path: '/tools',
-      component: Layout,
-      meta: {
-        title: '一致性检查工具',
-        icon: 'nested'
-      },
-    },
-    {
-      path: '/model-tool',
-      component: Layout,
-      meta: {
-        title: '模型检查工具',
-        icon: 'nested'
-      },
-    },
-    {
-      path: '/error',
-      component: Layout,
-      redirect: 'noredirect',
-      meta: {
-        title: '错误页面',
-        icon: 'nested'
-      },
-      children: [
-        {
-          path: '401',
-          component: () => import(/* webpackChunkName: "error-page-401" */ '@/views/error-page/401.vue'),
-          name: 'Page401',
-          meta: {
-            title: '401',
-            noCache: true
-          }
-        },
-        {
-          path: '404',
-          component: () => import(/* webpackChunkName: "error-page-404" */ '@/views/error-page/404.vue'),
-          name: '404',
-          meta: {
-            title: '404',
-            noCache: true
-          }
-        }
-      ]
-    },
-    {
-      path: '*',
-      redirect: '/404',
-      meta: {hidden: true}
-    }
-  ]
-})

+ 29 - 5
src/router/index.ts

@@ -32,11 +32,6 @@ export default new Router({
       meta: { hidden: true }
     },
     {
-      path: "/404",
-      component: () => import(/* webpackChunkName: "404" */ "@/views/404.vue"),
-      meta: { hidden: true }
-    },
-    {
       path: "/",
       redirect: "/project/index",
       component: Layout,
@@ -182,6 +177,35 @@ export default new Router({
       }
     },
     {
+      path: '/error',
+      component: Layout,
+      redirect: 'noredirect',
+      meta: {
+        title: '错误页面',
+        icon: "nested"
+      },
+      children: [
+        {
+          path: '401',
+          component: () => import(/* webpackChunkName: "error-page-401" */ '@/views/error-page/401.vue'),
+          name: 'Page401',
+          meta: {
+            title: '401',
+            noCache: true
+          }
+        },
+        {
+          path: '404',
+          component: () => import(/* webpackChunkName: "error-page-404" */ '@/views/error-page/404.vue'),
+          name: '404',
+          meta: {
+            title: '404',
+            noCache: true
+          }
+        }
+      ]
+    },
+    {
       path: "*",
       redirect: "/404",
       meta: { hidden: true }

+ 5 - 4
src/utils/request.ts

@@ -1,3 +1,4 @@
+// @ts-ignore
 import axios from 'axios'
 import { Message, MessageBox } from 'element-ui'
 import { UserModule } from '@/store/modules/user'
@@ -9,21 +10,21 @@ const service = axios.create({
 
 // Request interceptors
 service.interceptors.request.use(
-  (config) => {
+  (config: { headers: { [x: string]: string } }) => {
     // Add X-Access-Token header to every request, you can add other custom headers here
     if (UserModule.token) {
       config.headers['X-Access-Token'] = UserModule.token
     }
     return config
   },
-  (error) => {
+  (error: any) => {
     Promise.reject(error)
   }
 )
 
 // Response interceptors
 service.interceptors.response.use(
-  (response) => {
+  (response: { data: any }) => {
     // Some example codes here:
     // code == 20000: success
     // code == 50001: invalid access token
@@ -58,7 +59,7 @@ service.interceptors.response.use(
       return response.data
     }
   },
-  (error) => {
+  (error: { message: any }) => {
     Message({
       message: error.message,
       type: 'error',

+ 2 - 2
src/views/error-page/401.vue

@@ -21,12 +21,12 @@
         <ul class="list-unstyled">
           <li>或者你可以去:</li>
           <li class="link-type">
-            <router-link to="/dashboard">
+            <router-link to="/project/index">
               回首页
             </router-link>
           </li>
           <li class="link-type">
-            <a href="https://github.com/armour">随便看看</a>
+            <a href="#">随便看看</a>
           </li>
           <li>
             <a