diff --git a/src/service/api/auth.ts b/src/service/api/auth.ts index 2128128..21a47a2 100644 --- a/src/service/api/auth.ts +++ b/src/service/api/auth.ts @@ -208,7 +208,9 @@ export async function fetchRefreshToken(refreshToken: string): Promise { clearAuthStorage(); - authStore.$reset(); - dictStore.resetDictCache(); - objectContextStore.$reset(); + // setup store 没有内置 $reset,需要显式重置内部状态,避免 token / userInfo 残留导致 isLogin 误判。 + token.value = ''; + Object.assign(userInfo, { + userId: '', + userName: '', + nickname: '', + roles: [], + buttons: [] + }); - if (!route.meta.constant) { + dictStore.resetDictCache(); + objectContextStore.clearContext(); + + // 用路由名判断当前是否已在登录页,避免依赖 route.meta.constant —— + // workbench 等首页也是常量路由,原写法会让常量路由上的登出请求不跳转。 + if (route.name !== 'login') { await toLogin(); } tabStore.cacheTabs(); - routeStore.resetStore(); + await routeStore.resetStore(); } /** Record the user ID of the previous login session Used to compare with the current user ID on next login */ diff --git a/src/store/modules/route/index.ts b/src/store/modules/route/index.ts index b236653..05ceafb 100644 --- a/src/store/modules/route/index.ts +++ b/src/store/modules/route/index.ts @@ -149,9 +149,16 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => { /** 重置 store */ async function resetStore() { - const routeStore = useRouteStore(); - - routeStore.$reset(); + // setup store 没有内置 $reset,需要显式重置内部状态。 + // 否则 isInitConstantRoute / isInitAuthRoute 一直停在 true,导致下面 initConstantRoute 早返, + // 路由被 resetVueRoutes 摘掉后无法重新注册,菜单和导航都会失效。 + setIsInitConstantRoute(false); + setIsInitAuthRoute(false); + constantRoutes.value = []; + authRoutes.value = []; + menus.value = []; + cacheRoutes.value = []; + excludeCacheRoutes.value = []; resetVueRoutes(); diff --git a/src/views/product/list/index.vue b/src/views/product/list/index.vue index 86a2bab..143a5b0 100644 --- a/src/views/product/list/index.vue +++ b/src/views/product/list/index.vue @@ -3,7 +3,7 @@ import { computed, onMounted, reactive, ref } from 'vue'; import type { Component } from 'vue'; import { ElButton, ElTag } from 'element-plus'; import dayjs from 'dayjs'; -import { CircleCheckFilled, DeleteFilled, FolderOpened, VideoPause } from '@element-plus/icons-vue'; +import { Box, DeleteFilled, VideoPause, VideoPlay } from '@element-plus/icons-vue'; import { RDMS_OBJECT_DIRECTION_DICT_CODE } from '@/constants/dict'; import { OBJECT_CONTEXT_QUERY_KEY } from '@/constants/object-context'; import { fetchGetProductOverviewSummary, fetchGetProductPage, fetchGetUserSimpleList } from '@/service/api'; @@ -76,14 +76,14 @@ const statusNavMetas: StatusNavMeta[] = [ label: '启用产品', description: '当前正常服务中的产品', tone: 'teal', - icon: CircleCheckFilled + icon: VideoPlay }, { key: 'archived', label: '归档产品', description: '已完成阶段目标的产品', tone: 'slate', - icon: FolderOpened + icon: Box }, { key: 'paused', @@ -109,7 +109,7 @@ const operateVisible = ref(false); const editingRow = ref(null); const { routerPush } = useRouterPush(); -const { dictData: directionOptions, getLabel: getDirectionDictLabel } = useDict(RDMS_OBJECT_DIRECTION_DICT_CODE); +const { getLabel: getDirectionDictLabel } = useDict(RDMS_OBJECT_DIRECTION_DICT_CODE); const statusCounts = ref>({ active: 0, @@ -129,29 +129,6 @@ const statusItems = computed(() => })) ); -const overviewMetrics = computed(() => [ - { - label: '可见产品', - value: Object.values(statusCounts.value).reduce((sum, count) => sum + count, 0), - hint: '当前接口可查询到的产品总量' - }, - { - label: '当前启用', - value: statusCounts.value.active ?? 0, - hint: '正在持续服务和维护的产品' - }, - { - label: '产品方向', - value: directionOptions.value.length, - hint: '已加载的方向字典项数量' - }, - { - label: '废弃产品', - value: statusCounts.value.abandoned ?? 0, - hint: '已明确停止建设的产品' - } -]); - function getDirectionLabel(directionCode?: string | null) { return getDirectionDictLabel(directionCode, '--'); } @@ -288,7 +265,7 @@ async function handleResetSearch() { async function handleStatusChange(status: Api.Product.ProductStatusCode) { selectedStatus.value = status; - await reloadProductTable(1); + await Promise.all([loadOverviewData(), reloadProductTable(1)]); } function openCreate() { @@ -326,14 +303,6 @@ onMounted(async () => { >
-
-
- {{ item.label }} - {{ item.value }} - {{ item.hint }} -
-
-