fix: 修复引导获取token存储问题
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import Cookies from 'js-cookie';
|
||||
import { localRemove, localSet } from '@/utils/cache-local-utils';
|
||||
import {
|
||||
CACHE_LOCAL_LOCK_PASSWD,
|
||||
CACHE_LOCAL_MASK,
|
||||
} from '@/constants/cache-keys-constants';
|
||||
import {
|
||||
TOKEN_ACCESS_COOKIE,
|
||||
TOKEN_REFRESH_COOKIE,
|
||||
@@ -17,11 +22,14 @@ export function getAccessToken(): string {
|
||||
export function setAccessToken(token: string, exp: number): void {
|
||||
const expires = new Date(new Date().getTime() + exp * 1000);
|
||||
Cookies.set(TOKEN_ACCESS_COOKIE, token, { expires });
|
||||
localSet(CACHE_LOCAL_MASK, 'none');
|
||||
}
|
||||
|
||||
/**移除访问令牌 */
|
||||
export function delAccessToken(): void {
|
||||
Cookies.remove(TOKEN_ACCESS_COOKIE);
|
||||
localRemove(CACHE_LOCAL_MASK);
|
||||
localRemove(CACHE_LOCAL_LOCK_PASSWD);
|
||||
}
|
||||
|
||||
/**获取刷新令牌 */
|
||||
|
||||
@@ -56,9 +56,8 @@ function fnGuideDone() {
|
||||
bootloaderDone()
|
||||
.then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
delAccessToken();
|
||||
delRefreshToken();
|
||||
useAppStore().bootloader = false;
|
||||
delAccessToken();
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
|
||||
@@ -21,7 +21,7 @@ function fnGuideStart() {
|
||||
if (getAccessToken()) return;
|
||||
bootloaderStart().then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS && res.data) {
|
||||
setAccessToken(res.data.accessToken, res.data.refreshExpiresIn);
|
||||
setAccessToken(res.data.accessToken, res.data.expiresIn);
|
||||
} else {
|
||||
router.push({ name: 'Login' });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user