ming преди 3 години
родител
ревизия
0caac3a92e
променени са 5 файла, в които са добавени 16 реда и са изтрити 17 реда
  1. 7 12
      src/App.vue
  2. 1 1
      src/config/default/setting.config.js
  3. 4 2
      src/layout/vab-avatar/index.vue
  4. 3 1
      src/vab/plugins/permissions.js
  5. 1 1
      src/views/alarmManage/index.vue

+ 7 - 12
src/App.vue

@@ -3,24 +3,24 @@
 </template>
 <script>
 import { defineComponent, watchEffect } from 'vue'
-import {useRouter} from 'vue-router'
+// import {useRouter} from 'vue-router'
 
 import store from '@/store'
 
 export default defineComponent({
   setup() {
     let hasToken = store.getters['user/accessToken']
-    let router = useRouter();
+    // let router = useRouter();
 
     watchEffect((fn, options) => {
       fn, options
       if (!hasToken) {
-        // alert('跳转到登录页')
-        router.push({
-          path: '/login',
-        })
+        // router.push({
+        //   path: '/login',
+        // })
       } else {
-        // alert('token不失效')
+        console.log(2)
+
       }
     })
     return {
@@ -28,12 +28,7 @@ export default defineComponent({
     }
   },
 })
-// export default {
-//     mounted(){
-//     console.log(111111)
 
-//   }
-// }
 </script>
 
 <style lang="less">

+ 1 - 1
src/config/default/setting.config.js

@@ -44,7 +44,7 @@ const setting = {
     //token存储位置localStorage sessionStorage cookie
     storage: 'localStorage',
     //token失效回退到登录页时是否记录本次的路由
-    recordRoute: false,
+    recordRoute: true,
     //是否显示logo,不显示时设置false,显示时请填写remixIcon图标名称,暂时只支持设置remixIcon
     // logo: 'vuejs-fill',
     //语言类型zh、en

+ 4 - 2
src/layout/vab-avatar/index.vue

@@ -80,8 +80,10 @@ export default {
     async logout() {
       await this.$store.dispatch('user/logout')
       if (recordRoute) {
-        const fullPath = this.$route.fullPath
-        this.$router.push(`/login?redirect=${fullPath}`)
+        // const fullPath = this.$route.fullPath
+        // this.$router.push(`/login?redirect=${fullPath}`)
+
+        this.$router.push('/login')
       } else {
         this.$router.push('/login')
       }

+ 3 - 1
src/vab/plugins/permissions.js

@@ -61,10 +61,12 @@ router.beforeEach(async(to, from, next) => {
         }
     } else {
 
+        routesWhiteList
+        // next({ path: '/login', replace: true })
+
         if (routesWhiteList.indexOf(to.path) !== -1) {
             next()
         } else {
-            // next({ path: '/login', replace: true })
             if (recordRoute)
                 next({ path: '/login', query: { redirect: to.path }, replace: true })
             else next({ path: '/login', replace: true })

+ 1 - 1
src/views/alarmManage/index.vue

@@ -227,7 +227,7 @@ export default defineComponent({
 
     onMounted(() => {
       listSelect()
-      // console.log(store, router)
+      // window.location.reload()
     })
 
     //条数