diff --git a/src/layout/navBars/breadcrumb/user.vue b/src/layout/navBars/breadcrumb/user.vue index 883c8f2..ff02220 100644 --- a/src/layout/navBars/breadcrumb/user.vue +++ b/src/layout/navBars/breadcrumb/user.vue @@ -180,8 +180,8 @@ export default defineComponent({ .then(async () => { // 清除缓存/token等 Session.clear(); - // 使用 reload 时,不需要调用 resetRoute() 重置路由 - window.location.reload(); + // 显式回到登录页,避免保留之前受保护页面的重定向参数 + await router.replace('/login'); }) .catch(() => {}); } else if (path === 'wareHouse') { diff --git a/src/router/backEnd.ts b/src/router/backEnd.ts index 6ba1424..1b53750 100644 --- a/src/router/backEnd.ts +++ b/src/router/backEnd.ts @@ -4,14 +4,12 @@ import { useUserInfo } from '/@/stores/userInfo'; import { useRequestOldRoutes } from '/@/stores/requestOldRoutes'; import { Session } from '/@/utils/storage'; import { NextLoading } from '/@/utils/loading'; -import { dynamicRoutes, notFoundAndNoPower } from '/@/router/route'; +import { dynamicRoutes, defaultDynamicRouteChildren, notFoundAndNoPower } from '/@/router/route'; import { formatTwoStageRoutes, formatFlatteningRoutes, router } from '/@/router/index'; import { useRoutesList } from '/@/stores/routesList'; import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes'; import { getUserMenus } from '/@/api/system/menu/index'; - - const layouModules: any = import.meta.glob('../layout/routerView/*.{vue,tsx}'); const viewsModules: any = import.meta.glob('../views/**/*.{vue,tsx}'); @@ -43,11 +41,12 @@ export async function initBackEndControlRoutes() { await useUserInfo().setPermissions(); // 获取路由菜单数据 await getBackEndControlRoutes(); - let menuRoute = Session.get('userMenu') + let menuRoute = Session.get('userMenu'); // 存储接口原始路由(未处理component),根据需求选择使用 useRequestOldRoutes().setRequestOldRoutes(JSON.parse(JSON.stringify(menuRoute))); // 处理路由(component),替换 dynamicRoutes(/@/router/route)第一个顶级 children 的路由 - dynamicRoutes[0].children?.push(...await backEndComponent(menuRoute)); + dynamicRoutes[0].children = [...defaultDynamicRouteChildren]; + dynamicRoutes[0].children?.push(...(await backEndComponent(menuRoute))); // 添加动态路由 await setAddRoute(); // 设置路由到 vuex routesList 中(已处理成多级嵌套路由)及缓存多级嵌套数组处理后的一维数组 @@ -104,10 +103,10 @@ export async function setAddRoute() { * @returns 返回后端路由菜单数据 */ export async function getBackEndControlRoutes() { - let menuRoute = Session.get('userMenu') - let permissions = Session.get('permissions') + let menuRoute = Session.get('userMenu'); + let permissions = Session.get('permissions'); if (!menuRoute || !permissions) { - await refreshBackEndControlRoutes() + await refreshBackEndControlRoutes(); } } @@ -118,11 +117,11 @@ export async function getBackEndControlRoutes() { */ export async function refreshBackEndControlRoutes() { // 获取路由 - await getUserMenus().then((res:any)=>{ - Session.set('userMenu',res.data.menuList) - Session.set('permissions',res.data.permissions) - }) - await useUserInfo().setPermissions() + await getUserMenus().then((res: any) => { + Session.set('userMenu', res.data.menuList); + Session.set('permissions', res.data.permissions); + }); + await useUserInfo().setPermissions(); } /** @@ -140,16 +139,16 @@ export function setBackEndControlRefreshRoutes() { * @returns 返回处理成函数后的 component */ export function backEndComponent(routes: any) { - if (!routes) return; + if (!routes) return []; return routes.map((item: any) => { - if(item.children&&item.children.length>0){ - item.children.some((ci:any)=>{ - if(!ci.meta.isHide){ - item.redirect = ci - return true + if (item.children && item.children.length > 0) { + item.children.some((ci: any) => { + if (!ci.meta.isHide) { + item.redirect = ci; + return true; } - return false - }) + return false; + }); } if (item.component) item.component = dynamicImport(dynamicViewsModules, item.component as string); item.children && backEndComponent(item.children); diff --git a/src/router/route.ts b/src/router/route.ts index c3d7fc8..de53623 100644 --- a/src/router/route.ts +++ b/src/router/route.ts @@ -21,6 +21,39 @@ import { RouteRecordRaw } from 'vue-router'; * @description 各字段请查看 `/@/views/system/menu/component/addMenu.vue 下的 ruleForm` * @returns 返回路由菜单数据 */ +export const defaultDynamicRouteChildren: Array = [ + { + path: '/home', + name: 'home', + component: () => import('/@/views/home/index.vue'), + meta: { + title: 'message.router.home', + isLink: '', + isHide: true, + isKeepAlive: true, + isAffix: true, + isIframe: false, + roles: ['admin', 'common'], + icon: 'iconfont icon-shouye', + }, + }, + { + path: '/personal', + name: 'personals', + component: () => import('/@/views/system/personal/index.vue'), + meta: { + title: '个人中心', + isLink: '', + isHide: true, + isKeepAlive: true, + isAffix: false, + isIframe: false, + roles: ['admin'], + icon: 'iconfont icon-diannao', + }, + }, +]; + export const dynamicRoutes: Array = [ { path: '/', @@ -30,38 +63,7 @@ export const dynamicRoutes: Array = [ meta: { isKeepAlive: true, }, - children: [ - { - path: '/home', - name: 'home', - component: () => import('/@/views/home/index.vue'), - meta: { - title: 'message.router.home', - isLink: '', - isHide: true, - isKeepAlive: true, - isAffix: true, - isIframe: false, - roles: ['admin', 'common'], - icon: 'iconfont icon-shouye', - }, - }, - { - path: '/personal', - name: 'personals', - component: () => import('/@/views/system/personal/index.vue'), - meta: { - title: '个人中心', - isLink: '', - isHide: true, - isKeepAlive: true, - isAffix: false, - isIframe: false, - roles: ['admin'], - icon: 'iconfont icon-diannao', - }, - }, - ], + children: [...defaultDynamicRouteChildren], }, ]; diff --git a/src/utils/request.ts b/src/utils/request.ts index 96f5df1..ed1c693 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -72,9 +72,9 @@ const performLogout = () => { Session.clear(); localStorage.clear(); isHandlingTokenExpired = false; - // 跳转到后台管理登录页,确保完全刷新 + // Hash 路由统一回登录页,避免跳到错误地址 setTimeout(() => { - window.location.href = '/login'; + window.location.href = '/#/login'; }, 500); }; diff --git a/src/views/trade/operation/stats/shop/index.vue b/src/views/trade/operation/stats/shop/index.vue index 8a779c4..046bda4 100644 --- a/src/views/trade/operation/stats/shop/index.vue +++ b/src/views/trade/operation/stats/shop/index.vue @@ -6,18 +6,15 @@ 店铺维度统计 - -
- - -
-
-
+ + + + + + + + @@ -42,6 +86,15 @@
+ +
+ + +
+
+
@@ -73,19 +126,85 @@
+ +
+ + + + + + + + + + + + + + + + +