()
| 153 | * @Author: 白雾茫茫丶 |
| 154 | */ |
| 155 | export 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: 获取当前时间 |
no test coverage detected