refactor(projects): 代码优化

This commit is contained in:
Soybean 2022-03-05 23:48:05 +08:00
parent f42ee9dbe5
commit 4e31abd446
4 changed files with 12 additions and 16 deletions

View File

@ -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
};
}
}

View File

@ -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 });
}

View File

@ -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();
}

View File

@ -1,8 +1,8 @@
import subscribeAppStore from './app';
// import subscribeAppStore from './app';
import subscribeThemeStore from './theme';
/** 订阅状态 */
export function subscribeStore() {
subscribeAppStore();
// subscribeAppStore();
subscribeThemeStore();
}