Commit 11d3f395caf7e2268630090eb34f4e5c114a96b7
1 parent
a821d9a3
fix: ensure to request the interface correctly
Showing
8 changed files
with
11 additions
and
19 deletions
src/api/demo/account.ts
1 | import { defHttp } from '/@/utils/http/axios'; | 1 | import { defHttp } from '/@/utils/http/axios'; |
2 | import { GetAccountInfoModel } from './model/accountModel'; | 2 | import { GetAccountInfoModel } from './model/accountModel'; |
3 | 3 | ||
4 | -const { get } = defHttp; | ||
5 | - | ||
6 | enum Api { | 4 | enum Api { |
7 | ACCOUNT_INFO = '/account/getAccountInfo', | 5 | ACCOUNT_INFO = '/account/getAccountInfo', |
8 | } | 6 | } |
9 | 7 | ||
10 | // Get personal center-basic settings | 8 | // Get personal center-basic settings |
11 | 9 | ||
12 | -export const accountInfoApi = () => get<GetAccountInfoModel>({ url: Api.ACCOUNT_INFO }); | 10 | +export const accountInfoApi = () => defHttp.get<GetAccountInfoModel>({ url: Api.ACCOUNT_INFO }); |
src/api/demo/error.ts
1 | import { defHttp } from '/@/utils/http/axios'; | 1 | import { defHttp } from '/@/utils/http/axios'; |
2 | 2 | ||
3 | -const { get } = defHttp; | ||
4 | - | ||
5 | enum Api { | 3 | enum Api { |
6 | // The address does not exist | 4 | // The address does not exist |
7 | Error = '/error', | 5 | Error = '/error', |
@@ -11,4 +9,4 @@ enum Api { | @@ -11,4 +9,4 @@ enum Api { | ||
11 | * @description: Trigger ajax error | 9 | * @description: Trigger ajax error |
12 | */ | 10 | */ |
13 | 11 | ||
14 | -export const fireErrorApi = () => get({ url: Api.Error }); | 12 | +export const fireErrorApi = () => defHttp.get({ url: Api.Error }); |
src/api/demo/select.ts
1 | import { defHttp } from '/@/utils/http/axios'; | 1 | import { defHttp } from '/@/utils/http/axios'; |
2 | import { DemoOptionsGetResultModel } from './model/optionsModel'; | 2 | import { DemoOptionsGetResultModel } from './model/optionsModel'; |
3 | -const { get } = defHttp; | ||
4 | 3 | ||
5 | enum Api { | 4 | enum Api { |
6 | OPTIONS_LIST = '/select/getDemoOptions', | 5 | OPTIONS_LIST = '/select/getDemoOptions', |
@@ -9,4 +8,5 @@ enum Api { | @@ -9,4 +8,5 @@ enum Api { | ||
9 | /** | 8 | /** |
10 | * @description: Get sample options value | 9 | * @description: Get sample options value |
11 | */ | 10 | */ |
12 | -export const optionsListApi = () => get<DemoOptionsGetResultModel>({ url: Api.OPTIONS_LIST }); | 11 | +export const optionsListApi = () => |
12 | + defHttp.get<DemoOptionsGetResultModel>({ url: Api.OPTIONS_LIST }); |
src/api/demo/table.ts
1 | import { defHttp } from '/@/utils/http/axios'; | 1 | import { defHttp } from '/@/utils/http/axios'; |
2 | import { DemoParams, DemoListGetResultModel } from './model/tableModel'; | 2 | import { DemoParams, DemoListGetResultModel } from './model/tableModel'; |
3 | 3 | ||
4 | -const { get } = defHttp; | ||
5 | - | ||
6 | enum Api { | 4 | enum Api { |
7 | DEMO_LIST = '/table/getDemoList', | 5 | DEMO_LIST = '/table/getDemoList', |
8 | } | 6 | } |
@@ -12,7 +10,7 @@ enum Api { | @@ -12,7 +10,7 @@ enum Api { | ||
12 | */ | 10 | */ |
13 | 11 | ||
14 | export const demoListApi = (params: DemoParams) => | 12 | export const demoListApi = (params: DemoParams) => |
15 | - get<DemoListGetResultModel>({ | 13 | + defHttp.get<DemoListGetResultModel>({ |
16 | url: Api.DEMO_LIST, | 14 | url: Api.DEMO_LIST, |
17 | params, | 15 | params, |
18 | headers: { | 16 | headers: { |
src/api/sys/menu.ts
1 | import { defHttp } from '/@/utils/http/axios'; | 1 | import { defHttp } from '/@/utils/http/axios'; |
2 | import { getMenuListByIdParams, getMenuListByIdParamsResultModel } from './model/menuModel'; | 2 | import { getMenuListByIdParams, getMenuListByIdParamsResultModel } from './model/menuModel'; |
3 | 3 | ||
4 | -const { get } = defHttp; | ||
5 | - | ||
6 | enum Api { | 4 | enum Api { |
7 | GetMenuListById = '/getMenuListById', | 5 | GetMenuListById = '/getMenuListById', |
8 | } | 6 | } |
@@ -12,5 +10,5 @@ enum Api { | @@ -12,5 +10,5 @@ enum Api { | ||
12 | */ | 10 | */ |
13 | 11 | ||
14 | export const getMenuListById = (params: getMenuListByIdParams) => { | 12 | export const getMenuListById = (params: getMenuListByIdParams) => { |
15 | - return get<getMenuListByIdParamsResultModel>({ url: Api.GetMenuListById, params }); | 13 | + return defHttp.get<getMenuListByIdParamsResultModel>({ url: Api.GetMenuListById, params }); |
16 | }; | 14 | }; |
src/api/sys/user.ts
@@ -7,7 +7,6 @@ import { | @@ -7,7 +7,6 @@ import { | ||
7 | } from './model/userModel'; | 7 | } from './model/userModel'; |
8 | import { ErrorMessageMode } from '/@/utils/http/axios/types'; | 8 | import { ErrorMessageMode } from '/@/utils/http/axios/types'; |
9 | 9 | ||
10 | -const { post, get } = defHttp; | ||
11 | enum Api { | 10 | enum Api { |
12 | Login = '/login', | 11 | Login = '/login', |
13 | GetUserInfoById = '/getUserInfoById', | 12 | GetUserInfoById = '/getUserInfoById', |
@@ -18,7 +17,7 @@ enum Api { | @@ -18,7 +17,7 @@ enum Api { | ||
18 | * @description: user login api | 17 | * @description: user login api |
19 | */ | 18 | */ |
20 | export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') { | 19 | export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') { |
21 | - return post<LoginResultModel>( | 20 | + return defHttp.post<LoginResultModel>( |
22 | { | 21 | { |
23 | url: Api.Login, | 22 | url: Api.Login, |
24 | params, | 23 | params, |
@@ -33,14 +32,14 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') | @@ -33,14 +32,14 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') | ||
33 | * @description: getUserInfoById | 32 | * @description: getUserInfoById |
34 | */ | 33 | */ |
35 | export function getUserInfoById(params: GetUserInfoByUserIdParams) { | 34 | export function getUserInfoById(params: GetUserInfoByUserIdParams) { |
36 | - return get<GetUserInfoByUserIdModel>({ | 35 | + return defHttp.get<GetUserInfoByUserIdModel>({ |
37 | url: Api.GetUserInfoById, | 36 | url: Api.GetUserInfoById, |
38 | params, | 37 | params, |
39 | }); | 38 | }); |
40 | } | 39 | } |
41 | 40 | ||
42 | export function getPermCodeByUserId(params: GetUserInfoByUserIdParams) { | 41 | export function getPermCodeByUserId(params: GetUserInfoByUserIdParams) { |
43 | - return get<string[]>({ | 42 | + return defHttp.get<string[]>({ |
44 | url: Api.GetPermCodeByUserId, | 43 | url: Api.GetPermCodeByUserId, |
45 | params, | 44 | params, |
46 | }); | 45 | }); |
src/utils/http/axios/Axios.ts
@@ -195,6 +195,7 @@ export class VAxios { | @@ -195,6 +195,7 @@ export class VAxios { | ||
195 | } | 195 | } |
196 | 196 | ||
197 | conf = this.supportFormData(conf); | 197 | conf = this.supportFormData(conf); |
198 | + | ||
198 | return new Promise((resolve, reject) => { | 199 | return new Promise((resolve, reject) => { |
199 | this.axiosInstance | 200 | this.axiosInstance |
200 | .request<any, AxiosResponse<Result>>(conf) | 201 | .request<any, AxiosResponse<Result>>(conf) |
types/config.d.ts
@@ -9,7 +9,7 @@ import { | @@ -9,7 +9,7 @@ import { | ||
9 | 9 | ||
10 | import { CacheTypeEnum } from '/@/enums/cacheEnum'; | 10 | import { CacheTypeEnum } from '/@/enums/cacheEnum'; |
11 | import type { LocaleType } from '/@/locales/types'; | 11 | import type { LocaleType } from '/@/locales/types'; |
12 | -import { ThemeMode } from '../../build/config/themeConfig'; | 12 | +import { ThemeMode } from '../build/config/themeConfig'; |
13 | 13 | ||
14 | export interface MenuSetting { | 14 | export interface MenuSetting { |
15 | bgColor: string; | 15 | bgColor: string; |