From 02409bfbe15f22fc3b5dccadabfd860a660a49d9 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Sat, 11 Oct 2025 10:37:14 +0800
Subject: [PATCH] feat: 名称修改

---
 src/permission.js |   97 ++++++++++++++++++++++++++----------------------
 1 files changed, 53 insertions(+), 44 deletions(-)

diff --git a/src/permission.js b/src/permission.js
index c244bec..36ed552 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -18,6 +18,8 @@
 NProgress.configure({ showSpinner: false })
 const lockPage = '/lock' //锁屏页
 const urlParams = getUrlParams(window.location.href)
+const adminUrl = import.meta.env.VITE_APP_DASHBOARD_URL
+const env = import.meta.env.VITE_APP_ENV
 
 function findRouteByPath (routes, targetPath) {
   // 遍历数组中的每个路由对象
@@ -39,51 +41,49 @@
   // 遍历完所有路由都没找到,返回null
   return null
 }
-
 router.beforeEach((to, from, next) => {
   const meta = to.meta || {}
   const isMenu = meta.menu === undefined ? to.query.menu : meta.menu
   store.commit('SET_IS_MENU', isMenu === undefined)
 
   const menuAll = getStore({ name: 'menuAll' })
-
-  if (!menuAll) {
-    store.dispatch('GetMenu').then(data => {
-      if (data.length !== 0) {
-        router.$avueRouter.formatRoutes(data, true)
-
-        let newMenu = getStore({ name: 'menuAll' })
-
-        let firstMenu = newMenu[0]
-
-        let toMenu = findRouteByPath(newMenu, to.path)
-
-        store.commit('ADD_TAG', {
-          name: firstMenu.name,
-          path: firstMenu.path,
-          fullPath: firstMenu.path,
-          params: firstMenu.params || {},
-          query: firstMenu.query || {},
-          meta: firstMenu.meta || {},
-        })
-
-        store.commit('ADD_TAG', {
-          name: toMenu.name,
-          path: toMenu.path,
-          fullPath: toMenu.path,
-          params: toMenu.params || {},
-          query: toMenu.query || {},
-          meta: toMenu.meta || {},
-        })
-
-        next(to.fullPath)
-      }
-    })
-
-    return
-  }
-
   if (getToken()) {
+    if (!menuAll?.length) {
+      store.dispatch('GetMenu').then(data => {
+        if (data.length !== 0) {
+          router.$avueRouter.formatRoutes(data, true)
+
+          let newMenu = getStore({ name: 'menuAll' })
+
+          let firstMenu = newMenu[0]
+
+          let toMenu = findRouteByPath(newMenu, to.path)
+
+          store.commit('ADD_TAG', {
+            name: firstMenu.name,
+            path: firstMenu.path,
+            fullPath: firstMenu.path,
+            params: firstMenu.params || {},
+            query: firstMenu.query || {},
+            meta: firstMenu.meta || {},
+          })
+
+          store.commit('ADD_TAG', {
+            name: toMenu.name,
+            path: toMenu.path,
+            fullPath: toMenu.path,
+            params: toMenu.params || {},
+            query: toMenu.query || {},
+            meta: toMenu.meta || {},
+          })
+
+          next(to.fullPath)
+        }
+      })
+
+      return
+    }
+
     if (store.getters.isLock && to.path !== lockPage) {
       //如果系统激活锁屏,全部跳转到锁屏页
       next({ path: lockPage })
@@ -96,6 +96,7 @@
         store.dispatch('FedLogOut').then(() => {
           next({ path: '/login' })
         })
+        // store.dispatch('FedLogOut').then(() =>  window.location.replace(`${adminUrl}#/login`));
       } else {
         const meta = to.meta || {}
         const query = to.query || {}
@@ -120,14 +121,22 @@
     if (meta.isAuth === false) {
       next()
     } else {
-      next('/login')
+      env === 'development' ? next('/login') : window.location.replace(`${adminUrl}#/login`)
     }
   }
 })
 
+// router.afterEach(to => {
+//   NProgress.done()
+//   let title = router.$avueRouter.generateTitle(to, { label: 'name' })
+//   router.$avueRouter.setTitle(title)
+//   store.commit('SET_IS_SEARCH', false)
+// })
 router.afterEach(to => {
-  NProgress.done()
-  let title = router.$avueRouter.generateTitle(to, { label: 'name' })
-  router.$avueRouter.setTitle(title)
-  store.commit('SET_IS_SEARCH', false)
-})
+	NProgress.done()
+	const isLoginPage = to.path === '/login'
+	// 根据是否登录页设置标题
+	const pageTitle = isLoginPage ? '中图智飞低空感知网平台' : '综合管理平台'
+	document.title = pageTitle
+	store.commit('SET_IS_SEARCH', false)
+})
\ No newline at end of file

--
Gitblit v1.9.3