瀏覽代碼

重复请求重定向

zhengnaiwen_citu 3 月之前
父節點
當前提交
ade6f3d5b3
共有 4 個文件被更改,包括 14 次插入9 次删除
  1. 0 3
      src/App.vue
  2. 8 4
      src/components/AutoComponents/ECharts/index.vue
  3. 5 2
      src/permission.js
  4. 1 0
      src/utils/request.js

+ 0 - 3
src/App.vue

@@ -7,9 +7,6 @@ import autoRefresh from './update'
 export default {
   name: 'App',
   created () {
-    this.$store.dispatch('system/getOrganizationTree').catch(error => {
-      console.log(error)
-    })
     if (process.env.NODE_ENV !== 'production') {
       return
     }

+ 8 - 4
src/components/AutoComponents/ECharts/index.vue

@@ -38,10 +38,14 @@ export default {
         })
         return
       }
-      this.resizeObserver = new ResizeObserver(() => {
-        if (this.chart) {
-          this.onResize()
-        }
+      this.resizeObserver = new ResizeObserver(entries => {
+        window.requestAnimationFrame(() => {
+          if (!Array.isArray(entries) || !entries.length) return
+          // 处理尺寸变化的代码
+          if (this.chart) {
+            this.onResize()
+          }
+        })
       })
       this.resizeObserver.observe(this.$refs.content)
     },

+ 5 - 2
src/permission.js

@@ -10,6 +10,7 @@ import store from './store'
 import Vue from 'vue'
 // 刷新token状态
 let isRefreshToken = true
+let isRefreshTree = true
 
 // 路由拦截
 router.beforeEach(async (to, from, next) => {
@@ -46,8 +47,10 @@ router.beforeEach(async (to, from, next) => {
       }
     }
     // 判断是否已经存在机构信息
-    if (!store.getters.organizationTree.length) {
-      store.dispatch('system/getOrganizationTree').catch(e => {
+    if (isRefreshTree) {
+      store.dispatch('system/getOrganizationTree').then(_ => {
+        isRefreshTree = false
+      }).catch(e => {
         Vue.prototype.$message.error('获取机构信息失败')
       }).finally(() => {
         onFilterRoutes(to, next)

+ 1 - 0
src/utils/request.js

@@ -78,6 +78,7 @@ service.interceptors.response.use(
       // setTimeout(() => {
       //   Vue.prototype.$message.error(str)
       // })
+      debugger
       window.location.href = url
       return
     }