ai-coding
2026-07-24 812f73689c0edb43948a41047d44e5a48d86bfbe
fix: 从无权限->有权限时,残留无权限页tab

Co-Authored-By: 王心悦 <wangxy84@xiaopeng.com>
2个文件已修改
10 ■■■■■ 已修改文件
src/router/routes.static.ts 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/no-permission/index.vue 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/routes.static.ts
@@ -9,6 +9,9 @@
    componentPath: '/no-permission/index.vue',
    id: 9999,
    hide: true,
    /* 无权限页是权限缺失时的临时落地页,权限就绪就自动跳走,不应留下 tab;
       否则用户从「无权限 → 有权限」跳到首页后,tab 栏里会残留一个「无权限」标签。 */
    withoutTab: true,
    pid: null,
  },
  {
src/views/no-permission/index.vue
@@ -2,12 +2,13 @@
import { onBeforeUnmount, onMounted, ref } from 'vue'
import { fetchPermissionGuide } from '@/service/api/system'
import { fetchSysUserInfo } from '@/service/api/account'
import { useAuthStore, useRouteStore } from '@/store'
import { useAuthStore, useRouteStore, useTabStore } from '@/store'
import { local } from '@/utils'
import noPermissionBg from '@/assets/no-permission-bg.jpg'
const authStore = useAuthStore()
const routeStore = useRouteStore()
const tabStore = useTabStore()
const guideLink = ref('')
let pollingTimer: ReturnType<typeof setInterval> | null = null
@@ -61,6 +62,10 @@
        clearInterval(pollingTimer)
        pollingTimer = null
      }
      // 清空 tab 状态:tabStore 用 sessionStorage 持久化,整页刷新不会清;
      // 若不主动清,历史上添加过的 /no-permission 页签会残留到首页 tab 栏旁边。
      // 首页作为 pinTab 会在下次进入时由路由守卫自动补回,无需担心丢失。
      tabStore.clearAllTabs()
      window.location.href = '/'
    }
    // 仍无可访问菜单:留在无权限页,继续静默轮询,不再整页刷新