修改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) {
return request({
url: '/role/queryRoleByPage',
method: 'post',
data
})
return post('/api/role/queryRoleByPage', data)
}
export function doAdd(data) {
return request({
url: '/role/create',
method: 'post',
data
})
return post('/api/role/create', data)
}
export function doUpdate(data) {
return request({
url: '/role/update',
method: 'post',
data
})
return post('/api/role/update', data)
}
export function doDelete(data) {
return request({
url: '/role/destroy',
method: 'post',
data
})
return post('/api/role/destroy', data)
}
/**
*
* @return {Promise<AxiosResponse<{id: number, type:string, roleName: string}[]>>}
*/
export function getRoleList() {
return request({
url: '/role/list',
method: 'post'
})
return post('/api/role/list')
}
/**
* ID获取角色ID
*/
export function getRoleByUserId(userId) {
return request({
url: '/userRole/getByUserId',
method: 'post',
data: {
userId
}
})
return post('/api/userRole/getByUserId', { userId })
}

View File

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

View File

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

View File

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