From e8d37df18e97c367dfe271a4255d8a5f8406ea09 Mon Sep 17 00:00:00 2001 From: huaqiang Date: Wed, 12 Aug 2026 14:33:45 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=20API=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=B8=AD=E5=86=97=E4=BD=99=E7=9A=84=20[key:?= =?UTF-8?q?=20string]:=20unknown=20=E7=B4=A2=E5=BC=95=E7=AD=BE=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - user.ts: 移除 UserProfile、UserInfoVO 的索引签名 - rosCar.ts: 移除 8 个接口的索引签名(RosLift、RosCar、RosInspectionRecord 等) - 遵循"用到就补字段声明"原则,保留完整类型检查 --- src/api/rosCar.ts | 8 -------- src/api/user.ts | 2 -- src/router/routerGuard.ts | 14 +++++++------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/api/rosCar.ts b/src/api/rosCar.ts index e6abffe..803898d 100644 --- a/src/api/rosCar.ts +++ b/src/api/rosCar.ts @@ -21,7 +21,6 @@ export interface RosLift { liftErrorDescription?: string; /** 升降柱高度 */ liftHeight?: number; - [key: string]: unknown; } /** @@ -75,7 +74,6 @@ export interface RosCar { createTime?: string; /** 更新时间 */ updateTime?: string; - [key: string]: unknown; } /** @@ -133,7 +131,6 @@ export interface RosInspectionRecord { createTime?: string; /** 更新时间 */ updateTime?: string; - [key: string]: unknown; } /** @@ -149,7 +146,6 @@ export interface RosInspectionTaskNodeDTO { poseY?: number; /** 节点顺序 */ nodeIndex?: number; - [key: string]: unknown; } /** @@ -161,7 +157,6 @@ export interface RosInspectionTaskRoundDTO { roundIndex?: number; /** 本轮行走方向:forward 正走 / backward 倒走 */ direction?: string; - [key: string]: unknown; } /** @@ -177,7 +172,6 @@ export interface RosInspectionActionDTO { command?: number; /** 动作参数 */ params?: Record; - [key: string]: unknown; } /** @@ -206,7 +200,6 @@ export interface RosInspectionTaskDetailDTO { rounds?: RosInspectionTaskRoundDTO[]; /** 巡检动作模板列表 */ actions?: RosInspectionActionDTO[]; - [key: string]: unknown; } /** @@ -219,7 +212,6 @@ export interface RosDispatchResultDTO { accepted?: boolean; /** 下发结果说明 */ message?: string; - [key: string]: unknown; } /** diff --git a/src/api/user.ts b/src/api/user.ts index b82a504..8815ece 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -33,7 +33,6 @@ export interface UserProfile { phone?: string; /** 状态 */ status?: number; - [key: string]: unknown; } /** @@ -50,7 +49,6 @@ export interface UserInfoVO { permissions?: string[]; /** 用户个人资料 */ profile?: UserProfile; - [key: string]: unknown; } export function getPublicKey() { diff --git a/src/router/routerGuard.ts b/src/router/routerGuard.ts index 56f40ee..4743a6c 100644 --- a/src/router/routerGuard.ts +++ b/src/router/routerGuard.ts @@ -12,30 +12,30 @@ const whiteList = ['/login'] // no redirect whitelist // document.title = title // } // 路由守卫 -router.beforeEach(async (to, from, next) => { +router.beforeEach(async (to, from) => { $loadingBar.start() // setPageTitle(to.meta) const hasToken = getToken() const userStore = useUserStore() if (hasToken) { if (to.path === '/login') { - next({ path: '/' }) $loadingBar.finish() + return { path: '/' } } else { const hasGetUserInfo = userStore.name if (hasGetUserInfo !== '') { - next() + return } else { try { // get user info const infoVO = await userStore.getInfo() - next({ ...to, replace: true }) + return { ...to, replace: true } } catch (error) { await userStore.resetToken() - next(`/login?redirect=${to.path}`) // remove token and go to login page to re-login console.error(error) $loadingBar.error() + return `/login?redirect=${to.path}` } } } @@ -43,10 +43,10 @@ router.beforeEach(async (to, from, next) => { /* has no token */ if (whiteList.indexOf(to.path) !== -1) { // in the free login whitelist, go directly - next() + return } else { - next(`/login?redirect=${to.path}`) $loadingBar.finish() + return `/login?redirect=${to.path}` } } })