refactor(projects): 代码优化
This commit is contained in:
parent
f42ee9dbe5
commit
4e31abd446
@ -80,11 +80,11 @@ const apis: MockMethod[] = [
|
||||
{
|
||||
url: '/mock/updateToken',
|
||||
method: 'post',
|
||||
response: (): Service.MockServiceResult<string> => {
|
||||
response: (): Service.MockServiceResult<ApiAuth.Token> => {
|
||||
return {
|
||||
code: 200,
|
||||
message: 'ok',
|
||||
data: token.token
|
||||
data: token
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -36,10 +36,10 @@ export function fetchUserRoutes(userId: string) {
|
||||
return mockRequest.post<ApiRoute.Route>('/getUserRoutes', { userId });
|
||||
}
|
||||
|
||||
export function fetchTestToken() {
|
||||
return mockRequest.post('/testToken', { userName: 'Soybean' });
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
* @param refreshToken
|
||||
*/
|
||||
export function fetchUpdateToken(refreshToken: string) {
|
||||
return mockRequest.post('/updateToken', { refreshToken });
|
||||
return mockRequest.post<ApiAuth.Token>('/updateToken', { refreshToken });
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import axios from 'axios';
|
||||
import type { AxiosRequestConfig, AxiosInstance, AxiosError } from 'axios';
|
||||
import { REQUEST_TIMEOUT, REFRESH_TOKEN_CODE } from '@/config';
|
||||
import { REFRESH_TOKEN_CODE } from '@/config';
|
||||
import {
|
||||
getToken,
|
||||
transformRequestData,
|
||||
@ -23,7 +23,7 @@ export default class CustomAxiosInstance {
|
||||
/**
|
||||
*
|
||||
* @param axiosConfig - axios配置
|
||||
* @param backendSuccessCode - 后端业务上定义的成功请求的状态码
|
||||
* @param backendConfig - 后端返回的数据配置
|
||||
*/
|
||||
constructor(
|
||||
axiosConfig: AxiosRequestConfig,
|
||||
@ -35,11 +35,7 @@ export default class CustomAxiosInstance {
|
||||
}
|
||||
) {
|
||||
this.backendConfig = backendConfig;
|
||||
const defaultConfig: AxiosRequestConfig = {
|
||||
timeout: REQUEST_TIMEOUT
|
||||
};
|
||||
Object.assign(defaultConfig, axiosConfig);
|
||||
this.instance = axios.create(defaultConfig);
|
||||
this.instance = axios.create(axiosConfig);
|
||||
this.setInterceptor();
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import subscribeAppStore from './app';
|
||||
// import subscribeAppStore from './app';
|
||||
import subscribeThemeStore from './theme';
|
||||
|
||||
/** 订阅状态 */
|
||||
export function subscribeStore() {
|
||||
subscribeAppStore();
|
||||
// subscribeAppStore();
|
||||
subscribeThemeStore();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user