Skip to content

Commit

Permalink
refactor(request): 将/api/设置为前缀
Browse files Browse the repository at this point in the history
  • Loading branch information
yuntian001 committed Nov 30, 2022
1 parent 753a534 commit 29223fd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/api/example.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { request, RequestOptions } from '@/utils/request';
const enum Api {
LIST = '/api/list',
INFO = '/api/list/info/',
LIST = 'list',
INFO = 'list/info',
}

//列表接口
Expand Down
2 changes: 1 addition & 1 deletion src/api/routeMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { request, RequestOptions } from '@/utils/request';
import { RouteRecordRaw } from 'vue-router';

const enum Api {
MENU = '/api/menu/list',
MENU = 'menu/list',
}

export function menuApi<T extends boolean = true>(
Expand Down
6 changes: 3 additions & 3 deletions src/api/user.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import request from '@/utils/request';

const enum Api {
LOGIN = '/api/user/login',
USER_INFO = '/api/user/info',
LOGIN = 'user/login',
USER_INFO = 'user/info',
}

// 登录
Expand Down Expand Up @@ -30,7 +30,7 @@ export interface UserInfoResult {
name: string; // 名称
username: string; // 用户名
}
export function userInfoApi<T extends boolean = false>(returnAxios:T = false as T, noLoading = true) {
export function userInfoApi<T extends boolean = false>(returnAxios: T = false as T, noLoading = true) {
return request<UserInfoResult, [], T>(
() => ({
url: Api.USER_INFO,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import log from './log';
import { useRequest, Options, setGlobalOptions } from 'vue-request';
const t = (...args: [string | number]) => useGlobalStore().i18n.t(...args);
const service = axios.create({
baseURL: '/', // url = base url + request url
baseURL: '/api/', // url = base url + request url
timeout: 10000, // request timeout
});
// 请求拦截器
Expand Down

0 comments on commit 29223fd

Please sign in to comment.