fix dashboard statistic and login guard warnings

This commit is contained in:
david
2026-07-29 16:45:17 +08:00
parent 94f6492d6e
commit a6fbb8da21
2 changed files with 15 additions and 8 deletions

View File

@@ -5,9 +5,14 @@ import { useUserStore } from '@/store';
import { isLogin } from '@/utils/auth';
export default function setupUserLoginInfoGuard(router: Router) {
router.beforeEach(async (to, from, next) => {
router.beforeEach(async (to, _from, next) => {
NProgress.start();
const userStore = useUserStore();
// 登录页不需要校验旧令牌,避免后端未启动或令牌过期时重复请求用户资料。
if (to.name === 'login') {
next();
return;
}
if (isLogin()) {
if (userStore.role) {
next();
@@ -15,7 +20,7 @@ export default function setupUserLoginInfoGuard(router: Router) {
try {
await userStore.info();
next();
} catch (error) {
} catch {
await userStore.logout();
next({
name: 'login',
@@ -27,10 +32,6 @@ export default function setupUserLoginInfoGuard(router: Router) {
}
}
} else {
if (to.name === 'login') {
next();
return;
}
next({
name: 'login',
query: {

View File

@@ -4,8 +4,14 @@
<a-grid :cols="{ xs: 1, sm: 2, lg: 4 }" :col-gap="16" :row-gap="16">
<a-grid-item v-for="item in cards" :key="item.key">
<a-card :bordered="false" class="metric-card">
<a-statistic :title="item.label" :value="overview[item.key]" :precision="item.money ? 2 : 0"
:prefix="item.money ? '¥' : undefined" show-group-separator />
<a-statistic
:title="item.label"
:value="overview[item.key]"
:precision="item.money ? 2 : 0"
show-group-separator
>
<template v-if="item.money" #prefix>¥</template>
</a-statistic>
<div class="metric-hint">{{ item.hint }}</div>
</a-card>
</a-grid-item>