更改API路径

This commit is contained in:
洛洛希雅 2024-04-26 23:11:17 +08:00
parent c60a907d81
commit c2d2f5b6d8
5 changed files with 18 additions and 51 deletions

View File

@ -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<AxiosResponse<{id: number, type:string, roleName: string}[]>>}
*/
export function getRoleList() {
return post('/api/role/list')
}
/**
* ID获取角色ID
*/
export function getRoleByUserId(userId) {
return post('/api/userRole/getByUserId', { userId })
}

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> { export async function getMyInfo(): Promise<IUser> {
return post<IUser>('/api/user/myInfo') return post<IUser>('/user/myInfo')
} }
export async function getMyRole(): Promise<IUserRole> { export async function getMyRole(): Promise<IUserRole> {
return post('/api/user/myRole') return post('/user/myRole')
} }
//登录 //登录
export async function login(data): Promise<IUser> { export async function login(data): Promise<IUser> {
return post('/api/login', data) return post('/login', data)
} }
//退出登录 //退出登录
export async function logout(): Promise<void> { export async function logout(): Promise<void> {
return post('/api/logout') return post('/logout')
} }
export async function getUser(idList): Promise<IUser[]> { export async function getUser(idList): Promise<IUser[]> {
return post('/api/user/get', { idList }) return post('/user/get', { idList })
} }
export async function editUser(data: IUser) { 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[]>} * @return {Promise<any[]>}
*/ */
export function userSearching(keys) { export function userSearching(keys) {
return post('/api/user/searching', { keys }) return post('/user/searching', { keys })
} }
//修改密码 //修改密码
export function updatePassword(data: { id?; origin; target; session? }) { 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() const form = new FormData()
form.append('file', avatar, avatar instanceof File ? avatar.name : `${id}.jpg`) form.append('file', avatar, avatar instanceof File ? avatar.name : `${id}.jpg`)
return request({ return request({
url: `/api/user/avatar`, url: `/user/avatar`,
params: { id }, params: { id },
method: 'put', method: 'put',
data: form data: form
@ -77,7 +77,7 @@ export function setAvatar(id: string, avatar: Blob) {
//修改密码 //修改密码
export function getAvatar(id: string): Promise<Blob> { export function getAvatar(id: string): Promise<Blob> {
return request({ return request({
url: `/api/user/avatar?id=${id}`, url: `/user/avatar?id=${id}`,
responseType: 'blob', responseType: 'blob',
headers: { headers: {
'Cache-Control': 'no-cache' 'Cache-Control': 'no-cache'

View File

@ -1,17 +1,17 @@
import { post } from '@/utils/request' import { post } from '@/utils/request'
export function getList(data) { export function getList(data) {
return post('/api/user/list', data) return post('/user/list', data)
} }
export function doEdit(data) { export function doEdit(data) {
return post('/api/user/edit', data) return post('/user/edit', data)
} }
export function doCreate(data) { export function doCreate(data) {
return post('/api/user/create', data) return post('/user/create', data)
} }
export function doDelete(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 if (window.NGINX_BASE_URL) return window.NGINX_BASE_URL
const mode = import.meta.env.VITE_APP_BASE_MODE const mode = import.meta.env.VITE_APP_BASE_MODE
@ -77,7 +77,9 @@ export const baseUrl: string = (() => {
//local //local
return `${location.protocol}//${location.host}` return `${location.protocol}//${location.host}`
})() }
export const baseUrl: string = `${getRoot()}/home/api/`
//导出service实例给页面调用 , config->页面的配置 //导出service实例给页面调用 , config->页面的配置
export default function request(config: AxiosRequestConfig) { export default function request(config: AxiosRequestConfig) {