大量的代码格式化
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 1m10s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 1m10s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
This commit is contained in:
@@ -7,7 +7,9 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
const expiresAt = ref(localStorage.getItem('expiresAt') || '')
|
||||
|
||||
const isAuthenticated = computed(() => {
|
||||
if (!token.value || !expiresAt.value) return false
|
||||
if (!token.value || !expiresAt.value) {
|
||||
return false
|
||||
}
|
||||
// 检查token是否过期
|
||||
return new Date(expiresAt.value) > new Date()
|
||||
})
|
||||
@@ -16,13 +18,13 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
try {
|
||||
const response = await request.post('/Auth/Login', { password })
|
||||
const { token: newToken, expiresAt: newExpiresAt } = response.data
|
||||
|
||||
|
||||
token.value = newToken
|
||||
expiresAt.value = newExpiresAt
|
||||
|
||||
|
||||
localStorage.setItem('token', newToken)
|
||||
localStorage.setItem('expiresAt', newExpiresAt)
|
||||
|
||||
|
||||
return true
|
||||
} catch (error) {
|
||||
if (error.response?.status === 401) {
|
||||
@@ -44,6 +46,6 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
expiresAt,
|
||||
isAuthenticated,
|
||||
login,
|
||||
logout,
|
||||
logout
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user