Skip to content

Commit

Permalink
fix: mock数据
Browse files Browse the repository at this point in the history
  • Loading branch information
hongxinzz committed May 4, 2023
1 parent c72ac07 commit 8bdac71
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 199 deletions.
88 changes: 48 additions & 40 deletions mock/analysis/index.ts
@@ -1,7 +1,7 @@
import { config } from '@/config/axios/config'
import config from '@/config/axios/config'
import { MockMethod } from 'vite-plugin-mock'

const { result_code } = config
const { code } = config

const timeout = 1000

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

const { result_code } = config
const { code } = config

const timeout = 1000

Expand Down Expand Up @@ -30,8 +30,10 @@ export default [
timeout,
response: () => {
return {
code: result_code,
data: dictObj
data: {
code: code,
data: dictObj
}
}
}
},
Expand All @@ -42,21 +44,23 @@ export default [
timeout,
response: () => {
return {
code: result_code,
data: [
{
label: 'test1',
value: 0
},
{
label: 'test2',
value: 1
},
{
label: 'test3',
value: 2
}
]
data: {
code: code,
data: [
{
label: 'test1',
value: 0
},
{
label: 'test2',
value: 1
},
{
label: 'test3',
value: 2
}
]
}
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions mock/role/index.ts
@@ -1,7 +1,7 @@
import { config } from '@/config/axios/config'
import config from '@/config/axios/config'
import { MockMethod } from 'vite-plugin-mock'

const { result_code } = config
const { code } = config

const timeout = 1000

Expand Down Expand Up @@ -526,8 +526,10 @@ export default [
response: ({ query }) => {
const { roleName } = query
return {
code: result_code,
data: roleName === 'admin' ? adminList : testList
data: {
code: code,
data: roleName === 'admin' ? adminList : testList
}
}
}
}
Expand Down
36 changes: 23 additions & 13 deletions mock/table/index.ts
@@ -1,9 +1,9 @@
import { config } from '@/config/axios/config'
import config from '@/config/axios/config'
import { MockMethod } from 'vite-plugin-mock'
import { toAnyString } from '@/utils'
import Mock from 'mockjs'

const { result_code } = config
const { code } = config

const timeout = 1000

Expand Down Expand Up @@ -54,10 +54,12 @@ export default [
(_, index) => index < pageSize * pageIndex && index >= pageSize * (pageIndex - 1)
)
return {
code: result_code,
data: {
total: mockList.length,
list: pageList
code: code,
data: {
total: mockList.length,
list: pageList
}
}
}
}
Expand All @@ -75,8 +77,10 @@ export default [
})
].concat(List)
return {
code: result_code,
data: 'success'
data: {
code: code,
data: 'success'
}
}
} else {
List.map((item) => {
Expand All @@ -87,8 +91,10 @@ export default [
}
})
return {
code: result_code,
data: 'success'
data: {
code: code,
data: 'success'
}
}
}
}
Expand All @@ -102,8 +108,10 @@ export default [
for (const example of List) {
if (example.id === id) {
return {
code: result_code,
data: example
data: {
code: code,
data: example
}
}
}
}
Expand All @@ -128,8 +136,10 @@ export default [
}
}
return {
code: result_code,
data: 'success'
data: {
code: code,
data: 'success'
}
}
}
}
Expand Down
26 changes: 16 additions & 10 deletions mock/user/index.ts
@@ -1,7 +1,7 @@
import { config } from '@/config/axios/config'
import config from '@/config/axios/config'
import { MockMethod } from 'vite-plugin-mock'

const { result_code } = config
const { code } = config

const timeout = 1000

Expand Down Expand Up @@ -45,10 +45,12 @@ export default [
)

return {
code: result_code,
data: {
total: mockList.length,
list: pageList
code: code,
data: {
total: mockList.length,
list: pageList
}
}
}
}
Expand All @@ -65,14 +67,16 @@ export default [
if (user.username === data.username && user.password === data.password) {
hasUser = true
return {
code: result_code,
data: user
data: {
code: code,
data: user
}
}
}
}
if (!hasUser) {
return {
code: '500',
code: 500,
message: '账号或密码错误'
}
}
Expand All @@ -85,8 +89,10 @@ export default [
timeout,
response: () => {
return {
code: result_code,
data: null
data: {
code: code,
data: null
}
}
}
}
Expand Down

0 comments on commit 8bdac71

Please sign in to comment.