fix: mock数据

This commit is contained in:
hongxinzz 2023-05-04 14:19:31 +08:00
parent c72ac07de9
commit 8bdac7152f
6 changed files with 239 additions and 199 deletions

View File

@ -1,7 +1,7 @@
import { config } from '@/config/axios/config' import config from '@/config/axios/config'
import { MockMethod } from 'vite-plugin-mock' import { MockMethod } from 'vite-plugin-mock'
const { result_code } = config const { code } = config
const timeout = 1000 const timeout = 1000
@ -13,12 +13,14 @@ export default [
timeout, timeout,
response: () => { response: () => {
return { return {
code: result_code,
data: { data: {
users: 102400, code: code,
messages: 81212, data: {
moneys: 9280, users: 102400,
shoppings: 13600 messages: 81212,
moneys: 9280,
shoppings: 13600
}
} }
} }
} }
@ -30,14 +32,16 @@ export default [
timeout, timeout,
response: () => { response: () => {
return { return {
code: result_code, data: {
data: [ code: code,
{ value: 1000, name: 'analysis.directAccess' }, data: [
{ value: 310, name: 'analysis.mailMarketing' }, { value: 1000, name: 'analysis.directAccess' },
{ value: 234, name: 'analysis.allianceAdvertising' }, { value: 310, name: 'analysis.mailMarketing' },
{ value: 135, name: 'analysis.videoAdvertising' }, { value: 234, name: 'analysis.allianceAdvertising' },
{ value: 1548, name: 'analysis.searchEngines' } { value: 135, name: 'analysis.videoAdvertising' },
] { value: 1548, name: 'analysis.searchEngines' }
]
}
} }
} }
}, },
@ -48,16 +52,18 @@ export default [
timeout, timeout,
response: () => { response: () => {
return { return {
code: result_code, data: {
data: [ code: code,
{ value: 13253, name: 'analysis.monday' }, data: [
{ value: 34235, name: 'analysis.tuesday' }, { value: 13253, name: 'analysis.monday' },
{ value: 26321, name: 'analysis.wednesday' }, { value: 34235, name: 'analysis.tuesday' },
{ value: 12340, name: 'analysis.thursday' }, { value: 26321, name: 'analysis.wednesday' },
{ value: 24643, name: 'analysis.friday' }, { value: 12340, name: 'analysis.thursday' },
{ value: 1322, name: 'analysis.saturday' }, { value: 24643, name: 'analysis.friday' },
{ value: 1324, name: 'analysis.sunday' } { value: 1322, name: 'analysis.saturday' },
] { value: 1324, name: 'analysis.sunday' }
]
}
} }
} }
}, },
@ -68,21 +74,23 @@ export default [
timeout, timeout,
response: () => { response: () => {
return { return {
code: result_code, data: {
data: [ code: code,
{ estimate: 100, actual: 120, name: 'analysis.january' }, data: [
{ estimate: 120, actual: 82, name: 'analysis.february' }, { estimate: 100, actual: 120, name: 'analysis.january' },
{ estimate: 161, actual: 91, name: 'analysis.march' }, { estimate: 120, actual: 82, name: 'analysis.february' },
{ estimate: 134, actual: 154, name: 'analysis.april' }, { estimate: 161, actual: 91, name: 'analysis.march' },
{ estimate: 105, actual: 162, name: 'analysis.may' }, { estimate: 134, actual: 154, name: 'analysis.april' },
{ estimate: 160, actual: 140, name: 'analysis.june' }, { estimate: 105, actual: 162, name: 'analysis.may' },
{ estimate: 165, actual: 145, name: 'analysis.july' }, { estimate: 160, actual: 140, name: 'analysis.june' },
{ estimate: 114, actual: 250, name: 'analysis.august' }, { estimate: 165, actual: 145, name: 'analysis.july' },
{ estimate: 163, actual: 134, name: 'analysis.september' }, { estimate: 114, actual: 250, name: 'analysis.august' },
{ estimate: 185, actual: 56, name: 'analysis.october' }, { estimate: 163, actual: 134, name: 'analysis.september' },
{ estimate: 118, actual: 99, name: 'analysis.november' }, { estimate: 185, actual: 56, name: 'analysis.october' },
{ estimate: 123, actual: 123, name: 'analysis.december' } { estimate: 118, actual: 99, name: 'analysis.november' },
] { estimate: 123, actual: 123, name: 'analysis.december' }
]
}
} }
} }
} }

View File

@ -1,7 +1,7 @@
import { config } from '@/config/axios/config' import config from '@/config/axios/config'
import { MockMethod } from 'vite-plugin-mock' import { MockMethod } from 'vite-plugin-mock'
const { result_code } = config const { code } = config
const timeout = 1000 const timeout = 1000
@ -30,8 +30,10 @@ export default [
timeout, timeout,
response: () => { response: () => {
return { return {
code: result_code, data: {
data: dictObj code: code,
data: dictObj
}
} }
} }
}, },
@ -42,21 +44,23 @@ export default [
timeout, timeout,
response: () => { response: () => {
return { return {
code: result_code, data: {
data: [ code: code,
{ data: [
label: 'test1', {
value: 0 label: 'test1',
}, value: 0
{ },
label: 'test2', {
value: 1 label: 'test2',
}, value: 1
{ },
label: 'test3', {
value: 2 label: 'test3',
} value: 2
] }
]
}
} }
} }
} }

View File

@ -1,7 +1,7 @@
import { config } from '@/config/axios/config' import config from '@/config/axios/config'
import { MockMethod } from 'vite-plugin-mock' import { MockMethod } from 'vite-plugin-mock'
const { result_code } = config const { code } = config
const timeout = 1000 const timeout = 1000
@ -526,8 +526,10 @@ export default [
response: ({ query }) => { response: ({ query }) => {
const { roleName } = query const { roleName } = query
return { return {
code: result_code, data: {
data: roleName === 'admin' ? adminList : testList code: code,
data: roleName === 'admin' ? adminList : testList
}
} }
} }
} }

View File

@ -1,9 +1,9 @@
import { config } from '@/config/axios/config' import config from '@/config/axios/config'
import { MockMethod } from 'vite-plugin-mock' import { MockMethod } from 'vite-plugin-mock'
import { toAnyString } from '@/utils' import { toAnyString } from '@/utils'
import Mock from 'mockjs' import Mock from 'mockjs'
const { result_code } = config const { code } = config
const timeout = 1000 const timeout = 1000
@ -54,10 +54,12 @@ export default [
(_, index) => index < pageSize * pageIndex && index >= pageSize * (pageIndex - 1) (_, index) => index < pageSize * pageIndex && index >= pageSize * (pageIndex - 1)
) )
return { return {
code: result_code,
data: { data: {
total: mockList.length, code: code,
list: pageList data: {
total: mockList.length,
list: pageList
}
} }
} }
} }
@ -75,8 +77,10 @@ export default [
}) })
].concat(List) ].concat(List)
return { return {
code: result_code, data: {
data: 'success' code: code,
data: 'success'
}
} }
} else { } else {
List.map((item) => { List.map((item) => {
@ -87,8 +91,10 @@ export default [
} }
}) })
return { return {
code: result_code, data: {
data: 'success' code: code,
data: 'success'
}
} }
} }
} }
@ -102,8 +108,10 @@ export default [
for (const example of List) { for (const example of List) {
if (example.id === id) { if (example.id === id) {
return { return {
code: result_code, data: {
data: example code: code,
data: example
}
} }
} }
} }
@ -128,8 +136,10 @@ export default [
} }
} }
return { return {
code: result_code, data: {
data: 'success' code: code,
data: 'success'
}
} }
} }
} }

View File

@ -1,7 +1,7 @@
import { config } from '@/config/axios/config' import config from '@/config/axios/config'
import { MockMethod } from 'vite-plugin-mock' import { MockMethod } from 'vite-plugin-mock'
const { result_code } = config const { code } = config
const timeout = 1000 const timeout = 1000
@ -45,10 +45,12 @@ export default [
) )
return { return {
code: result_code,
data: { data: {
total: mockList.length, code: code,
list: pageList data: {
total: mockList.length,
list: pageList
}
} }
} }
} }
@ -65,14 +67,16 @@ export default [
if (user.username === data.username && user.password === data.password) { if (user.username === data.username && user.password === data.password) {
hasUser = true hasUser = true
return { return {
code: result_code, data: {
data: user code: code,
data: user
}
} }
} }
} }
if (!hasUser) { if (!hasUser) {
return { return {
code: '500', code: 500,
message: '账号或密码错误' message: '账号或密码错误'
} }
} }
@ -85,8 +89,10 @@ export default [
timeout, timeout,
response: () => { response: () => {
return { return {
code: result_code, data: {
data: null code: code,
data: null
}
} }
} }
} }

View File

@ -1,7 +1,7 @@
import { config } from '@/config/axios/config' import config from '@/config/axios/config'
import { MockMethod } from 'vite-plugin-mock' import { MockMethod } from 'vite-plugin-mock'
const { result_code } = config const { code } = config
const timeout = 1000 const timeout = 1000
@ -13,11 +13,13 @@ export default [
timeout, timeout,
response: () => { response: () => {
return { return {
code: result_code,
data: { data: {
project: 40, code: code,
access: 2340, data: {
todo: 10 project: 40,
access: 2340,
todo: 10
}
} }
} }
} }
@ -29,51 +31,53 @@ export default [
timeout, timeout,
response: () => { response: () => {
return { return {
code: result_code, data: {
data: [ code: code,
{ data: [
name: 'Github', {
icon: 'akar-icons:github-fill', name: 'Github',
message: 'workplace.introduction', icon: 'akar-icons:github-fill',
personal: 'Archer', message: 'workplace.introduction',
time: new Date() personal: 'Archer',
}, time: new Date()
{ },
name: 'Vue', {
icon: 'logos:vue', name: 'Vue',
message: 'workplace.introduction', icon: 'logos:vue',
personal: 'Archer', message: 'workplace.introduction',
time: new Date() personal: 'Archer',
}, time: new Date()
{ },
name: 'Angular', {
icon: 'logos:angular-icon', name: 'Angular',
message: 'workplace.introduction', icon: 'logos:angular-icon',
personal: 'Archer', message: 'workplace.introduction',
time: new Date() personal: 'Archer',
}, time: new Date()
{ },
name: 'React', {
icon: 'logos:react', name: 'React',
message: 'workplace.introduction', icon: 'logos:react',
personal: 'Archer', message: 'workplace.introduction',
time: new Date() personal: 'Archer',
}, time: new Date()
{ },
name: 'Webpack', {
icon: 'logos:webpack', name: 'Webpack',
message: 'workplace.introduction', icon: 'logos:webpack',
personal: 'Archer', message: 'workplace.introduction',
time: new Date() personal: 'Archer',
}, time: new Date()
{ },
name: 'Vite', {
icon: 'vscode-icons:file-type-vite', name: 'Vite',
message: 'workplace.introduction', icon: 'vscode-icons:file-type-vite',
personal: 'Archer', message: 'workplace.introduction',
time: new Date() personal: 'Archer',
} time: new Date()
] }
]
}
} }
} }
}, },
@ -84,33 +88,35 @@ export default [
timeout, timeout,
response: () => { response: () => {
return { return {
code: result_code, data: {
data: [ code: code,
{ data: [
keys: ['workplace.push', 'Github'], {
time: new Date() keys: ['workplace.push', 'Github'],
}, time: new Date()
{ },
keys: ['workplace.push', 'Github'], {
time: new Date() keys: ['workplace.push', 'Github'],
}, time: new Date()
{ },
keys: ['workplace.push', 'Github'], {
time: new Date() keys: ['workplace.push', 'Github'],
}, time: new Date()
{ },
keys: ['workplace.push', 'Github'], {
time: new Date() keys: ['workplace.push', 'Github'],
}, time: new Date()
{ },
keys: ['workplace.push', 'Github'], {
time: new Date() keys: ['workplace.push', 'Github'],
}, time: new Date()
{ },
keys: ['workplace.push', 'Github'], {
time: new Date() keys: ['workplace.push', 'Github'],
} time: new Date()
] }
]
}
} }
} }
}, },
@ -121,33 +127,35 @@ export default [
timeout, timeout,
response: () => { response: () => {
return { return {
code: result_code, data: {
data: [ code: code,
{ data: [
name: 'Github', {
icon: 'akar-icons:github-fill' name: 'Github',
}, icon: 'akar-icons:github-fill'
{ },
name: 'Vue', {
icon: 'logos:vue' name: 'Vue',
}, icon: 'logos:vue'
{ },
name: 'Angular', {
icon: 'logos:angular-icon' name: 'Angular',
}, icon: 'logos:angular-icon'
{ },
name: 'React', {
icon: 'logos:react' name: 'React',
}, icon: 'logos:react'
{ },
name: 'Webpack', {
icon: 'logos:webpack' name: 'Webpack',
}, icon: 'logos:webpack'
{ },
name: 'Vite', {
icon: 'vscode-icons:file-type-vite' name: 'Vite',
} icon: 'vscode-icons:file-type-vite'
] }
]
}
} }
} }
}, },
@ -158,14 +166,16 @@ export default [
timeout, timeout,
response: () => { response: () => {
return { return {
code: result_code, data: {
data: [ code: code,
{ name: 'workplace.quote', max: 65, personal: 42, team: 50 }, data: [
{ name: 'workplace.contribution', max: 160, personal: 30, team: 140 }, { name: 'workplace.quote', max: 65, personal: 42, team: 50 },
{ name: 'workplace.hot', max: 300, personal: 20, team: 28 }, { name: 'workplace.contribution', max: 160, personal: 30, team: 140 },
{ name: 'workplace.yield', max: 130, personal: 35, team: 35 }, { name: 'workplace.hot', max: 300, personal: 20, team: 28 },
{ name: 'workplace.follow', max: 100, personal: 80, team: 90 } { name: 'workplace.yield', max: 130, personal: 35, team: 35 },
] { name: 'workplace.follow', max: 100, personal: 80, team: 90 }
]
}
} }
} }
} }