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