1
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
const AUTH_TOKEN_KEY = 'token';
|
||||
const MOCK_TOKEN = 'mock-extension-token';
|
||||
|
||||
/**
|
||||
* 获取当前登录 token。
|
||||
@@ -16,13 +15,6 @@ export async function getToken(): Promise<string | null> {
|
||||
return window.localStorage.getItem(AUTH_TOKEN_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟登录,写入一个临时 token,方便后续替换真实登录逻辑。
|
||||
*/
|
||||
export async function mockLogin(): Promise<string> {
|
||||
await setToken(MOCK_TOKEN);
|
||||
return MOCK_TOKEN;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除当前登录 token。
|
||||
@@ -34,11 +26,12 @@ export async function logout(): Promise<void> {
|
||||
await storage.remove(AUTH_TOKEN_KEY);
|
||||
return;
|
||||
}
|
||||
console.log("溢出")
|
||||
|
||||
window.localStorage.removeItem(AUTH_TOKEN_KEY);
|
||||
}
|
||||
|
||||
async function setToken(token: string): Promise<void> {
|
||||
export async function setToken(token: string): Promise<void> {
|
||||
const storage = getChromeStorage();
|
||||
|
||||
if (storage) {
|
||||
|
||||
Reference in New Issue
Block a user