2023-09-03 21:05:22 +08:00
|
|
|
const TOKEN_STORAGE_KEY = 'jsonwebtoken';
|
|
|
|
|
|
|
|
export function getJWT(): string | null {
|
|
|
|
const token = window.localStorage.getItem(TOKEN_STORAGE_KEY);
|
|
|
|
|
|
|
|
return token ?? null;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setJWT(jwt: string) {
|
|
|
|
window.localStorage.setItem(TOKEN_STORAGE_KEY, jwt);
|
|
|
|
}
|
2023-10-20 23:12:42 +08:00
|
|
|
|
|
|
|
export function clearJWT() {
|
|
|
|
window.localStorage.removeItem(TOKEN_STORAGE_KEY);
|
|
|
|
}
|