Explorar el Código

移除portal中无用的首页菜单,默认跳转到用户管理

zengy hace 2 días
padre
commit
1d5993cefa

+ 2 - 1
memory/index.md

@@ -12,7 +12,7 @@
 - 应用入口:`src/main.js`
 - 根组件:`src/App.vue`
 - 路由守卫:`src/permission.js`
-- 路由定义:`src/router/index.js`
+- 路由定义:`src/router/index.js`(总后台默认落地页常量 `DEFAULT_BACKEND_HOME = '/system/user'`,写死的首页菜单已移除)
 - 动态权限路由:`src/store/modules/permission.js`
 - Axios 封装:`src/utils/request.js`
 - Vite 配置:`vite.config.js`
@@ -54,3 +54,4 @@ npm run dev       # 默认 http://localhost:80
 - [2026-08-21:工程技能仓库配置](sessions/2026-08-21.md)
 - [2026-08-22:供水报警与工单前端适配设计](sessions/2026-08-22.md)
 - [2026-09-01:供水管网数据统计分析 T3](sessions/2026-09-01.md)
+- [2026-09-03:移除写死的首页菜单,后台默认落地到用户管理](sessions/2026-09-03.md)

+ 6 - 18
src/components/Breadcrumb/index.vue

@@ -19,18 +19,14 @@ function getBreadcrumb() {
   let matched = route.matched.filter(item => item.meta && item.meta.title);
   const first = matched[0]
 
-  // ===================== 【核心:子系统不显示首页】 =====================
-  const isSubSystem = route.path.startsWith(first.path);
-
-  // const currentPath = route.path
-  // const allRoutes = permissionStore.sidebarRouters
-  // const prefix = currentPath.split('/')[1]
-
-  // 只有【不是子系统】时,才添加首页
-  if (!isDashboard(first) && !isSubSystem) {
-    matched = [{path: '/index', meta: {title: '首页'}}].concat(matched)
+  if (!first) {
+    levelList.value = []
+    return
   }
 
+  // ===================== 【核心:子系统与总后台各自只显示自己的层级】 =====================
+  const isSubSystem = route.path.startsWith(first.path);
+
   // ===================== 【核心:彻底隔离子系统 / 总后台】 =====================
   if (isSubSystem) {
     // 子系统:只保留子系统路由,过滤总后台
@@ -45,14 +41,6 @@ function getBreadcrumb() {
   }
 }
 
-function isDashboard(route) {
-  const name = route && route.name
-  if (!name) {
-    return false
-  }
-  return ['Index', 'MainAdminHome'].includes(name.trim())
-}
-
 function handleLink(item) {
   const {redirect, path} = item
   if (redirect) {

+ 1 - 1
src/layout/components/Navbar.vue

@@ -100,7 +100,7 @@ function logout() {
     type: 'warning'
   }).then(() => {
     userStore.logOut().then(() => {
-      location.href = '/index';
+      location.href = '/';
     })
   }).catch(() => {
   });

+ 1 - 1
src/layout/components/TagsView/index.vue

@@ -276,7 +276,7 @@ function toLastView(visitedViews, view) {
     } else if (prefix === 'dispatch') {
       router.push('/dispatch/index')
     } else {
-      router.push('/index')
+      router.push('/')
     }
   }
 }

+ 7 - 15
src/router/index.js

@@ -32,6 +32,9 @@ import { mergeRouteRecords } from './routeUtils'
  }
  */
 
+// 进入总后台后的默认落地页(原写死的 /index 首页菜单已移除)
+export const DEFAULT_BACKEND_HOME = '/system/user'
+
 // 公共路由
 export const constantRoutes = mergeRouteRecords(
   [
@@ -73,22 +76,11 @@ export const constantRoutes = mergeRouteRecords(
     hidden: true
   },
 
-  // 原若依首页(总后台标记)
+  // 根路径直接落到默认后台页面,不再保留写死的首页菜单
   {
-    path: '',
-    component: Layout,
-    redirect: '/index',
-    meta: { isMainAdmin: true }, // 总后台标记
-    children: [
-      {
-        path: '/index',
-        component: () => import('@/views/index'),
-        // Keep this name unique: backend menu paths such as "index" are also
-        // normalized to the route name "Index" by the dynamic router builder.
-        name: 'MainAdminHome',
-        meta: { title: '首页', icon: 'dashboard', affix: true }
-      }
-    ]
+    path: '/',
+    redirect: DEFAULT_BACKEND_HOME,
+    hidden: true
   },
 
   {

+ 1 - 1
src/utils/request.js

@@ -92,7 +92,7 @@ service.interceptors.response.use(res => {
         ElMessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {
           isRelogin.show = false;
           useUserStore().logOut().then(() => {
-            location.href = '/index';
+            location.href = '/';
           })
       }).catch(() => {
         isRelogin.show = false;

+ 1 - 1
src/views/error/404.vue

@@ -17,7 +17,7 @@
         <div class="bullshit__info">
           对不起,您正在寻找的页面不存在。尝试检查URL的错误,然后按浏览器上的刷新按钮或尝试在我们的应用程序中找到其他内容。
         </div>
-        <router-link to="/index" class="bullshit__return-home">
+        <router-link to="/" class="bullshit__return-home">
           返回首页
         </router-link>
       </div>

+ 2 - 1
src/views/portal/index.vue

@@ -44,6 +44,7 @@
 <script setup lang="ts">
 import { ref, reactive, computed, onMounted, onUnmounted, watch } from 'vue'
 import { useRouter } from 'vue-router'
+import { DEFAULT_BACKEND_HOME } from '@/router'
 import useUserStore from '@/store/modules/user'
 import usePermissionStore from '@/store/modules/permission'
 import { ElMessageBox, ElMessage } from 'element-plus'
@@ -235,7 +236,7 @@ const loadDynamicModules = () => {
 // 进入后台
 // ==============================================
 const enterBackend = () => {
-  router.push('/index')
+  router.push(DEFAULT_BACKEND_HOME)
 }
 
 // ==============================================

+ 1 - 1
src/views/subSystem/drainage/jcsj/jsqc.vue

@@ -357,7 +357,7 @@ function goBack() {
   router.push('/')
 }
 function goAdmin() {
-  router.push('/index')
+  router.push('/')
 }
 
 // ==================== 地图初始化 ====================