feat: 替换mock-server插件
This commit is contained in:
parent
3502493cbe
commit
b8f9a9940d
|
@ -1,18 +0,0 @@
|
|||
import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer'
|
||||
|
||||
const modules = import.meta.glob('./**/*.ts', {
|
||||
import: 'default',
|
||||
eager: true
|
||||
})
|
||||
|
||||
const mockModules: any[] = []
|
||||
Object.keys(modules).forEach(async (key) => {
|
||||
if (key.includes('_')) {
|
||||
return
|
||||
}
|
||||
mockModules.push(...(modules[key] as any))
|
||||
})
|
||||
|
||||
export function setupProdMockServer() {
|
||||
createProdMockServer(mockModules)
|
||||
}
|
|
@ -1,17 +1,17 @@
|
|||
import config from '@/config/axios/config'
|
||||
import { MockMethod } from 'vite-plugin-mock'
|
||||
import { defineMock } from 'vite-plugin-mock-dev-server'
|
||||
|
||||
const { code } = config
|
||||
|
||||
const timeout = 1000
|
||||
const delay = 1000
|
||||
|
||||
export default [
|
||||
export default defineMock([
|
||||
// 分析页统计接口
|
||||
{
|
||||
url: '/analysis/total',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/analysis/total',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: {
|
||||
|
@ -25,10 +25,10 @@ export default [
|
|||
},
|
||||
// 用户来源
|
||||
{
|
||||
url: '/analysis/userAccessSource',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/analysis/userAccessSource',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: [
|
||||
|
@ -43,10 +43,10 @@ export default [
|
|||
},
|
||||
// 每周用户活跃量
|
||||
{
|
||||
url: '/analysis/weeklyUserActivity',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/analysis/weeklyUserActivity',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: [
|
||||
|
@ -63,10 +63,10 @@ export default [
|
|||
},
|
||||
// 每月销售额
|
||||
{
|
||||
url: '/analysis/monthlySales',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/analysis/monthlySales',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: [
|
||||
|
@ -86,4 +86,4 @@ export default [
|
|||
}
|
||||
}
|
||||
}
|
||||
] as MockMethod[]
|
||||
])
|
|
@ -1,5 +1,5 @@
|
|||
import config from '@/config/axios/config'
|
||||
import { MockMethod } from 'vite-plugin-mock'
|
||||
|
||||
import { toAnyString } from '@/utils'
|
||||
import Mock from 'mockjs'
|
||||
|
||||
|
@ -81,9 +81,9 @@ for (let i = 0; i < 5; i++) {
|
|||
export default [
|
||||
// 列表接口
|
||||
{
|
||||
url: '/department/list',
|
||||
method: 'get',
|
||||
response: () => {
|
||||
url: '/mock/department/list',
|
||||
method: 'GET',
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: {
|
||||
|
@ -93,9 +93,9 @@ export default [
|
|||
}
|
||||
},
|
||||
{
|
||||
url: '/department/table/list',
|
||||
method: 'get',
|
||||
response: () => {
|
||||
url: '/mock/department/table/list',
|
||||
method: 'GET',
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: {
|
||||
|
@ -106,10 +106,10 @@ export default [
|
|||
}
|
||||
},
|
||||
{
|
||||
url: '/department/users',
|
||||
method: 'get',
|
||||
timeout: 1000,
|
||||
response: ({ query }) => {
|
||||
url: '/mock/department/users',
|
||||
method: 'GET',
|
||||
delay: 1000,
|
||||
body: ({ query }) => {
|
||||
const { pageSize } = query
|
||||
// 根据pageSize来创建数据
|
||||
const mockList: any = []
|
||||
|
@ -140,10 +140,10 @@ export default [
|
|||
},
|
||||
// 保存接口
|
||||
{
|
||||
url: '/department/user/save',
|
||||
method: 'post',
|
||||
timeout: 1000,
|
||||
response: () => {
|
||||
url: '/mock/department/user/save',
|
||||
method: 'POST',
|
||||
delay: 1000,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: 'success'
|
||||
|
@ -152,9 +152,9 @@ export default [
|
|||
},
|
||||
// 删除接口
|
||||
{
|
||||
url: '/department/user/delete',
|
||||
method: 'post',
|
||||
response: ({ body }) => {
|
||||
url: '/mock/department/user/delete',
|
||||
method: 'POST',
|
||||
body: ({ body }) => {
|
||||
const ids = body.ids
|
||||
if (!ids) {
|
||||
return {
|
||||
|
@ -171,10 +171,10 @@ export default [
|
|||
},
|
||||
// 保存接口
|
||||
{
|
||||
url: '/department/save',
|
||||
method: 'post',
|
||||
timeout: 1000,
|
||||
response: () => {
|
||||
url: '/mock/department/save',
|
||||
method: 'POST',
|
||||
delay: 1000,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: 'success'
|
||||
|
@ -183,9 +183,9 @@ export default [
|
|||
},
|
||||
// 删除接口
|
||||
{
|
||||
url: '/department/delete',
|
||||
method: 'post',
|
||||
response: ({ body }) => {
|
||||
url: '/mock/department/delete',
|
||||
method: 'POST',
|
||||
body: ({ body }) => {
|
||||
const ids = body.ids
|
||||
if (!ids) {
|
||||
return {
|
||||
|
@ -200,4 +200,4 @@ export default [
|
|||
}
|
||||
}
|
||||
}
|
||||
] as MockMethod[]
|
||||
]
|
|
@ -1,9 +1,8 @@
|
|||
import config from '@/config/axios/config'
|
||||
import { MockMethod } from 'vite-plugin-mock'
|
||||
|
||||
const { code } = config
|
||||
|
||||
const timeout = 1000
|
||||
const delay = 1000
|
||||
|
||||
const dictObj: Recordable = {
|
||||
importance: [
|
||||
|
@ -25,10 +24,10 @@ const dictObj: Recordable = {
|
|||
export default [
|
||||
// 字典接口
|
||||
{
|
||||
url: '/dict/list',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/dict/list',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: dictObj
|
||||
|
@ -37,10 +36,10 @@ export default [
|
|||
},
|
||||
// 获取某个字典
|
||||
{
|
||||
url: '/dict/one',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/dict/one',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: [
|
||||
|
@ -60,4 +59,4 @@ export default [
|
|||
}
|
||||
}
|
||||
}
|
||||
] as MockMethod[]
|
||||
]
|
|
@ -1,18 +1,18 @@
|
|||
import config from '@/config/axios/config'
|
||||
import { MockMethod } from 'vite-plugin-mock'
|
||||
|
||||
import Mock from 'mockjs'
|
||||
|
||||
const { code } = config
|
||||
|
||||
const timeout = 1000
|
||||
const delay = 1000
|
||||
|
||||
export default [
|
||||
// 列表接口
|
||||
{
|
||||
url: '/menu/list',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/menu/list',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: {
|
||||
|
@ -344,4 +344,4 @@ export default [
|
|||
}
|
||||
}
|
||||
}
|
||||
] as MockMethod[]
|
||||
]
|
|
@ -1,16 +1,15 @@
|
|||
import config from '@/config/axios/config'
|
||||
import { MockMethod } from 'vite-plugin-mock'
|
||||
|
||||
const timeout = 600000
|
||||
const delay = 600000
|
||||
|
||||
const { code } = config
|
||||
|
||||
export default [
|
||||
{
|
||||
url: '/request/1',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/request/1',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: 'request-1'
|
||||
|
@ -18,10 +17,10 @@ export default [
|
|||
}
|
||||
},
|
||||
{
|
||||
url: '/request/2',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/request/2',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: 'request-2'
|
||||
|
@ -29,10 +28,10 @@ export default [
|
|||
}
|
||||
},
|
||||
{
|
||||
url: '/request/3',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/request/3',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: 'request-3'
|
||||
|
@ -40,10 +39,10 @@ export default [
|
|||
}
|
||||
},
|
||||
{
|
||||
url: '/request/4',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/request/4',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: 'request-4'
|
||||
|
@ -51,10 +50,10 @@ export default [
|
|||
}
|
||||
},
|
||||
{
|
||||
url: '/request/5',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/request/5',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: 'request-5'
|
||||
|
@ -62,14 +61,14 @@ export default [
|
|||
}
|
||||
},
|
||||
{
|
||||
url: '/request/expired',
|
||||
method: 'get',
|
||||
timeout: 0,
|
||||
response: () => {
|
||||
url: '/mock/request/expired',
|
||||
method: 'GET',
|
||||
delay: 0,
|
||||
body: () => {
|
||||
return {
|
||||
code: 401,
|
||||
message: 'token expired'
|
||||
}
|
||||
}
|
||||
}
|
||||
] as MockMethod[]
|
||||
]
|
|
@ -1,11 +1,11 @@
|
|||
import config from '@/config/axios/config'
|
||||
import { MockMethod } from 'vite-plugin-mock'
|
||||
|
||||
import Mock from 'mockjs'
|
||||
import { toAnyString } from '@/utils'
|
||||
|
||||
const { code } = config
|
||||
|
||||
const timeout = 1000
|
||||
const delay = 1000
|
||||
|
||||
const adminList = [
|
||||
{
|
||||
|
@ -1139,10 +1139,10 @@ for (let i = 0; i < 4; i++) {
|
|||
export default [
|
||||
// 列表接口
|
||||
{
|
||||
url: '/role/list',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/role/list',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: adminList
|
||||
|
@ -1150,10 +1150,10 @@ export default [
|
|||
}
|
||||
},
|
||||
{
|
||||
url: '/role/table',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/role/table',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: {
|
||||
|
@ -1165,10 +1165,10 @@ export default [
|
|||
},
|
||||
// 列表接口
|
||||
{
|
||||
url: '/role/list2',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/role/list2',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: testList
|
||||
|
@ -1176,10 +1176,10 @@ export default [
|
|||
}
|
||||
},
|
||||
{
|
||||
url: '/role/table',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/role/table',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: {
|
||||
|
@ -1189,4 +1189,4 @@ export default [
|
|||
}
|
||||
}
|
||||
}
|
||||
] as MockMethod[]
|
||||
]
|
|
@ -1,11 +1,11 @@
|
|||
import config from '@/config/axios/config'
|
||||
import { MockMethod } from 'vite-plugin-mock'
|
||||
|
||||
import { toAnyString } from '@/utils'
|
||||
import Mock from 'mockjs'
|
||||
|
||||
const { code } = config
|
||||
|
||||
const timeout = 1000
|
||||
const delay = 1000
|
||||
|
||||
const count = 100
|
||||
|
||||
|
@ -139,10 +139,10 @@ for (let i = 0; i < count; i++) {
|
|||
export default [
|
||||
// 树形列表接口
|
||||
{
|
||||
url: '/example/treeList',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: ({ query }) => {
|
||||
url: '/mock/example/treeList',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: ({ query }) => {
|
||||
const { title, pageIndex, pageSize } = query
|
||||
const mockList = treeList.filter((item) => {
|
||||
if (title && item.title.indexOf(title) < 0) return false
|
||||
|
@ -162,10 +162,10 @@ export default [
|
|||
},
|
||||
// 列表接口
|
||||
{
|
||||
url: '/example/list',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: ({ query }) => {
|
||||
url: '/mock/example/list',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: ({ query }) => {
|
||||
const { title, pageIndex, pageSize } = query
|
||||
const mockList = List.filter((item) => {
|
||||
if (title && item.title.indexOf(title) < 0) return false
|
||||
|
@ -185,10 +185,10 @@ export default [
|
|||
},
|
||||
// 保存接口
|
||||
{
|
||||
url: '/example/save',
|
||||
method: 'post',
|
||||
timeout,
|
||||
response: ({ body }) => {
|
||||
url: '/mock/example/save',
|
||||
method: 'POST',
|
||||
delay,
|
||||
body: ({ body }) => {
|
||||
if (!body.id) {
|
||||
List = [
|
||||
Object.assign(body, {
|
||||
|
@ -216,9 +216,9 @@ export default [
|
|||
},
|
||||
// 详情接口
|
||||
{
|
||||
url: '/example/detail',
|
||||
method: 'get',
|
||||
response: ({ query }) => {
|
||||
url: '/mock/example/detail',
|
||||
method: 'GET',
|
||||
body: ({ query }) => {
|
||||
const { id } = query
|
||||
for (const example of List) {
|
||||
if (example.id === id) {
|
||||
|
@ -232,9 +232,9 @@ export default [
|
|||
},
|
||||
// 删除接口
|
||||
{
|
||||
url: '/example/delete',
|
||||
method: 'post',
|
||||
response: ({ body }) => {
|
||||
url: '/mock/example/delete',
|
||||
method: 'POST',
|
||||
body: ({ body }) => {
|
||||
const ids = body.ids
|
||||
if (!ids) {
|
||||
return {
|
||||
|
@ -255,4 +255,4 @@ export default [
|
|||
}
|
||||
}
|
||||
}
|
||||
] as MockMethod[]
|
||||
]
|
|
@ -1,9 +1,8 @@
|
|||
import config from '@/config/axios/config'
|
||||
import { MockMethod } from 'vite-plugin-mock'
|
||||
|
||||
const { code } = config
|
||||
|
||||
const timeout = 1000
|
||||
const delay = 1000
|
||||
|
||||
const List: {
|
||||
username: string
|
||||
|
@ -31,9 +30,9 @@ const List: {
|
|||
export default [
|
||||
// 列表接口
|
||||
{
|
||||
url: '/user/list',
|
||||
method: 'get',
|
||||
response: ({ query }) => {
|
||||
url: '/mock/user/list',
|
||||
method: 'GET',
|
||||
body: ({ query }) => {
|
||||
const { username, pageIndex, pageSize } = query
|
||||
|
||||
const mockList = List.filter((item) => {
|
||||
|
@ -55,10 +54,10 @@ export default [
|
|||
},
|
||||
// 登录接口
|
||||
{
|
||||
url: '/user/login',
|
||||
method: 'post',
|
||||
timeout,
|
||||
response: ({ body }) => {
|
||||
url: '/mock/user/login',
|
||||
method: 'POST',
|
||||
delay,
|
||||
body: ({ body }) => {
|
||||
const data = body
|
||||
let hasUser = false
|
||||
for (const user of List) {
|
||||
|
@ -80,14 +79,14 @@ export default [
|
|||
},
|
||||
// 退出接口
|
||||
{
|
||||
url: '/user/loginOut',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/user/loginOut',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: null
|
||||
}
|
||||
}
|
||||
}
|
||||
] as MockMethod[]
|
||||
]
|
|
@ -1,17 +1,16 @@
|
|||
import config from '@/config/axios/config'
|
||||
import { MockMethod } from 'vite-plugin-mock'
|
||||
|
||||
const { code } = config
|
||||
|
||||
const timeout = 1000
|
||||
const delay = 1000
|
||||
|
||||
export default [
|
||||
// 获取统计
|
||||
{
|
||||
url: '/workplace/total',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/workplace/total',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: {
|
||||
|
@ -24,10 +23,10 @@ export default [
|
|||
},
|
||||
// 获取项目
|
||||
{
|
||||
url: '/workplace/project',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/workplace/project',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: [
|
||||
|
@ -79,10 +78,10 @@ export default [
|
|||
},
|
||||
// 获取动态
|
||||
{
|
||||
url: '/workplace/dynamic',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/workplace/dynamic',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: [
|
||||
|
@ -116,10 +115,10 @@ export default [
|
|||
},
|
||||
// 获取团队信息
|
||||
{
|
||||
url: '/workplace/team',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/workplace/team',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: [
|
||||
|
@ -153,10 +152,10 @@ export default [
|
|||
},
|
||||
// 获取指数
|
||||
{
|
||||
url: '/workplace/radar',
|
||||
method: 'get',
|
||||
timeout,
|
||||
response: () => {
|
||||
url: '/mock/workplace/radar',
|
||||
method: 'GET',
|
||||
delay,
|
||||
body: () => {
|
||||
return {
|
||||
code: code,
|
||||
data: [
|
||||
|
@ -169,4 +168,4 @@ export default [
|
|||
}
|
||||
}
|
||||
}
|
||||
] as MockMethod[]
|
||||
]
|
|
@ -109,7 +109,7 @@
|
|||
"vite": "5.0.3",
|
||||
"vite-plugin-ejs": "^1.7.0",
|
||||
"vite-plugin-eslint": "^1.8.1",
|
||||
"vite-plugin-mock": "2.9.6",
|
||||
"vite-plugin-mock-dev-server": "^1.3.4",
|
||||
"vite-plugin-progress": "^0.0.7",
|
||||
"vite-plugin-purge-icons": "^0.10.0",
|
||||
"vite-plugin-style-import": "2.0.0",
|
||||
|
|
|
@ -2,10 +2,10 @@ import request from '@/config/axios'
|
|||
|
||||
// 获取所有字典
|
||||
export const getDictApi = () => {
|
||||
return request.get({ url: '/dict/list' })
|
||||
return request.get({ url: '/mock/dict/list' })
|
||||
}
|
||||
|
||||
// 模拟获取某个字典
|
||||
export const getDictOneApi = async () => {
|
||||
return request.get({ url: '/dict/one' })
|
||||
return request.get({ url: '/mock/dict/one' })
|
||||
}
|
||||
|
|
|
@ -7,17 +7,17 @@ import type {
|
|||
} from './types'
|
||||
|
||||
export const getCountApi = (): Promise<IResponse<AnalysisTotalTypes[]>> => {
|
||||
return request.get({ url: '/analysis/total' })
|
||||
return request.get({ url: '/mock/analysis/total' })
|
||||
}
|
||||
|
||||
export const getUserAccessSourceApi = (): Promise<IResponse<UserAccessSource[]>> => {
|
||||
return request.get({ url: '/analysis/userAccessSource' })
|
||||
return request.get({ url: '/mock/analysis/userAccessSource' })
|
||||
}
|
||||
|
||||
export const getWeeklyUserActivityApi = (): Promise<IResponse<WeeklyUserActivity[]>> => {
|
||||
return request.get({ url: '/analysis/weeklyUserActivity' })
|
||||
return request.get({ url: '/mock/analysis/weeklyUserActivity' })
|
||||
}
|
||||
|
||||
export const getMonthlySalesApi = (): Promise<IResponse<MonthlySales[]>> => {
|
||||
return request.get({ url: '/analysis/monthlySales' })
|
||||
return request.get({ url: '/mock/analysis/monthlySales' })
|
||||
}
|
||||
|
|
|
@ -2,21 +2,21 @@ import request from '@/config/axios'
|
|||
import type { WorkplaceTotal, Project, Dynamic, Team, RadarData } from './types'
|
||||
|
||||
export const getCountApi = (): Promise<IResponse<WorkplaceTotal>> => {
|
||||
return request.get({ url: '/workplace/total' })
|
||||
return request.get({ url: '/mock/workplace/total' })
|
||||
}
|
||||
|
||||
export const getProjectApi = (): Promise<IResponse<Project>> => {
|
||||
return request.get({ url: '/workplace/project' })
|
||||
return request.get({ url: '/mock/workplace/project' })
|
||||
}
|
||||
|
||||
export const getDynamicApi = (): Promise<IResponse<Dynamic[]>> => {
|
||||
return request.get({ url: '/workplace/dynamic' })
|
||||
return request.get({ url: '/mock/workplace/dynamic' })
|
||||
}
|
||||
|
||||
export const getTeamApi = (): Promise<IResponse<Team[]>> => {
|
||||
return request.get({ url: '/workplace/team' })
|
||||
return request.get({ url: '/mock/workplace/team' })
|
||||
}
|
||||
|
||||
export const getRadarApi = (): Promise<IResponse<RadarData[]>> => {
|
||||
return request.get({ url: '/workplace/radar' })
|
||||
return request.get({ url: '/mock/workplace/radar' })
|
||||
}
|
||||
|
|
|
@ -2,29 +2,29 @@ import request from '@/config/axios'
|
|||
import { DepartmentListResponse, DepartmentUserParams, DepartmentUserResponse } from './types'
|
||||
|
||||
export const getDepartmentApi = () => {
|
||||
return request.get<DepartmentListResponse>({ url: '/department/list' })
|
||||
return request.get<DepartmentListResponse>({ url: '/mock/department/list' })
|
||||
}
|
||||
|
||||
export const getUserByIdApi = (params: DepartmentUserParams) => {
|
||||
return request.get<DepartmentUserResponse>({ url: '/department/users', params })
|
||||
return request.get<DepartmentUserResponse>({ url: '/mock/department/users', params })
|
||||
}
|
||||
|
||||
export const deleteUserByIdApi = (ids: string[] | number[]) => {
|
||||
return request.post({ url: '/department/user/delete', data: { ids } })
|
||||
return request.post({ url: '/mock/department/user/delete', data: { ids } })
|
||||
}
|
||||
|
||||
export const saveUserApi = (data: any) => {
|
||||
return request.post({ url: '/department/user/save', data })
|
||||
return request.post({ url: '/mock/department/user/save', data })
|
||||
}
|
||||
|
||||
export const saveDepartmentApi = (data: any) => {
|
||||
return request.post({ url: '/department/save', data })
|
||||
return request.post({ url: '/mock/department/save', data })
|
||||
}
|
||||
|
||||
export const deleteDepartmentApi = (ids: string[] | number[]) => {
|
||||
return request.post({ url: '/department/delete', data: { ids } })
|
||||
return request.post({ url: '/mock/department/delete', data: { ids } })
|
||||
}
|
||||
|
||||
export const getDepartmentTableApi = (params: any) => {
|
||||
return request.get({ url: '/department/table/list', params })
|
||||
return request.get({ url: '/mock/department/table/list', params })
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ interface RoleParams {
|
|||
}
|
||||
|
||||
export const loginApi = (data: UserType): Promise<IResponse<UserType>> => {
|
||||
return request.post({ url: '/user/login', data })
|
||||
return request.post({ url: '/mock/user/login', data })
|
||||
}
|
||||
|
||||
export const loginOutApi = (): Promise<IResponse> => {
|
||||
return request.get({ url: '/user/loginOut' })
|
||||
return request.get({ url: '/mock/user/loginOut' })
|
||||
}
|
||||
|
||||
export const getUserListApi = ({ params }: AxiosConfig) => {
|
||||
|
@ -20,15 +20,15 @@ export const getUserListApi = ({ params }: AxiosConfig) => {
|
|||
list: UserType[]
|
||||
total: number
|
||||
}
|
||||
}>({ url: '/user/list', params })
|
||||
}>({ url: '/mock/user/list', params })
|
||||
}
|
||||
|
||||
export const getAdminRoleApi = (
|
||||
params: RoleParams
|
||||
): Promise<IResponse<AppCustomRouteRecordRaw[]>> => {
|
||||
return request.get({ url: '/role/list', params })
|
||||
return request.get({ url: '/mock/role/list', params })
|
||||
}
|
||||
|
||||
export const getTestRoleApi = (params: RoleParams): Promise<IResponse<string[]>> => {
|
||||
return request.get({ url: '/role/list2', params })
|
||||
return request.get({ url: '/mock/role/list2', params })
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
export const getMenuListApi = () => {
|
||||
return request.get({ url: '/menu/list' })
|
||||
return request.get({ url: '/mock/menu/list' })
|
||||
}
|
||||
|
|
|
@ -3,36 +3,36 @@ import { RequestResponse } from './types'
|
|||
|
||||
export const request1 = () => {
|
||||
return request.get<IResponse<RequestResponse>>({
|
||||
url: '/request/1'
|
||||
url: '/mock/request/1'
|
||||
})
|
||||
}
|
||||
|
||||
export const request2 = () => {
|
||||
return request.get<IResponse<RequestResponse>>({
|
||||
url: '/request/2'
|
||||
url: '/mock/request/2'
|
||||
})
|
||||
}
|
||||
|
||||
export const request3 = () => {
|
||||
return request.get<IResponse<RequestResponse>>({
|
||||
url: '/request/3'
|
||||
url: '/mock/request/3'
|
||||
})
|
||||
}
|
||||
|
||||
export const request4 = () => {
|
||||
return request.get<IResponse<RequestResponse>>({
|
||||
url: '/request/4'
|
||||
url: '/mock/request/4'
|
||||
})
|
||||
}
|
||||
|
||||
export const request5 = () => {
|
||||
return request.get<IResponse<RequestResponse>>({
|
||||
url: '/request/5'
|
||||
url: '/mock/request/5'
|
||||
})
|
||||
}
|
||||
|
||||
export const expired = () => {
|
||||
return request.get<IResponse<RequestResponse>>({
|
||||
url: '/request/expired'
|
||||
url: '/mock/request/expired'
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
export const getRoleListApi = () => {
|
||||
return request.get({ url: '/role/table' })
|
||||
return request.get({ url: '/mock/role/table' })
|
||||
}
|
||||
|
|
|
@ -2,21 +2,21 @@ import request from '@/config/axios'
|
|||
import type { TableData } from './types'
|
||||
|
||||
export const getTableListApi = (params: any) => {
|
||||
return request.get({ url: '/example/list', params })
|
||||
return request.get({ url: '/mock/example/list', params })
|
||||
}
|
||||
|
||||
export const getTreeTableListApi = (params: any) => {
|
||||
return request.get({ url: '/example/treeList', params })
|
||||
return request.get({ url: '/mock/example/treeList', params })
|
||||
}
|
||||
|
||||
export const saveTableApi = (data: Partial<TableData>): Promise<IResponse> => {
|
||||
return request.post({ url: '/example/save', data })
|
||||
return request.post({ url: '/mock/example/save', data })
|
||||
}
|
||||
|
||||
export const getTableDetApi = (id: string): Promise<IResponse<TableData>> => {
|
||||
return request.get({ url: '/example/detail', params: { id } })
|
||||
return request.get({ url: '/mock/example/detail', params: { id } })
|
||||
}
|
||||
|
||||
export const delTableListApi = (ids: string[] | number[]): Promise<IResponse> => {
|
||||
return request.post({ url: '/example/delete', data: { ids } })
|
||||
return request.post({ url: '/mock/example/delete', data: { ids } })
|
||||
}
|
||||
|
|
|
@ -6,12 +6,13 @@ import VueJsx from '@vitejs/plugin-vue-jsx'
|
|||
import progress from 'vite-plugin-progress'
|
||||
import EslintPlugin from 'vite-plugin-eslint'
|
||||
import { ViteEjsPlugin } from "vite-plugin-ejs"
|
||||
import { viteMockServe } from 'vite-plugin-mock'
|
||||
// import { viteMockServe } from 'vite-plugin-mock'
|
||||
import PurgeIcons from 'vite-plugin-purge-icons'
|
||||
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite"
|
||||
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
|
||||
import { createStyleImportPlugin, ElementPlusResolve } from 'vite-plugin-style-import'
|
||||
import UnoCSS from 'unocss/vite'
|
||||
import MockDevServerPlugin from 'vite-plugin-mock-dev-server'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
const root = process.cwd()
|
||||
|
@ -67,16 +68,19 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
|||
svgoOptions: true
|
||||
}),
|
||||
PurgeIcons(),
|
||||
viteMockServe({
|
||||
ignore: /^\_/,
|
||||
mockPath: 'mock',
|
||||
localEnabled: !isBuild,
|
||||
prodEnabled: isBuild,
|
||||
injectCode: `
|
||||
import { setupProdMockServer } from '../mock/_createProductionServer'
|
||||
// viteMockServe({
|
||||
// ignore: /^\_/,
|
||||
// mockPath: 'mock',
|
||||
// localEnabled: !isBuild,
|
||||
// prodEnabled: isBuild,
|
||||
// injectCode: `
|
||||
// import { setupProdMockServer } from '../mock/_createProductionServer'
|
||||
|
||||
setupProdMockServer()
|
||||
`
|
||||
// setupProdMockServer()
|
||||
// `
|
||||
// }),
|
||||
MockDevServerPlugin({
|
||||
prefix: '/mock'
|
||||
}),
|
||||
ViteEjsPlugin({
|
||||
title: env.VITE_APP_TITLE
|
||||
|
|
Loading…
Reference in New Issue