refactor: 移除 API 接口中冗余的 [key: string]: unknown 索引签名

- user.ts: 移除 UserProfile、UserInfoVO 的索引签名
- rosCar.ts: 移除 8 个接口的索引签名(RosLift、RosCar、RosInspectionRecord 等)
- 遵循"用到就补字段声明"原则,保留完整类型检查
This commit is contained in:
2026-08-12 14:33:45 +08:00
parent 61e105def2
commit e8d37df18e
3 changed files with 7 additions and 17 deletions

View File

@@ -21,7 +21,6 @@ export interface RosLift {
liftErrorDescription?: string; liftErrorDescription?: string;
/** 升降柱高度 */ /** 升降柱高度 */
liftHeight?: number; liftHeight?: number;
[key: string]: unknown;
} }
/** /**
@@ -75,7 +74,6 @@ export interface RosCar {
createTime?: string; createTime?: string;
/** 更新时间 */ /** 更新时间 */
updateTime?: string; updateTime?: string;
[key: string]: unknown;
} }
/** /**
@@ -133,7 +131,6 @@ export interface RosInspectionRecord {
createTime?: string; createTime?: string;
/** 更新时间 */ /** 更新时间 */
updateTime?: string; updateTime?: string;
[key: string]: unknown;
} }
/** /**
@@ -149,7 +146,6 @@ export interface RosInspectionTaskNodeDTO {
poseY?: number; poseY?: number;
/** 节点顺序 */ /** 节点顺序 */
nodeIndex?: number; nodeIndex?: number;
[key: string]: unknown;
} }
/** /**
@@ -161,7 +157,6 @@ export interface RosInspectionTaskRoundDTO {
roundIndex?: number; roundIndex?: number;
/** 本轮行走方向forward 正走 / backward 倒走 */ /** 本轮行走方向forward 正走 / backward 倒走 */
direction?: string; direction?: string;
[key: string]: unknown;
} }
/** /**
@@ -177,7 +172,6 @@ export interface RosInspectionActionDTO {
command?: number; command?: number;
/** 动作参数 */ /** 动作参数 */
params?: Record<string, unknown>; params?: Record<string, unknown>;
[key: string]: unknown;
} }
/** /**
@@ -206,7 +200,6 @@ export interface RosInspectionTaskDetailDTO {
rounds?: RosInspectionTaskRoundDTO[]; rounds?: RosInspectionTaskRoundDTO[];
/** 巡检动作模板列表 */ /** 巡检动作模板列表 */
actions?: RosInspectionActionDTO[]; actions?: RosInspectionActionDTO[];
[key: string]: unknown;
} }
/** /**
@@ -219,7 +212,6 @@ export interface RosDispatchResultDTO {
accepted?: boolean; accepted?: boolean;
/** 下发结果说明 */ /** 下发结果说明 */
message?: string; message?: string;
[key: string]: unknown;
} }
/** /**

View File

@@ -33,7 +33,6 @@ export interface UserProfile {
phone?: string; phone?: string;
/** 状态 */ /** 状态 */
status?: number; status?: number;
[key: string]: unknown;
} }
/** /**
@@ -50,7 +49,6 @@ export interface UserInfoVO {
permissions?: string[]; permissions?: string[];
/** 用户个人资料 */ /** 用户个人资料 */
profile?: UserProfile; profile?: UserProfile;
[key: string]: unknown;
} }
export function getPublicKey() { export function getPublicKey() {

View File

@@ -12,30 +12,30 @@ const whiteList = ['/login'] // no redirect whitelist
// document.title = title // document.title = title
// } // }
// 路由守卫 // 路由守卫
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from) => {
$loadingBar.start() $loadingBar.start()
// setPageTitle(to.meta) // setPageTitle(to.meta)
const hasToken = getToken() const hasToken = getToken()
const userStore = useUserStore() const userStore = useUserStore()
if (hasToken) { if (hasToken) {
if (to.path === '/login') { if (to.path === '/login') {
next({ path: '/' })
$loadingBar.finish() $loadingBar.finish()
return { path: '/' }
} else { } else {
const hasGetUserInfo = userStore.name const hasGetUserInfo = userStore.name
if (hasGetUserInfo !== '') { if (hasGetUserInfo !== '') {
next() return
} else { } else {
try { try {
// get user info // get user info
const infoVO = await userStore.getInfo() const infoVO = await userStore.getInfo()
next({ ...to, replace: true }) return { ...to, replace: true }
} catch (error) { } catch (error) {
await userStore.resetToken() await userStore.resetToken()
next(`/login?redirect=${to.path}`)
// remove token and go to login page to re-login // remove token and go to login page to re-login
console.error(error) console.error(error)
$loadingBar.error() $loadingBar.error()
return `/login?redirect=${to.path}`
} }
} }
} }
@@ -43,10 +43,10 @@ router.beforeEach(async (to, from, next) => {
/* has no token */ /* has no token */
if (whiteList.indexOf(to.path) !== -1) { if (whiteList.indexOf(to.path) !== -1) {
// in the free login whitelist, go directly // in the free login whitelist, go directly
next() return
} else { } else {
next(`/login?redirect=${to.path}`)
$loadingBar.finish() $loadingBar.finish()
return `/login?redirect=${to.path}`
} }
} }
}) })