修改api地址

This commit is contained in:
洛洛希雅 2024-04-26 17:25:47 +08:00
parent 6f3858a075
commit bb9062f191
10 changed files with 35 additions and 229 deletions

View File

@ -1,12 +0,0 @@
export default [
{
url: '/getMapInfo',
method: 'get',
response: () => {
return {
code: 200,
title: 'mock请求测试'
}
}
}
]

View File

@ -1,56 +0,0 @@
import Mock from 'mockjs'
const NameList: any = []
const count = 100
for (let i = 0; i < count; i++) {
NameList.push(
Mock.mock({
name: '@first'
})
)
}
NameList.push({ name: 'mock-Pan' })
export default [
// username search
{
url: '/vue3-admin-plus/search/user',
method: 'get',
response: (config) => {
const { name } = config.query
const mockNameList = NameList.filter((item) => {
// @ts-ignore
const lowerCaseName = item.name.toLowerCase()
return !(name && !lowerCaseName.includes(name.toLowerCase()))
})
return {
code: 20000,
data: { items: mockNameList }
}
}
},
// transaction list
{
url: '/vue3-admin-plus/transaction/list',
method: 'get',
response: () => {
return {
code: 20000,
data: {
total: 20,
'items|20': [
{
order_no: '@guid()',
timestamp: +Mock.Random.date('T'),
userName: '@name()',
price: '@float(1000, 15000, 0, 2)',
'status|1': ['success', 'pending']
}
]
}
}
}
}
]

View File

@ -1,31 +0,0 @@
import Mock from 'mockjs'
const data = Mock.mock({
'items|30': [
{
id: '@id',
title: '@sentence(10, 20)',
'status|1': ['published', 'draft', 'deleted'],
author: 'name',
display_time: '@datetime',
pageviews: '@integer(300, 5000)'
}
]
})
export default [
{
url: '/vue3-admin-template/table/list',
method: 'get',
response: () => {
const items = data.items
return {
code: 20000,
data: {
total: items.length,
items
}
}
}
}
]

View File

@ -1,28 +0,0 @@
import request, { post } from '@/utils/request'
export function getTree(data) {
return post('/menu/list', data)
}
export function doAdd(data) {
return request({
url: '/menu/create',
method: 'post',
data
})
}
export function doUpdate(data) {
return request({
url: '/menu/update',
method: 'post',
data
})
}
export function doDelete(data) {
return request({
url: '/menu/destroy',
method: 'post',
data
})
}

View File

@ -1,17 +0,0 @@
import request from '@/utils/mock-axios-req'
export function searchUser(name) {
return request({
url: '/vue3-admin-plus/search/user',
method: 'get',
params: { name }
})
}
export function transactionList(query) {
return request({
url: '/vue3-admin-plus/transaction/list',
method: 'get',
params: query
})
}

View File

@ -1,55 +1,30 @@
import request from '@/utils/request' import request, { post } from '@/utils/request'
export function getList(data) { export function getList(data) {
return request({ return post('/api/role/queryRoleByPage', data)
url: '/role/queryRoleByPage',
method: 'post',
data
})
} }
export function doAdd(data) { export function doAdd(data) {
return request({ return post('/api/role/create', data)
url: '/role/create',
method: 'post',
data
})
} }
export function doUpdate(data) { export function doUpdate(data) {
return request({ return post('/api/role/update', data)
url: '/role/update',
method: 'post',
data
})
} }
export function doDelete(data) { export function doDelete(data) {
return request({ return post('/api/role/destroy', data)
url: '/role/destroy',
method: 'post',
data
})
} }
/** /**
* *
* @return {Promise<AxiosResponse<{id: number, type:string, roleName: string}[]>>} * @return {Promise<AxiosResponse<{id: number, type:string, roleName: string}[]>>}
*/ */
export function getRoleList() { export function getRoleList() {
return request({ return post('/api/role/list')
url: '/role/list',
method: 'post'
})
} }
/** /**
* ID获取角色ID * ID获取角色ID
*/ */
export function getRoleByUserId(userId) { export function getRoleByUserId(userId) {
return request({ return post('/api/userRole/getByUserId', { userId })
url: '/userRole/getByUserId',
method: 'post',
data: {
userId
}
})
} }

View File

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

View File

@ -1,5 +1,5 @@
//获取用户信息 //获取用户信息
import request, { baseUrl, post } from '@/utils/request' import request, { post } from '@/utils/request'
export interface IUser { export interface IUser {
id: string id: string
@ -23,29 +23,29 @@ export interface IUserRole {
} }
export async function getMyInfo(): Promise<IUser> { export async function getMyInfo(): Promise<IUser> {
return post<IUser>('/user/myInfo') return post<IUser>('/api/user/myInfo')
} }
export async function getMyRole(): Promise<IUserRole> { export async function getMyRole(): Promise<IUserRole> {
return post('/user/myRole') return post('/api/user/myRole')
} }
//登录 //登录
export async function login(data): Promise<IUser> { export async function login(data): Promise<IUser> {
return post('/login', data) return post('/api/login', data)
} }
//退出登录 //退出登录
export async function logout(): Promise<void> { export async function logout(): Promise<void> {
return post('/logout') return post('/api/logout')
} }
export async function getUser(idList): Promise<IUser[]> { export async function getUser(idList): Promise<IUser[]> {
return post('/user/get', { idList }) return post('/api/user/get', { idList })
} }
export async function editUser(data: IUser) { export async function editUser(data: IUser) {
return post('/user/edit', data) return post('/api/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('/user/searching', { keys }) return post('/api/user/searching', { keys })
} }
//修改密码 //修改密码
export function updatePassword(data: { id?; origin; target; session? }) { export function updatePassword(data: { id?; origin; target; session? }) {
return post('/user/updatePassword', data) return post('/api/user/updatePassword', data)
} }
//修改密码 //修改密码
@ -67,17 +67,17 @@ 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: `/user/avatar`, url: `/api/user/avatar`,
params: { id }, params: { id },
method: 'put', method: 'put',
data: form data: form
}) }) as Promise<any>
} }
//修改密码 //修改密码
export function getAvatar(id: string): Promise<Blob> { export function getAvatar(id: string): Promise<Blob> {
return request({ return request({
url: `/user/avatar?id=${id}`, url: `/api/user/avatar?id=${id}`,
responseType: 'blob', responseType: 'blob',
headers: { headers: {
'Cache-Control': 'no-cache' 'Cache-Control': 'no-cache'

View File

@ -1,42 +1,17 @@
import request from '@/utils/request' import { post } from '@/utils/request'
export function getList(data) { export function getList(data) {
return request({ return post('/api/user/list', data)
url: '/user/list',
method: 'post',
data
})
} }
export function doEdit(data) { export function doEdit(data) {
return request({ return post('/api/user/edit', data)
url: '/user/edit',
method: 'post',
data
})
} }
export function doCreate(data) { export function doCreate(data) {
return request({ return post('/api/user/create', data)
url: '/user/create',
method: 'post',
data
})
} }
export function doDelete(data) { export function doDelete(data) {
return request({ return post('/api/user/delete', data)
url: '/user/delete',
method: 'post',
data
})
}
// 查询学生信息
export function getStudentInfoByStudentId(data) {
return request({
url: '/user/getStudentInfoByStudentId',
method: 'post',
data
})
} }

View File

@ -57,16 +57,16 @@ export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => {
symbolId: 'icon-[dir]-[name]' symbolId: 'icon-[dir]-[name]'
}), }),
//https://github.com/anncwb/vite-plugin-mock/blob/HEAD/README.zh_CN.md //https://github.com/anncwb/vite-plugin-mock/blob/HEAD/README.zh_CN.md
viteMockServe({ // viteMockServe({
mockPath: 'mock', // mockPath: 'mock',
localEnabled: command === 'serve', // localEnabled: command === 'serve',
prodEnabled: prodMock, // prodEnabled: prodMock,
injectCode: ` // injectCode: `
import { setupProdMockServer } from '../mock-prod-server'; // import { setupProdMockServer } from '../mock-prod-server';
setupProdMockServer(); // setupProdMockServer();
`, // `,
logger: true // logger: true
} as ViteMockOptions), // } as ViteMockOptions),
// VueSetupExtend(),using DefineOptions instant of it // VueSetupExtend(),using DefineOptions instant of it
//https://github.com/antfu/unplugin-auto-import/blob/HEAD/src/types.ts //https://github.com/antfu/unplugin-auto-import/blob/HEAD/src/types.ts
Components({ Components({