fix: 增加用户角色标识与优化产品页

This commit is contained in:
Gsh
2025-06-29 17:47:07 +08:00
parent 2b7c779e14
commit a33c6dbf1a
6 changed files with 170 additions and 38 deletions

View File

@@ -75,13 +75,22 @@ function jwtPlugin(): HookFetchPlugin<BaseResponse> {
return {
name: 'jwt',
beforeRequest: async (config) => {
config.headers = new Headers(config.headers);
if (userStore.refreshToken) {
config.headers.set('refresh_token', `Bearer ${userStore.refreshToken}`);
}
if (userStore.token) {
config.headers = new Headers(config.headers);
config.headers.set('authorization', `Bearer ${userStore.token}`);
}
return config;
},
afterResponse: async (response) => {
afterResponse: async (response: any) => {
console.log('response.response.headers---', response.response.headers);
if (response.response.headers?.refresh_token) {
userStore.setToken(response.response.headers?.access_token, response.response.headers?.refresh_token);
}
if (response.result?.code === 200)
return response;