MCPcopy Create free account
hub / github.com/baiwumm/react-admin / logoutToLogin

Function logoutToLogin

Xmw_web/src/utils/index.ts:155–177  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

153 * @Author: 白雾茫茫丶
154 */
155export const logoutToLogin = () => {
156 const { search, pathname } = window.location;
157 // 获取 LOCK_SLEEP 信息
158 const LOCK_SLEEP = getLocalStorageItem<LockSleepTypes>(LOCAL_STORAGE.LOCK_SLEEP)
159 const urlParams = new URL(window.location.href).searchParams;
160 /** 此方法会跳转到 redirect 参数所在的位置 */
161 const redirect = urlParams.get('redirect');
162 // 移除 token
163 removeLocalStorageItem(LOCAL_STORAGE.ACCESS_TOKEN)
164 // 取消睡眠弹窗
165 if (LOCK_SLEEP) {
166 setLocalStorageItem(LOCAL_STORAGE.LOCK_SLEEP, { ...LOCK_SLEEP, isSleep: false })
167 }
168 // 重定向地址
169 if (window.location.pathname !== ROUTES.LOGIN && !redirect) {
170 history.replace({
171 pathname: ROUTES.LOGIN,
172 search: stringify({
173 redirect: pathname + search,
174 }),
175 });
176 }
177}
178
179/**
180 * @description: 获取当前时间

Callers 3

AvatarPropsFunction · 0.90
index.tsFile · 0.90
ChangePasswordFunction · 0.90

Calls 4

getLocalStorageItemFunction · 0.85
removeLocalStorageItemFunction · 0.85
setLocalStorageItemFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected