😎修复用户菜单为空时无限刷新接口的问题

This commit is contained in:
zuohuaijun 2025-09-14 13:23:36 +08:00
parent 41b8b361cd
commit 381724ab81

View File

@ -10,6 +10,7 @@ import { Session, Local } from '/@/utils/storage';
import { staticRoutes, notFoundAndNoPower } from '/@/router/route';
import { initFrontEndControlRoutes } from '/@/router/frontEnd';
import { initBackEndControlRoutes } from '/@/router/backEnd';
import { clearTokens } from '/@/utils/axios-utils';
/**
* 1isRequestRoutes false roles setFilterRoute
@ -120,7 +121,8 @@ router.beforeEach(async (to, from, next) => {
if (routesList.value.length === 0) {
if (isRequestRoutes) {
// 后端控制路由:路由数据初始化,防止刷新时丢失
await initBackEndControlRoutes();
const isNoPower = await initBackEndControlRoutes();
if (isNoPower) clearTokens();
// 解决刷新时,一直跳 404 页面问题,关联问题 No match found for location with path 'xxx'
// to.query 防止页面刷新时普通路由带参数时参数丢失。动态路由xxx/:id/:name"isDynamic 无需处理
next({ path: to.path, query: to.query });