修复全量审查问题;接入vitest;精简IdP图标逻辑
CI / test (push) Successful in 46s

This commit is contained in:
2026-07-22 16:51:45 +08:00
parent efcb84eaa8
commit 119f60516c
39 changed files with 1164 additions and 797 deletions
+5 -3
View File
@@ -1,5 +1,5 @@
import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
import { ref } from 'vue'
const TOKEN_KEY = 'oci-portal.token'
const EXPIRES_KEY = 'oci-portal.expiresAt'
@@ -8,11 +8,13 @@ export const useAuthStore = defineStore('auth', () => {
const token = ref(localStorage.getItem(TOKEN_KEY) ?? '')
const expiresAt = ref(localStorage.getItem(EXPIRES_KEY) ?? '')
const isAuthed = computed(() => {
// 普通函数而非 computed:computed 只随 token/expiresAt 失效,时间流逝不会
// 触发重算,令牌自然过期后路由守卫会长期误判仍已登录
function isAuthed(): boolean {
if (!token.value) return false
if (!expiresAt.value) return true
return new Date(expiresAt.value).getTime() > Date.now()
})
}
function setSession(newToken: string, newExpiresAt: string) {
token.value = newToken