feat: add SingleRecordMnt component for student record maintenance with search, add, edit, view, and delete functionalities
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { ref } from 'vue'
|
||||
|
||||
// Token Service
|
||||
//
|
||||
// 設計重點:
|
||||
// - 單一來源(Single Source of Truth):用 ref 維護 token,並同步 localStorage
|
||||
// - Store 與 Interceptor 只透過此 service 讀寫 token,避免來源分裂
|
||||
|
||||
const storageKey = 'token'
|
||||
const tokenRef = ref<string | null>(localStorage.getItem(storageKey))
|
||||
|
||||
export const tokenService = {
|
||||
token: tokenRef,
|
||||
getToken() {
|
||||
return tokenRef.value
|
||||
},
|
||||
setToken(nextToken: string) {
|
||||
tokenRef.value = nextToken
|
||||
localStorage.setItem(storageKey, nextToken)
|
||||
},
|
||||
clearToken() {
|
||||
tokenRef.value = null
|
||||
localStorage.removeItem(storageKey)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user