Commit 11d3f395caf7e2268630090eb34f4e5c114a96b7

Authored by Vben
1 parent a821d9a3

fix: ensure to request the interface correctly

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