Merge pull request 'feat: 官网 + 管理端 + Gin/GORM 后端首个完整版本' (#1) from main into dev #2
@@ -42,7 +42,9 @@ export async function request<T>(
|
|||||||
|
|
||||||
const res = await fetch(path, { ...init, headers })
|
const res = await fetch(path, { ...init, headers })
|
||||||
|
|
||||||
if (res.status === 401) {
|
// 登录接口的 401 是「凭据错误」,交给下方按后端 message 处理;
|
||||||
|
// 其它接口的 401 才视为会话过期:清 token 并跳登录页
|
||||||
|
if (res.status === 401 && !path.includes('/admin/login')) {
|
||||||
clearToken()
|
clearToken()
|
||||||
// basename=/admin,登录路由实际是 /admin/login
|
// basename=/admin,登录路由实际是 /admin/login
|
||||||
if (!window.location.pathname.endsWith('/login')) {
|
if (!window.location.pathname.endsWith('/login')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user