diff --git a/src/api/roleManagement.ts b/src/api/roleManagement.ts deleted file mode 100644 index 7e49f84..0000000 --- a/src/api/roleManagement.ts +++ /dev/null @@ -1,30 +0,0 @@ -import request, { post } from '@/utils/request' - -export function getList(data) { - return post('/api/role/queryRoleByPage', data) -} - -export function doAdd(data) { - return post('/api/role/create', data) -} -export function doUpdate(data) { - return post('/api/role/update', data) -} - -export function doDelete(data) { - return post('/api/role/destroy', data) -} -/** - * 获取角色列表 - * @return {Promise>} - */ -export function getRoleList() { - return post('/api/role/list') -} - -/** - * 根据用户ID获取角色ID - */ -export function getRoleByUserId(userId) { - return post('/api/userRole/getByUserId', { userId }) -} 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) {