更改API路径

This commit is contained in:
洛洛希雅 2024-04-26 23:13:49 +08:00
parent c60a907d81
commit 1c4744d38d
4 changed files with 18 additions and 21 deletions

View File

@ -1,5 +0,0 @@
import { post } from '@/utils/request'
export function getRouterList(data) {
return post('/api/menu/navigate', data)
}

View File

@ -23,29 +23,29 @@ export interface IUserRole {
}
export async function getMyInfo(): Promise<IUser> {
return post<IUser>('/api/user/myInfo')
return post<IUser>('/user/myInfo')
}
export async function getMyRole(): Promise<IUserRole> {
return post('/api/user/myRole')
return post('/user/myRole')
}
//登录
export async function login(data): Promise<IUser> {
return post('/api/login', data)
return post('/login', data)
}
//退出登录
export async function logout(): Promise<void> {
return post('/api/logout')
return post('/logout')
}
export async function getUser(idList): Promise<IUser[]> {
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<any[]>}
*/
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<Blob> {
return request({
url: `/api/user/avatar?id=${id}`,
url: `/user/avatar?id=${id}`,
responseType: 'blob',
headers: {
'Cache-Control': 'no-cache'

View File

@ -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)
}

View File

@ -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) {