mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-26 08:36:19 +08:00
perf: imporve axios logic
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { GetAccountInfoModel } from './model/accountModel';
|
||||
|
||||
const { get } = defHttp;
|
||||
|
||||
enum Api {
|
||||
ACCOUNT_INFO = '/account/getAccountInfo',
|
||||
}
|
||||
|
||||
// Get personal center-basic settings
|
||||
export function accountInfoApi() {
|
||||
return defHttp.request<GetAccountInfoModel>({
|
||||
url: Api.ACCOUNT_INFO,
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
export const accountInfoApi = () => get<GetAccountInfoModel>({ url: Api.ACCOUNT_INFO });
|
||||
|
@@ -1,5 +1,7 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
const { get } = defHttp;
|
||||
|
||||
enum Api {
|
||||
// The address does not exist
|
||||
Error = '/error',
|
||||
@@ -8,9 +10,5 @@ enum Api {
|
||||
/**
|
||||
* @description: Trigger ajax error
|
||||
*/
|
||||
export function fireErrorApi() {
|
||||
return defHttp.request({
|
||||
url: Api.Error,
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
export const fireErrorApi = () => get({ url: Api.Error });
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { DemoOptionsGetResultModel } from './model/optionsModel';
|
||||
const { get } = defHttp;
|
||||
|
||||
enum Api {
|
||||
OPTIONS_LIST = '/select/getDemoOptions',
|
||||
@@ -8,9 +9,4 @@ enum Api {
|
||||
/**
|
||||
* @description: Get sample options value
|
||||
*/
|
||||
export function optionsListApi() {
|
||||
return defHttp.request<DemoOptionsGetResultModel>({
|
||||
url: Api.OPTIONS_LIST,
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
export const optionsListApi = () => get<DemoOptionsGetResultModel>({ url: Api.OPTIONS_LIST });
|
||||
|
@@ -1,6 +1,8 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { DemoParams, DemoListGetResultModel } from './model/tableModel';
|
||||
|
||||
const { get } = defHttp;
|
||||
|
||||
enum Api {
|
||||
DEMO_LIST = '/table/getDemoList',
|
||||
}
|
||||
@@ -8,13 +10,12 @@ enum Api {
|
||||
/**
|
||||
* @description: Get sample list value
|
||||
*/
|
||||
export function demoListApi(params: DemoParams) {
|
||||
return defHttp.request<DemoListGetResultModel>({
|
||||
|
||||
export const demoListApi = (params: DemoParams) =>
|
||||
get<DemoListGetResultModel>({
|
||||
url: Api.DEMO_LIST,
|
||||
method: 'GET',
|
||||
params,
|
||||
headers: {
|
||||
ignoreCancelToken: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
import { getMenuListByIdParams, getMenuListByIdParamsResultModel } from './model/menuModel';
|
||||
|
||||
const { get } = defHttp;
|
||||
|
||||
enum Api {
|
||||
GetMenuListById = '/getMenuListById',
|
||||
}
|
||||
@@ -9,10 +10,7 @@ enum Api {
|
||||
/**
|
||||
* @description: Get user menu based on id
|
||||
*/
|
||||
export function getMenuListById(params: getMenuListByIdParams) {
|
||||
return defHttp.request<getMenuListByIdParamsResultModel>({
|
||||
url: Api.GetMenuListById,
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export const getMenuListById = (params: getMenuListByIdParams) => {
|
||||
return get<getMenuListByIdParamsResultModel>({ url: Api.GetMenuListById, params });
|
||||
};
|
||||
|
@@ -7,6 +7,7 @@ import {
|
||||
} from './model/userModel';
|
||||
import { ErrorMessageMode } from '/@/utils/http/axios/types';
|
||||
|
||||
const { post, get } = defHttp;
|
||||
enum Api {
|
||||
Login = '/login',
|
||||
GetUserInfoById = '/getUserInfoById',
|
||||
@@ -17,10 +18,9 @@ enum Api {
|
||||
* @description: user login api
|
||||
*/
|
||||
export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.request<LoginResultModel>(
|
||||
return post<LoginResultModel>(
|
||||
{
|
||||
url: Api.Login,
|
||||
method: 'POST',
|
||||
params,
|
||||
},
|
||||
{
|
||||
@@ -33,17 +33,15 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal')
|
||||
* @description: getUserInfoById
|
||||
*/
|
||||
export function getUserInfoById(params: GetUserInfoByUserIdParams) {
|
||||
return defHttp.request<GetUserInfoByUserIdModel>({
|
||||
return get<GetUserInfoByUserIdModel>({
|
||||
url: Api.GetUserInfoById,
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export function getPermCodeByUserId(params: GetUserInfoByUserIdParams) {
|
||||
return defHttp.request<string[]>({
|
||||
return get<string[]>({
|
||||
url: Api.GetPermCodeByUserId,
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user