mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
fix(projects): 修复登录的重定向地址
This commit is contained in:
@ -1,2 +1,2 @@
|
||||
export { getToken, setToken, removeToken, getUserInfo, getLoginModuleRegExp } from './user';
|
||||
export { getLoginRedirectUrl, toLoginRedirectUrl, toHomeByLocation } from './location';
|
||||
export { getToken, setToken, removeToken, getUserInfo, resetAuthStorage, getLoginModuleRegExp } from './user';
|
||||
export { getLoginRedirectUrl, toLoginRedirectUrl } from './location';
|
||||
|
@ -7,8 +7,3 @@ export function getLoginRedirectUrl() {
|
||||
export function toLoginRedirectUrl(redirectUrl: string) {
|
||||
window.location.href = redirectUrl;
|
||||
}
|
||||
|
||||
/** 回到首页 */
|
||||
export function toHomeByLocation() {
|
||||
window.location.href = '/';
|
||||
}
|
||||
|
@ -3,21 +3,43 @@ import type { LoginModuleType } from '@/interface';
|
||||
import { setLocal, getLocal, removeLocal } from '../storage';
|
||||
|
||||
/** 设置token */
|
||||
export function getToken() {
|
||||
return getLocal<string>(EnumStorageKey.token) || '';
|
||||
}
|
||||
|
||||
/** 获取token */
|
||||
export function setToken(token: string) {
|
||||
setLocal(EnumStorageKey.token, token);
|
||||
}
|
||||
|
||||
/** 获取token */
|
||||
export function getToken() {
|
||||
return getLocal<string>(EnumStorageKey.token) || '';
|
||||
}
|
||||
|
||||
/** 去除token */
|
||||
export function removeToken() {
|
||||
removeLocal(EnumStorageKey.token);
|
||||
}
|
||||
|
||||
/** 获取refresh token */
|
||||
export function getRefreshToken() {
|
||||
return getLocal<string>(EnumStorageKey['refresh-koken']) || '';
|
||||
}
|
||||
|
||||
/** 设置refresh token */
|
||||
export function setRefreshToken(token: string) {
|
||||
setLocal(EnumStorageKey['refresh-koken'], token);
|
||||
}
|
||||
|
||||
/** 去除refresh token */
|
||||
export function removeRefreshToken() {
|
||||
removeLocal(EnumStorageKey['refresh-koken']);
|
||||
}
|
||||
|
||||
export function getUserInfo() {}
|
||||
|
||||
/** 去除用户相关缓存 */
|
||||
export function resetAuthStorage() {
|
||||
removeToken();
|
||||
removeRefreshToken();
|
||||
}
|
||||
|
||||
/** 获取登录模块的正则字符串 */
|
||||
export function getLoginModuleRegExp() {
|
||||
const arr: LoginModuleType[] = ['pwd-login', 'code-login', 'register', 'reset-pwd', 'bind-wechat'];
|
||||
|
@ -3,10 +3,10 @@ export {
|
||||
getToken,
|
||||
removeToken,
|
||||
getUserInfo,
|
||||
resetAuthStorage,
|
||||
getLoginModuleRegExp,
|
||||
getLoginRedirectUrl,
|
||||
toLoginRedirectUrl,
|
||||
toHomeByLocation
|
||||
toLoginRedirectUrl
|
||||
} from './auth';
|
||||
|
||||
export {
|
||||
@ -26,4 +26,13 @@ export {
|
||||
dynamicIconRender
|
||||
} from './common';
|
||||
|
||||
export { setLocal, getLocal, setSession, getSession } from './storage';
|
||||
export {
|
||||
setLocal,
|
||||
getLocal,
|
||||
removeLocal,
|
||||
clearLocal,
|
||||
setSession,
|
||||
getSession,
|
||||
removeSession,
|
||||
clearSession
|
||||
} from './storage';
|
||||
|
@ -1,2 +1,2 @@
|
||||
export { setLocal, getLocal, removeLocal } from './local';
|
||||
export { setSession, getSession } from './session';
|
||||
export { setLocal, getLocal, removeLocal, clearLocal } from './local';
|
||||
export { setSession, getSession, removeSession, clearSession } from './session';
|
||||
|
@ -14,3 +14,7 @@ export function getLocal<T>(key: string) {
|
||||
export function removeLocal(key: string) {
|
||||
window.localStorage.removeItem(key);
|
||||
}
|
||||
|
||||
export function clearLocal() {
|
||||
window.localStorage.clear();
|
||||
}
|
||||
|
@ -10,3 +10,11 @@ export function getSession<T>(key: string) {
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
export function removeSession(key: string) {
|
||||
window.sessionStorage.removeItem(key);
|
||||
}
|
||||
|
||||
export function clearSession() {
|
||||
window.sessionStorage.clear();
|
||||
}
|
||||
|
Reference in New Issue
Block a user