From a48ce0cb5483a57c1500e46606c851daa97a19d8 Mon Sep 17 00:00:00 2001 From: sexygoat <1538832180@qq.com> Date: Tue, 28 Apr 2026 14:48:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=A7=E5=88=B6=E5=8F=B0=E5=8A=A0?= =?UTF-8?q?=E6=9D=83=E9=99=90,=E7=99=BB=E5=BD=95=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E8=B5=84=E4=BA=A7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/layouts/art-fast-enter/index.vue | 34 ++++++---- src/router/guards/beforeEach.ts | 5 +- src/router/index.ts | 22 +++++++ src/router/routesAlias.ts | 4 +- src/router/utils/registerRoutes.ts | 17 ++--- .../components/BasicInfoCard.vue | 65 +++++++------------ .../composables/useAssetInfo.ts | 1 - src/views/finance/agent-recharge/index.vue | 7 +- 8 files changed, 83 insertions(+), 72 deletions(-) diff --git a/src/components/core/layouts/art-fast-enter/index.vue b/src/components/core/layouts/art-fast-enter/index.vue index fe2d1f7..65bdc74 100644 --- a/src/components/core/layouts/art-fast-enter/index.vue +++ b/src/components/core/layouts/art-fast-enter/index.vue @@ -56,11 +56,11 @@ import { ref, computed } from 'vue' import { RoutesAlias } from '@/router/routesAlias' import { WEB_LINKS } from '@/utils/constants' - import { useAuth } from '@/composables/useAuth' + import { useUserStore } from '@/store/modules/user' const router = useRouter() const popoverRef = ref() - const { hasAuth } = useAuth() + const userStore = useUserStore() interface Application { name: string @@ -108,36 +108,48 @@ } ] - if (hasAuth('dashboard:console')) { + const menus = userStore.menus.value || [] + + const hasMenuPermission = (permCode: string): boolean => { + const findMenu = (items: any[]): boolean => { + for (const item of items) { + if (item.perm_code === permCode) return true + if (item.children && item.children.length > 0) { + if (findMenu(item.children)) return true + } + } + return false + } + return findMenu(menus) + } + + if (hasMenuPermission('menu:dashboard')) { apps.unshift({ name: '工作台', description: '系统概览与数据统计', icon: '', iconColor: '#377dff', - path: RoutesAlias.Dashboard, - permission: 'dashboard:console' + path: RoutesAlias.Dashboard }) } - if (hasAuth('dashboard:analysis')) { + if (hasMenuPermission('menu:analysis')) { apps.unshift({ name: '分析页', description: '数据分析与可视化', icon: '', iconColor: '#ff3b30', - path: RoutesAlias.Analysis, - permission: 'dashboard:analysis' + path: RoutesAlias.Analysis }) } - if (hasAuth('dashboard:ecommerce')) { + if (hasMenuPermission('menu:ecommerce')) { apps.unshift({ name: '电子商务', description: '电商数据统计', icon: '', iconColor: '#00b42a', - path: RoutesAlias.Ecommerce, - permission: 'dashboard:ecommerce' + path: RoutesAlias.Ecommerce }) } diff --git a/src/router/guards/beforeEach.ts b/src/router/guards/beforeEach.ts index 18c60db..70754b2 100644 --- a/src/router/guards/beforeEach.ts +++ b/src/router/guards/beforeEach.ts @@ -274,12 +274,15 @@ async function processBackendMenu(router: Router): Promise { /** * 合并默认菜单 * 将配置的默认菜单合并到后端返回的菜单中 + * 注意: /dashboard 及其子路由(console/analysis/ecommerce)不再作为默认菜单强制显示 + * 这些路由只有在后端 menus 中返回时才会显示 */ function mergeDefaultMenus( backendMenus: AppRouteRecord[], routeMap: Map ): AppRouteRecord[] { - const defaultMenuPaths = ['/dashboard'] + // 移除 /dashboard 作为默认菜单,现在仪表台路由完全由后端控制 + const defaultMenuPaths: string[] = [] const defaultMenus: AppRouteRecord[] = defaultMenuPaths .map((path) => { diff --git a/src/router/index.ts b/src/router/index.ts index 5859a5e..6d95146 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -12,6 +12,28 @@ export const router = createRouter({ scrollBehavior: () => ({ left: 0, top: 0 }) // 滚动行为 }) +// 处理路由错误(Chunk 加载失败等) +router.onError((error) => { + const pattern = /Loading chunk (\d+) failed|Failed to fetch dynamically imported module|Couldn't resolve component/ + const isChunkLoadFailed = error.message && pattern.test(error.message) + + if (isChunkLoadFailed) { + const key = '__route_chunk_reload__' + const hasReloaded = sessionStorage.getItem(key) + + if (!hasReloaded) { + console.warn('检测到 chunk 加载失败,尝试刷新页面...') + sessionStorage.setItem(key, '1') + window.location.reload() + } else { + console.error('页面刷新后仍然无法加载组件,请联系管理员') + sessionStorage.removeItem(key) + } + } else { + console.error('[路由错误]:', error) + } +}) + // 初始化路由 export function initRouter(app: App): void { configureNProgress() // 顶部进度条 diff --git a/src/router/routesAlias.ts b/src/router/routesAlias.ts index a7bc7ac..a83f1a9 100644 --- a/src/router/routesAlias.ts +++ b/src/router/routesAlias.ts @@ -105,5 +105,5 @@ export enum RoutesAlias { Calendar = '/template/calendar' // 日历 } -// 主页路由 -export const HOME_PAGE = RoutesAlias.Dashboard +// 主页路由 - 修改为资产信息页面 +export const HOME_PAGE = RoutesAlias.AssetInformation diff --git a/src/router/utils/registerRoutes.ts b/src/router/utils/registerRoutes.ts index c5b07b6..4c19893 100644 --- a/src/router/utils/registerRoutes.ts +++ b/src/router/utils/registerRoutes.ts @@ -98,17 +98,13 @@ function checkDuplicateRoutes(routes: AppRouteRecord[], parentPath = ''): void { * 获取组件路径的字符串表示 */ function getComponentPathString(component: any): string { + // 只处理字符串类型的组件路径 if (typeof component === 'string') { return component } - // 对于其他别名路由,获取组件名称 - for (const key in RoutesAlias) { - if (RoutesAlias[key as keyof typeof RoutesAlias] === component) { - return `RoutesAlias.${key}` - } - } - + // 对于函数类型的组件(懒加载),返回空字符串 + // 因为这些组件已经是有效的组件定义,不需要再次处理 return '' } @@ -250,9 +246,8 @@ function handleNormalRoute( routeName: string ): void { if (component) { - const aliasComponent = RoutesAlias[ - component as keyof typeof RoutesAlias - ] as unknown as RouteRecordRaw['component'] - converted.component = aliasComponent || loadComponent(component as string, routeName) + // 直接使用 loadComponent 加载组件 + // component 参数是路由路径(如 "/system/role"),loadComponent 会将其转换为组件导入路径 + converted.component = loadComponent(component as string, routeName) } } diff --git a/src/views/asset-management/asset-information/components/BasicInfoCard.vue b/src/views/asset-management/asset-information/components/BasicInfoCard.vue index a5e1ad2..75937d3 100644 --- a/src/views/asset-management/asset-information/components/BasicInfoCard.vue +++ b/src/views/asset-management/asset-information/components/BasicInfoCard.vue @@ -86,7 +86,7 @@ @@ -254,11 +248,6 @@ {{ deviceRealtime.online_status === 1 ? '在线' : '离线' }} - - - {{ deviceRealtime.status === 1 ? '正常' : '禁用' }} - - {{ deviceRealtime.battery_level !== null && deviceRealtime.battery_level !== undefined @@ -288,15 +277,11 @@ {{ deviceRealtime.rsrq ? `${deviceRealtime.rsrq} dB` : '-' }} - {{ deviceRealtime.sinr ? `${deviceRealtime.sinr} dB` : '-' }} - - {{ deviceRealtime.max_clients || '-' }} - - - {{ deviceRealtime.current_iccid || '-' }} + + {{ deviceRealtime.client_number }} / {{ deviceRealtime.max_clients }} @@ -326,9 +311,6 @@ {{ deviceRealtime.mac_address || '-' }} - - {{ deviceRealtime.imei || '-' }} - {{ deviceRealtime.imsi || '-' }} @@ -353,9 +335,6 @@ {{ deviceRealtime.sync_interval ? `${deviceRealtime.sync_interval} 秒` : '-' }} - - {{ deviceRealtime.device_id || '-' }} - {{ formatDateTime(deviceRealtime.last_update_time) || '-' }} diff --git a/src/views/asset-management/asset-information/composables/useAssetInfo.ts b/src/views/asset-management/asset-information/composables/useAssetInfo.ts index ef8d2a9..02c4141 100644 --- a/src/views/asset-management/asset-information/composables/useAssetInfo.ts +++ b/src/views/asset-management/asset-information/composables/useAssetInfo.ts @@ -318,7 +318,6 @@ export function useAssetInfo() { // 设备实时信息(Gateway 数据) if (data.device_realtime !== undefined) { deviceRealtime.value = data.device_realtime - console.log('设备实时信息:', deviceRealtime.value) } } } diff --git a/src/views/finance/agent-recharge/index.vue b/src/views/finance/agent-recharge/index.vue index 9186068..4c4d565 100644 --- a/src/views/finance/agent-recharge/index.vue +++ b/src/views/finance/agent-recharge/index.vue @@ -39,7 +39,8 @@ :total="pagination.total" :marginTop="10" :actions="getActions" - :actionsWidth="120" + :inlineActionsCount="2" + :actionsWidth="200" @size-change="handleSizeChange" @current-change="handleCurrentChange" > @@ -126,14 +127,14 @@ {{ currentRecharge?.recharge_no }}