From febbb83dad05c73d5c9dc7a8c51629f82af77523 Mon Sep 17 00:00:00 2001 From: zhouyanli <593579392@qq.com> Date: Tue, 13 Oct 2026 08:01:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=AD=E5=BB=BA=E9=A1=B5=E9=9D=A2=E9=AA=A8?= =?UTF-8?q?=E6=9E=B6=EF=BC=8C=E5=86=99=E8=B4=A6=E5=8F=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=92=8C=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 +- .env.production | 4 +- src/components/Breadcrumb/index.vue | 14 +- src/layout/components/Navbar.vue | 8 +- src/layout/components/TagsView/index.vue | 2 +- src/permission.ts | 18 +- src/router/index.ts | 16 +- src/store/modules/permission.ts | 4 +- src/views/error/404.vue | 2 +- src/views/index.vue | 370 ----------------------- src/views/login.vue | 144 +-------- src/views/system/user/index.vue | 207 +++++-------- vite.config.ts | 2 +- 13 files changed, 124 insertions(+), 671 deletions(-) delete mode 100644 src/views/index.vue diff --git a/.env.development b/.env.development index 5bfb9da..40876f3 100644 --- a/.env.development +++ b/.env.development @@ -1,6 +1,6 @@ # 页面标题 -VITE_APP_TITLE = RuoYi-Vue-Plus后台管理系统 -VITE_APP_LOGO_TITLE = RuoYi-Vue-Plus +VITE_APP_TITLE = 水电表充值管理平台 +VITE_APP_LOGO_TITLE = 水电表充值管理平台 # 开发环境配置 VITE_APP_ENV = 'development' diff --git a/.env.production b/.env.production index 45011d8..b56ac61 100644 --- a/.env.production +++ b/.env.production @@ -1,6 +1,6 @@ # 页面标题 -VITE_APP_TITLE = RuoYi-Vue-Plus后台管理系统 -VITE_APP_LOGO_TITLE = RuoYi-Vue-Plus +VITE_APP_TITLE = 水电表充值管理平台 +VITE_APP_LOGO_TITLE = 水电表充值管理平台 # 生产环境配置 VITE_APP_ENV = 'production' diff --git a/src/components/Breadcrumb/index.vue b/src/components/Breadcrumb/index.vue index 791ae5f..5343709 100644 --- a/src/components/Breadcrumb/index.vue +++ b/src/components/Breadcrumb/index.vue @@ -35,16 +35,14 @@ const getBreadcrumb = () => { } else { matched = route.matched.filter(item => item.meta && item.meta.title); } - // 判断是否为首页 - if (!isDashboard(matched[0])) { - matched = [{ path: '/index', meta: { title: '首页' } }].concat(matched); - } levelList.value = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false); }; + const findPathNum = (str, char = '/') => { if (typeof str !== 'string' || str.length === 0) return 0; return str.split(char).length - 1; }; + const getMatched = (pathList, routeList, matched) => { const data = routeList.find(item => item.path == pathList[0] || (item.name += '').toLowerCase() == pathList[0]); if (data) { @@ -55,13 +53,7 @@ const getMatched = (pathList, routeList, matched) => { } } }; -const isDashboard = (route: RouteLocationMatched) => { - const name = route && (route.name as string); - if (!name) { - return false; - } - return name.trim() === 'Index'; -}; + const handleLink = item => { const { redirect, path } = item; redirect ? router.push(redirect) : router.push(path); diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 35eaa12..49d6117 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -25,11 +25,11 @@
diff --git a/src/layout/components/TagsView/index.vue b/src/layout/components/TagsView/index.vue index d687b0c..1863fc0 100644 --- a/src/layout/components/TagsView/index.vue +++ b/src/layout/components/TagsView/index.vue @@ -181,7 +181,7 @@ const isFirstView = () => { return false; } try { - return tag.fullPath === '/index' || tag.fullPath === visitedViews.value[1]?.fullPath; + return tag.fullPath === visitedViews.value[0]?.fullPath; } catch { return false; } diff --git a/src/permission.ts b/src/permission.ts index 9b19c2a..df79c2b 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -49,15 +49,15 @@ router.beforeEach(async (to, from) => { router.addRoute(route); // 动态添加可访问路由表 } }); - // hack方法 确保addRoutes已完成 - return { - path: to.path, - replace: true, - params: to.params, - query: to.query, - hash: to.hash, - name: to.name as string - }; + // hack方法 确保addRoutes已完成: + // 动态路由挂载前解析出的 to 可能只是 404 兜底路由(后台菜单路由此时还没注册), + // 所以这里按 fullPath 重新解析一次,用挂载后的真实路由再走一遍导航 + const resolved = router.resolve(to.fullPath); + // 目标地址确实不存在(如后台菜单还没建 / 历史遗留的已删除地址)时退到默认落点,避免登录后直接落到 404 + if (resolved.name === 'NotFound') { + return { path: '/', replace: true }; + } + return { path: resolved.fullPath, replace: true }; } } else { return true; diff --git a/src/router/index.ts b/src/router/index.ts index 6a6facb..8e3edcd 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -54,6 +54,7 @@ export const constantRoutes: RouteRecordRaw[] = [ }, { path: '/:pathMatch(.*)*', + name: 'NotFound', component: () => import('@/views/error/404.vue'), hidden: true }, @@ -63,17 +64,10 @@ export const constantRoutes: RouteRecordRaw[] = [ hidden: true }, { - path: '', - component: Layout, - redirect: '/index', - children: [ - { - path: '/index', - component: () => import('@/views/index.vue'), - name: 'Index', - meta: { title: '首页', icon: 'dashboard', affix: true } - } - ] + // 无首页:登录后默认落点设备列表(设备路由由后台菜单下发) + path: '/', + redirect: '/device/devicelist', + hidden: true }, { path: '/user', diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index 11016f0..caeb3fe 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -91,7 +91,9 @@ export const usePermissionStore = defineStore('permission', () => { } // Layout ParentView 组件特殊处理 if (route.component?.toString() === 'Layout') { - route.component = Layout; + // 仅一级目录用 Layout。子级菜单若也返回 Layout(后台菜单未配置真实组件路径), + // 再套一层 Layout 会出现“布局里又套一套侧边栏/顶栏”,这里降级为 ParentView + route.component = lastRouter ? ParentView : Layout; } else if (route.component?.toString() === 'ParentView') { route.component = ParentView; } else if (route.component?.toString() === 'InnerLink') { diff --git a/src/views/error/404.vue b/src/views/error/404.vue index f0526f4..49f465e 100644 --- a/src/views/error/404.vue +++ b/src/views/error/404.vue @@ -15,7 +15,7 @@
对不起,您正在寻找的页面不存在。尝试检查URL的错误,然后按浏览器上的刷新按钮或尝试在我们的应用程序中找到其他内容。
- 返回首页 + 返回主页
diff --git a/src/views/index.vue b/src/views/index.vue deleted file mode 100644 index 7934314..0000000 --- a/src/views/index.vue +++ /dev/null @@ -1,370 +0,0 @@ - - - - - diff --git a/src/views/login.vue b/src/views/login.vue index e360dcf..c67483f 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -1,25 +1,6 @@