From 1c4744d38d7df2c8209dd246956a17bb1945f292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B4=9B=E5=B8=8C=E9=9B=85?= Date: Fri, 26 Apr 2024 23:13:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9API=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/router.ts | 5 ----- src/api/user.ts | 20 ++++++++++---------- src/api/userManagement.ts | 8 ++++---- src/utils/request.ts | 6 ++++-- 4 files changed, 18 insertions(+), 21 deletions(-) delete mode 100644 src/api/router.ts diff --git a/src/api/router.ts b/src/api/router.ts deleted file mode 100644 index 5b5c418..0000000 --- a/src/api/router.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { post } from '@/utils/request' - -export function getRouterList(data) { - return post('/api/menu/navigate', data) -} diff --git a/src/api/user.ts b/src/api/user.ts index 58c533e..5e4042e 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -23,29 +23,29 @@ export interface IUserRole { } export async function getMyInfo(): Promise { - return post('/api/user/myInfo') + return post('/user/myInfo') } export async function getMyRole(): Promise { - return post('/api/user/myRole') + return post('/user/myRole') } //登录 export async function login(data): Promise { - return post('/api/login', data) + return post('/login', data) } //退出登录 export async function logout(): Promise { - return post('/api/logout') + return post('/logout') } export async function getUser(idList): Promise { - return post('/api/user/get', { idList }) + return post('/user/get', { idList }) } export async function editUser(data: IUser) { - return post('/api/user/edit', data) + return post('/user/edit', data) } /** @@ -54,12 +54,12 @@ export async function editUser(data: IUser) { * @return {Promise} */ export function userSearching(keys) { - return post('/api/user/searching', { keys }) + return post('/user/searching', { keys }) } //修改密码 export function updatePassword(data: { id?; origin; target; session? }) { - return post('/api/user/updatePassword', data) + return post('/user/updatePassword', data) } //修改密码 @@ -67,7 +67,7 @@ export function setAvatar(id: string, avatar: Blob) { const form = new FormData() form.append('file', avatar, avatar instanceof File ? avatar.name : `${id}.jpg`) return request({ - url: `/api/user/avatar`, + url: `/user/avatar`, params: { id }, method: 'put', data: form @@ -77,7 +77,7 @@ export function setAvatar(id: string, avatar: Blob) { //修改密码 export function getAvatar(id: string): Promise { return request({ - url: `/api/user/avatar?id=${id}`, + url: `/user/avatar?id=${id}`, responseType: 'blob', headers: { 'Cache-Control': 'no-cache' diff --git a/src/api/userManagement.ts b/src/api/userManagement.ts index 22c4b55..cb75bbd 100644 --- a/src/api/userManagement.ts +++ b/src/api/userManagement.ts @@ -1,17 +1,17 @@ import { post } from '@/utils/request' export function getList(data) { - return post('/api/user/list', data) + return post('/user/list', data) } export function doEdit(data) { - return post('/api/user/edit', data) + return post('/user/edit', data) } export function doCreate(data) { - return post('/api/user/create', data) + return post('/user/create', data) } export function doDelete(data) { - return post('/api/user/delete', data) + return post('/user/delete', data) } diff --git a/src/utils/request.ts b/src/utils/request.ts index 4681b94..89383ef 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -61,7 +61,7 @@ service.interceptors.response.use( } ) -export const baseUrl: string = (() => { +function getRoot() { if (window.NGINX_BASE_URL) return window.NGINX_BASE_URL const mode = import.meta.env.VITE_APP_BASE_MODE @@ -77,7 +77,9 @@ export const baseUrl: string = (() => { //local return `${location.protocol}//${location.host}` -})() +} + +export const baseUrl: string = `${getRoot()}/home/api/` //导出service实例给页面调用 , config->页面的配置 export default function request(config: AxiosRequestConfig) {