fix: 员工端 portalAxios 缺少 response interceptor 导致登录失败
问题:portalAxios 没有 response interceptor,axios 返回完整的
response 对象,unwrap 取 res.data 得到的是 { success, data: {...} }
而非 { token, employee },导致前端 data.token 为 undefined,
自动登录/密码登录/验证码登录全部失败。
修复:给 portalAxios 添加与管理端 api 实例一致的 response
interceptor:(response) => response.data,使 unwrap 能正确
解包到 { token, employee }。
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1005,6 +1005,11 @@ portalAxios.interceptors.request.use((config: any) => {
|
||||
if (token) config.headers.Authorization = `Bearer ${token}`
|
||||
return config
|
||||
})
|
||||
// 与管理端 api 实例一致:response interceptor 返回 response.data(后端 JSON body)
|
||||
portalAxios.interceptors.response.use(
|
||||
(response) => response.data,
|
||||
(error) => Promise.reject(error),
|
||||
)
|
||||
const portalGet = ((url: string, config?: any) => portalAxios.get(url, config)) as any
|
||||
const portalPost = ((url: string, data?: any, config?: any) => portalAxios.post(url, data, config)) as any
|
||||
|
||||
|
||||
Reference in New Issue
Block a user