feat: connect admin session and public config endpoints

This commit is contained in:
Lan
2026-06-03 02:52:38 +08:00
parent 32cbc10cd8
commit c6f33096be
7 changed files with 83 additions and 7 deletions
+35
View File
@@ -0,0 +1,35 @@
import { AuthService } from '@/services'
import { useAdminStore } from '@/stores/adminStore'
export function useAdminSession() {
const adminStore = useAdminStore()
const verifySession = async () => {
if (!adminStore.hasToken) return false
try {
const response = await AuthService.verifyToken()
if (response.code === 200 && response.detail?.token) {
adminStore.login(response.detail)
return true
}
} catch {
adminStore.logout()
}
return false
}
const logout = async () => {
try {
await AuthService.logout()
} finally {
adminStore.logout()
}
}
return {
verifySession,
logout
}
}