refactor: 移除 API 接口中冗余的 [key: string]: unknown 索引签名
- user.ts: 移除 UserProfile、UserInfoVO 的索引签名 - rosCar.ts: 移除 8 个接口的索引签名(RosLift、RosCar、RosInspectionRecord 等) - 遵循"用到就补字段声明"原则,保留完整类型检查
This commit is contained in:
@@ -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}`
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user