perf: 还原mock.js

This commit is contained in:
kailong321200875 2023-12-25 17:25:33 +08:00
parent a18bc641e8
commit 83de387e2a
8 changed files with 217 additions and 246 deletions

View File

@ -50,7 +50,7 @@ Online examples do not apply to menu filtering by default, but directly use Stat
- [Es6+](http://es6.ruanyifeng.com/) - Familiar with es6 basic syntax - [Es6+](http://es6.ruanyifeng.com/) - Familiar with es6 basic syntax
- [Vue-Router-Next](https://next.router.vuejs.org/) - Familiar with the basic use of vue-router - [Vue-Router-Next](https://next.router.vuejs.org/) - Familiar with the basic use of vue-router
- [Element-Plus](https://element-plus.org/) - Familiar with the basic use of element-plus - [Element-Plus](https://element-plus.org/) - Familiar with the basic use of element-plus
- [Faker.js](https://github.com/faker-js/faker#readme) - Generate massive amounts of fake contextual data - [Mock.js](https://github.com/nuysoft/Mock) - mockjs basic syntax
## Install and use ## Install and use

View File

@ -50,7 +50,7 @@ vue-element-plus-admin 的定位是后台集成方案,不太适合当基础模
- [Es6+](http://es6.ruanyifeng.com/) - 熟悉 es6 基本语法 - [Es6+](http://es6.ruanyifeng.com/) - 熟悉 es6 基本语法
- [Vue-Router-Next](https://next.router.vuejs.org/) - 熟悉 vue-router 基本使用 - [Vue-Router-Next](https://next.router.vuejs.org/) - 熟悉 vue-router 基本使用
- [Element-Plus](https://element-plus.org/) - element-plus 基本使用 - [Element-Plus](https://element-plus.org/) - element-plus 基本使用
- [Faker.js](https://github.com/faker-js/faker#readme) - 生成大量伪造的上下文数据 - [Mock.js](https://github.com/nuysoft/Mock) - mockjs 基本语法
## 安装和使用 ## 安装和使用

View File

@ -1,5 +1,5 @@
import { toAnyString } from '@/utils' import { toAnyString } from '@/utils'
import { faker } from '@faker-js/faker' import Mock from 'mockjs'
import { SUCCESS_CODE } from '@/constants' import { SUCCESS_CODE } from '@/constants'
const departmentList: any = [] const departmentList: any = []
@ -11,64 +11,71 @@ for (let i = 0; i < 5; i++) {
// 部门名称 // 部门名称
departmentName: citys[i], departmentName: citys[i],
id: toAnyString(), id: toAnyString(),
createTime: faker.date.anytime(), createTime: '@datetime',
status: faker.number.int({ min: 0, max: 1 }), // 状态
status: Mock.Random.integer(0, 1),
// 备注 // 备注
remark: faker.lorem.sentence(), remark: '@cword(10, 15)',
children: [ children: [
{ {
// 部门名称 // 部门名称
departmentName: '研发部', departmentName: '研发部',
createTime: faker.date.anytime(),
// 状态
status: faker.number.int({ min: 0, max: 1 }),
id: toAnyString(), id: toAnyString(),
remark: faker.lorem.sentence() createTime: '@datetime',
// 状态
status: Mock.Random.integer(0, 1),
// 备注
remark: '@cword(10, 15)'
}, },
{ {
// 部门名称 // 部门名称
departmentName: '产品部', departmentName: '产品部',
createTime: faker.date.anytime(),
// 状态
status: faker.number.int({ min: 0, max: 1 }),
id: toAnyString(), id: toAnyString(),
remark: faker.lorem.sentence() createTime: '@datetime',
// 状态
status: Mock.Random.integer(0, 1),
// 备注
remark: '@cword(10, 15)'
}, },
{ {
// 部门名称 // 部门名称
departmentName: '运营部', departmentName: '运营部',
createTime: faker.date.anytime(),
// 状态
status: faker.number.int({ min: 0, max: 1 }),
id: toAnyString(), id: toAnyString(),
remark: faker.lorem.sentence() createTime: '@datetime',
// 状态
status: Mock.Random.integer(0, 1),
// 备注
remark: '@cword(10, 15)'
}, },
{ {
// 部门名称 // 部门名称
departmentName: '市场部', departmentName: '市场部',
createTime: faker.date.anytime(),
// 状态
status: faker.number.int({ min: 0, max: 1 }),
id: toAnyString(), id: toAnyString(),
remark: faker.lorem.sentence() createTime: '@datetime',
// 状态
status: Mock.Random.integer(0, 1),
// 备注
remark: '@cword(10, 15)'
}, },
{ {
// 部门名称 // 部门名称
departmentName: '销售部', departmentName: '销售部',
createTime: faker.date.anytime(),
// 状态
status: faker.number.int({ min: 0, max: 1 }),
id: toAnyString(), id: toAnyString(),
remark: faker.lorem.sentence() createTime: '@datetime',
// 状态
status: Mock.Random.integer(0, 1),
// 备注
remark: '@cword(10, 15)'
}, },
{ {
// 部门名称 // 部门名称
departmentName: '客服部', departmentName: '客服部',
createTime: faker.date.anytime(),
// 状态
status: faker.number.int({ min: 0, max: 1 }),
id: toAnyString(), id: toAnyString(),
remark: faker.lorem.sentence() createTime: '@datetime',
// 状态
status: Mock.Random.integer(0, 1),
// 备注
remark: '@cword(10, 15)'
} }
] ]
}) })
@ -110,18 +117,20 @@ export default [
// 根据pageSize来创建数据 // 根据pageSize来创建数据
const mockList: any = [] const mockList: any = []
for (let i = 0; i < pageSize; i++) { for (let i = 0; i < pageSize; i++) {
mockList.push({ mockList.push(
// 用户名 Mock.mock({
username: faker.person.firstName(), // 用户名
// 账号 username: '@cname',
account: faker.person.lastName(), // 账号
// 邮箱 account: '@first',
email: faker.internet.email(), // 邮箱
// 创建时间 email: '@EMAIL',
createTime: faker.date.anytime(), // 创建时间
// 用户id createTime: '@datetime',
id: toAnyString() // 用户id
}) id: toAnyString()
})
)
} }
return { return {
code: SUCCESS_CODE, code: SUCCESS_CODE,

View File

@ -1,4 +1,4 @@
import { faker } from '@faker-js/faker' import Mock from 'mockjs'
import { SUCCESS_CODE } from '@/constants' import { SUCCESS_CODE } from '@/constants'
const timeout = 1000 const timeout = 1000
@ -19,7 +19,7 @@ export default [
component: '#', component: '#',
redirect: '/dashboard/analysis', redirect: '/dashboard/analysis',
name: 'Dashboard', name: 'Dashboard',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 1, id: 1,
type: 0, type: 0,
parentId: undefined, parentId: undefined,
@ -34,7 +34,7 @@ export default [
path: 'analysis', path: 'analysis',
component: 'views/Dashboard/Analysis', component: 'views/Dashboard/Analysis',
name: 'Analysis', name: 'Analysis',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 2, id: 2,
type: 1, type: 1,
parentId: 1, parentId: 1,
@ -59,7 +59,7 @@ export default [
path: 'workplace', path: 'workplace',
component: 'views/Dashboard/Workplace', component: 'views/Dashboard/Workplace',
name: 'Workplace', name: 'Workplace',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 3, id: 3,
type: 1, type: 1,
parentId: 1, parentId: 1,
@ -93,7 +93,7 @@ export default [
icon: 'clarity:document-solid' icon: 'clarity:document-solid'
}, },
name: 'ExternalLink', name: 'ExternalLink',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 4, id: 4,
type: 0, type: 0,
parentId: undefined, parentId: undefined,
@ -102,7 +102,7 @@ export default [
{ {
path: 'https://element-plus-admin-doc.cn/', path: 'https://element-plus-admin-doc.cn/',
name: 'DocumentLink', name: 'DocumentLink',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 5, id: 5,
type: 1, type: 1,
parentId: 4, parentId: 4,
@ -118,7 +118,7 @@ export default [
component: '#', component: '#',
redirect: '/level/menu1/menu1-1/menu1-1-1', redirect: '/level/menu1/menu1-1/menu1-1-1',
name: 'Level', name: 'Level',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 6, id: 6,
type: 0, type: 0,
parentId: undefined, parentId: undefined,
@ -132,7 +132,7 @@ export default [
path: 'menu1', path: 'menu1',
name: 'Menu1', name: 'Menu1',
component: '##', component: '##',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 7, id: 7,
type: 0, type: 0,
parentId: 6, parentId: 6,
@ -146,7 +146,7 @@ export default [
path: 'menu1-1', path: 'menu1-1',
name: 'Menu11', name: 'Menu11',
component: '##', component: '##',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 8, id: 8,
type: 0, type: 0,
parentId: 7, parentId: 7,
@ -161,7 +161,7 @@ export default [
path: 'menu1-1-1', path: 'menu1-1-1',
name: 'Menu111', name: 'Menu111',
component: 'views/Level/Menu111', component: 'views/Level/Menu111',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 9, id: 9,
type: 1, type: 1,
parentId: 8, parentId: 8,
@ -176,7 +176,7 @@ export default [
path: 'menu1-2', path: 'menu1-2',
name: 'Menu12', name: 'Menu12',
component: 'views/Level/Menu12', component: 'views/Level/Menu12',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 10, id: 10,
type: 1, type: 1,
parentId: 7, parentId: 7,
@ -191,7 +191,7 @@ export default [
path: 'menu2', path: 'menu2',
name: 'Menu2Demo', name: 'Menu2Demo',
component: 'views/Level/Menu2', component: 'views/Level/Menu2',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 11, id: 11,
type: 1, type: 1,
parentId: 6, parentId: 6,
@ -207,7 +207,7 @@ export default [
component: '#', component: '#',
redirect: '/example/example-dialog', redirect: '/example/example-dialog',
name: 'Example', name: 'Example',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 12, id: 12,
type: 0, type: 0,
parentId: undefined, parentId: undefined,
@ -222,7 +222,7 @@ export default [
path: 'example-dialog', path: 'example-dialog',
component: 'views/Example/Dialog/ExampleDialog', component: 'views/Example/Dialog/ExampleDialog',
name: 'ExampleDialog', name: 'ExampleDialog',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 13, id: 13,
type: 1, type: 1,
parentId: 12, parentId: 12,
@ -253,7 +253,7 @@ export default [
path: 'example-page', path: 'example-page',
component: 'views/Example/Page/ExamplePage', component: 'views/Example/Page/ExamplePage',
name: 'ExamplePage', name: 'ExamplePage',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 14, id: 14,
type: 1, type: 1,
parentId: 12, parentId: 12,
@ -284,7 +284,7 @@ export default [
path: 'example-add', path: 'example-add',
component: 'views/Example/Page/ExampleAdd', component: 'views/Example/Page/ExampleAdd',
name: 'ExampleAdd', name: 'ExampleAdd',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 15, id: 15,
type: 1, type: 1,
parentId: 12, parentId: 12,
@ -302,7 +302,7 @@ export default [
path: 'example-edit', path: 'example-edit',
component: 'views/Example/Page/ExampleEdit', component: 'views/Example/Page/ExampleEdit',
name: 'ExampleEdit', name: 'ExampleEdit',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 16, id: 16,
type: 1, type: 1,
parentId: 12, parentId: 12,
@ -320,7 +320,7 @@ export default [
path: 'example-detail', path: 'example-detail',
component: 'views/Example/Page/ExampleDetail', component: 'views/Example/Page/ExampleDetail',
name: 'ExampleDetail', name: 'ExampleDetail',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 17, id: 17,
type: 1, type: 1,
parentId: 12, parentId: 12,

View File

@ -1,4 +1,4 @@
import { faker } from '@faker-js/faker' import Mock from 'mockjs'
import { SUCCESS_CODE } from '@/constants' import { SUCCESS_CODE } from '@/constants'
import { toAnyString } from '@/utils' import { toAnyString } from '@/utils'
@ -731,7 +731,7 @@ const menus = [
component: '#', component: '#',
redirect: '/dashboard/analysis', redirect: '/dashboard/analysis',
name: 'Dashboard', name: 'Dashboard',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 1, id: 1,
meta: { meta: {
title: '首页', title: '首页',
@ -743,7 +743,7 @@ const menus = [
path: 'analysis', path: 'analysis',
component: 'views/Dashboard/Analysis', component: 'views/Dashboard/Analysis',
name: 'Analysis', name: 'Analysis',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 2, id: 2,
meta: { meta: {
title: '分析页', title: '分析页',
@ -754,7 +754,7 @@ const menus = [
path: 'workplace', path: 'workplace',
component: 'views/Dashboard/Workplace', component: 'views/Dashboard/Workplace',
name: 'Workplace', name: 'Workplace',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 3, id: 3,
meta: { meta: {
title: '工作台', title: '工作台',
@ -771,13 +771,13 @@ const menus = [
icon: 'clarity:document-solid' icon: 'clarity:document-solid'
}, },
name: 'ExternalLink', name: 'ExternalLink',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 4, id: 4,
children: [ children: [
{ {
path: 'https://element-plus-admin-doc.cn/', path: 'https://element-plus-admin-doc.cn/',
name: 'DocumentLink', name: 'DocumentLink',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 5, id: 5,
meta: { meta: {
title: '文档' title: '文档'
@ -790,7 +790,7 @@ const menus = [
component: '#', component: '#',
redirect: '/level/menu1/menu1-1/menu1-1-1', redirect: '/level/menu1/menu1-1/menu1-1-1',
name: 'Level', name: 'Level',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 6, id: 6,
meta: { meta: {
title: '菜单', title: '菜单',
@ -801,7 +801,7 @@ const menus = [
path: 'menu1', path: 'menu1',
name: 'Menu1', name: 'Menu1',
component: '##', component: '##',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 7, id: 7,
redirect: '/level/menu1/menu1-1/menu1-1-1', redirect: '/level/menu1/menu1-1/menu1-1-1',
meta: { meta: {
@ -812,7 +812,7 @@ const menus = [
path: 'menu1-1', path: 'menu1-1',
name: 'Menu11', name: 'Menu11',
component: '##', component: '##',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 8, id: 8,
redirect: '/level/menu1/menu1-1/menu1-1-1', redirect: '/level/menu1/menu1-1/menu1-1-1',
meta: { meta: {
@ -824,7 +824,7 @@ const menus = [
path: 'menu1-1-1', path: 'menu1-1-1',
name: 'Menu111', name: 'Menu111',
component: 'views/Level/Menu111', component: 'views/Level/Menu111',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 9, id: 9,
permission: ['edit', 'add', 'delete'], permission: ['edit', 'add', 'delete'],
meta: { meta: {
@ -838,7 +838,7 @@ const menus = [
path: 'menu1-2', path: 'menu1-2',
name: 'Menu12', name: 'Menu12',
component: 'views/Level/Menu12', component: 'views/Level/Menu12',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 10, id: 10,
permission: ['edit', 'add', 'delete'], permission: ['edit', 'add', 'delete'],
meta: { meta: {
@ -852,7 +852,7 @@ const menus = [
path: 'menu2', path: 'menu2',
name: 'Menu2Demo', name: 'Menu2Demo',
component: 'views/Level/Menu2', component: 'views/Level/Menu2',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 11, id: 11,
permission: ['edit', 'add', 'delete'], permission: ['edit', 'add', 'delete'],
meta: { meta: {
@ -867,7 +867,7 @@ const menus = [
component: '#', component: '#',
redirect: '/example/example-dialog', redirect: '/example/example-dialog',
name: 'Example', name: 'Example',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 12, id: 12,
meta: { meta: {
title: '综合示例', title: '综合示例',
@ -879,7 +879,7 @@ const menus = [
path: 'example-dialog', path: 'example-dialog',
component: 'views/Example/Dialog/ExampleDialog', component: 'views/Example/Dialog/ExampleDialog',
name: 'ExampleDialog', name: 'ExampleDialog',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 13, id: 13,
permission: ['edit', 'add', 'delete'], permission: ['edit', 'add', 'delete'],
meta: { meta: {
@ -891,7 +891,7 @@ const menus = [
path: 'example-page', path: 'example-page',
component: 'views/Example/Page/ExamplePage', component: 'views/Example/Page/ExamplePage',
name: 'ExamplePage', name: 'ExamplePage',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 14, id: 14,
permission: ['edit', 'add', 'delete'], permission: ['edit', 'add', 'delete'],
meta: { meta: {
@ -903,7 +903,7 @@ const menus = [
path: 'example-add', path: 'example-add',
component: 'views/Example/Page/ExampleAdd', component: 'views/Example/Page/ExampleAdd',
name: 'ExampleAdd', name: 'ExampleAdd',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 15, id: 15,
permission: ['edit', 'add', 'delete'], permission: ['edit', 'add', 'delete'],
meta: { meta: {
@ -920,7 +920,7 @@ const menus = [
path: 'example-edit', path: 'example-edit',
component: 'views/Example/Page/ExampleEdit', component: 'views/Example/Page/ExampleEdit',
name: 'ExampleEdit', name: 'ExampleEdit',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 16, id: 16,
permission: ['edit', 'add', 'delete'], permission: ['edit', 'add', 'delete'],
meta: { meta: {
@ -937,7 +937,7 @@ const menus = [
path: 'example-detail', path: 'example-detail',
component: 'views/Example/Page/ExampleDetail', component: 'views/Example/Page/ExampleDetail',
name: 'ExampleDetail', name: 'ExampleDetail',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 17, id: 17,
permission: ['edit', 'add', 'delete'], permission: ['edit', 'add', 'delete'],
meta: { meta: {
@ -959,7 +959,7 @@ const menus = [
component: '#', component: '#',
redirect: '/dashboard/analysis', redirect: '/dashboard/analysis',
name: 'Dashboard', name: 'Dashboard',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 1, id: 1,
meta: { meta: {
title: '首页', title: '首页',
@ -971,7 +971,7 @@ const menus = [
path: 'analysis', path: 'analysis',
component: 'views/Dashboard/Analysis', component: 'views/Dashboard/Analysis',
name: 'Analysis', name: 'Analysis',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 2, id: 2,
meta: { meta: {
title: '分析页', title: '分析页',
@ -982,7 +982,7 @@ const menus = [
path: 'workplace', path: 'workplace',
component: 'views/Dashboard/Workplace', component: 'views/Dashboard/Workplace',
name: 'Workplace', name: 'Workplace',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 3, id: 3,
meta: { meta: {
title: '工作台', title: '工作台',
@ -1001,13 +1001,13 @@ const menus = [
icon: 'clarity:document-solid' icon: 'clarity:document-solid'
}, },
name: 'ExternalLink', name: 'ExternalLink',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 4, id: 4,
children: [ children: [
{ {
path: 'https://element-plus-admin-doc.cn/', path: 'https://element-plus-admin-doc.cn/',
name: 'DocumentLink', name: 'DocumentLink',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 5, id: 5,
meta: { meta: {
title: '文档' title: '文档'
@ -1020,7 +1020,7 @@ const menus = [
component: '#', component: '#',
redirect: '/level/menu1/menu1-1/menu1-1-1', redirect: '/level/menu1/menu1-1/menu1-1-1',
name: 'Level', name: 'Level',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 6, id: 6,
meta: { meta: {
title: '菜单', title: '菜单',
@ -1031,7 +1031,7 @@ const menus = [
path: 'menu1', path: 'menu1',
name: 'Menu1', name: 'Menu1',
component: '##', component: '##',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 7, id: 7,
redirect: '/level/menu1/menu1-1/menu1-1-1', redirect: '/level/menu1/menu1-1/menu1-1-1',
meta: { meta: {
@ -1042,7 +1042,7 @@ const menus = [
path: 'menu1-1', path: 'menu1-1',
name: 'Menu11', name: 'Menu11',
component: '##', component: '##',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 8, id: 8,
redirect: '/level/menu1/menu1-1/menu1-1-1', redirect: '/level/menu1/menu1-1/menu1-1-1',
meta: { meta: {
@ -1054,7 +1054,7 @@ const menus = [
path: 'menu1-1-1', path: 'menu1-1-1',
name: 'Menu111', name: 'Menu111',
component: 'views/Level/Menu111', component: 'views/Level/Menu111',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 9, id: 9,
permission: ['edit', 'add', 'delete'], permission: ['edit', 'add', 'delete'],
meta: { meta: {
@ -1068,7 +1068,7 @@ const menus = [
path: 'menu1-2', path: 'menu1-2',
name: 'Menu12', name: 'Menu12',
component: 'views/Level/Menu12', component: 'views/Level/Menu12',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 10, id: 10,
permission: ['edit', 'add', 'delete'], permission: ['edit', 'add', 'delete'],
meta: { meta: {
@ -1082,7 +1082,7 @@ const menus = [
path: 'menu2', path: 'menu2',
name: 'Menu2Demo', name: 'Menu2Demo',
component: 'views/Level/Menu2', component: 'views/Level/Menu2',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 11, id: 11,
permission: ['edit', 'add', 'delete'], permission: ['edit', 'add', 'delete'],
meta: { meta: {
@ -1099,7 +1099,7 @@ const menus = [
component: '#', component: '#',
redirect: '/example/example-dialog', redirect: '/example/example-dialog',
name: 'Example', name: 'Example',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 12, id: 12,
meta: { meta: {
title: '综合示例', title: '综合示例',
@ -1111,7 +1111,7 @@ const menus = [
path: 'example-detail', path: 'example-detail',
component: 'views/Example/Page/ExampleDetail', component: 'views/Example/Page/ExampleDetail',
name: 'ExampleDetail', name: 'ExampleDetail',
status: faker.number.int({ min: 0, max: 1 }), status: Mock.Random.integer(0, 1),
id: 17, id: 17,
permission: ['edit', 'add', 'delete'], permission: ['edit', 'add', 'delete'],
meta: { meta: {
@ -1130,16 +1130,18 @@ const menus = [
] ]
for (let i = 0; i < 4; i++) { for (let i = 0; i < 4; i++) {
List.push({ List.push(
id: toAnyString(), Mock.mock({
// timestamp: +Mock.Random.date('T'), id: toAnyString(),
roleName: roleNames[i], // timestamp: +Mock.Random.date('T'),
role: faker.lorem.sentence(1), roleName: roleNames[i],
status: faker.number.int({ min: 0, max: 1 }), role: '@first',
createTime: faker.date.anytime(), status: Mock.Random.integer(0, 1),
remark: faker.lorem.sentence(), createTime: '@datetime',
menu: menus[i] remark: '@cword(10, 15)',
}) menu: menus[i]
})
)
} }
export default [ export default [

View File

@ -1,4 +1,4 @@
import { faker } from '@faker-js/faker' import Mock from 'mockjs'
import { SUCCESS_CODE } from '@/constants' import { SUCCESS_CODE } from '@/constants'
import { toAnyString } from '@/utils' import { toAnyString } from '@/utils'
@ -36,144 +36,103 @@ interface TreeListProps {
let List: ListProps[] = [] let List: ListProps[] = []
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
List.push({ List.push(
id: toAnyString(), Mock.mock({
// timestamp: +Mock.Random.date('T'), id: toAnyString(),
author: faker.person.firstName(), // timestamp: +Mock.Random.date('T'),
title: faker.lorem.sentence(), author: '@first',
content: baseContent, title: '@title(5, 10)',
importance: faker.number.int({ min: 1, max: 3 }), content: baseContent,
display_time: faker.date.anytime(), importance: '@integer(1, 3)',
pageviews: faker.number.int({ min: 300, max: 5000 }), display_time: '@datetime',
image_uri: faker.image.url({ pageviews: '@integer(100, 500)',
width: faker.number.int({ min: 200, max: 400 }), image_uri: Mock.Random.image('@integer(100, 500)x@integer(100, 500)'),
height: faker.number.int({ min: 200, max: 400 }) video_uri:
}), '//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4'
video_uri: })
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4' )
})
} }
const treeList: TreeListProps[] = [] const treeList: TreeListProps[] = []
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
treeList.push({ treeList.push(
id: toAnyString(), Mock.mock({
// timestamp: +Mock.Random.date('T'), id: toAnyString(),
author: faker.person.firstName(), // timestamp: +Mock.Random.date('T'),
title: faker.lorem.sentence(), author: '@first',
content: baseContent, title: '@title(5, 10)',
importance: faker.number.int({ min: 1, max: 3 }), content: baseContent,
display_time: faker.date.anytime(), importance: '@integer(1, 3)',
pageviews: faker.number.int({ min: 300, max: 5000 }), display_time: '@datetime',
image_uri: faker.image.url({ pageviews: '@integer(300, 5000)',
width: faker.number.int({ min: 200, max: 400 }), children: [
height: faker.number.int({ min: 200, max: 400 }) {
}), id: toAnyString(),
video_uri: // timestamp: +Mock.Random.date('T'),
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4', author: '@first',
children: [ title: '@title(5, 10)',
{ content: baseContent,
id: toAnyString(), importance: '@integer(1, 3)',
// timestamp: +Mock.Random.date('T'), display_time: '@datetime',
author: faker.person.firstName(), pageviews: '@integer(300, 5000)',
title: faker.lorem.sentence(), children: [
content: baseContent, {
importance: faker.number.int({ min: 1, max: 3 }), id: toAnyString(),
display_time: faker.date.anytime(), // timestamp: +Mock.Random.date('T'),
pageviews: faker.number.int({ min: 300, max: 5000 }), author: '@first',
image_uri: faker.image.url({ title: '@title(5, 10)',
width: faker.number.int({ min: 200, max: 400 }), content: baseContent,
height: faker.number.int({ min: 200, max: 400 }) importance: '@integer(1, 3)',
}), display_time: '@datetime',
video_uri: pageviews: '@integer(300, 5000)'
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4', },
children: [ {
{ id: toAnyString(),
id: toAnyString(), // timestamp: +Mock.Random.date('T'),
// timestamp: +Mock.Random.date('T'), author: '@first',
author: faker.person.firstName(), title: '@title(5, 10)',
title: faker.lorem.sentence(), content: baseContent,
content: baseContent, importance: '@integer(1, 3)',
importance: faker.number.int({ min: 1, max: 3 }), display_time: '@datetime',
display_time: faker.date.anytime(), pageviews: '@integer(300, 5000)'
pageviews: faker.number.int({ min: 300, max: 5000 }), }
image_uri: faker.image.url({ ]
width: faker.number.int({ min: 200, max: 400 }), },
height: faker.number.int({ min: 200, max: 400 }) {
}), id: toAnyString(),
video_uri: // timestamp: +Mock.Random.date('T'),
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4' author: '@first',
}, title: '@title(5, 10)',
{ content: baseContent,
id: toAnyString(), importance: '@integer(1, 3)',
// timestamp: +Mock.Random.date('T'), display_time: '@datetime',
author: faker.person.firstName(), pageviews: '@integer(300, 5000)'
title: faker.lorem.sentence(), },
content: baseContent, {
importance: faker.number.int({ min: 1, max: 3 }), id: toAnyString(),
display_time: faker.date.anytime(), // timestamp: +Mock.Random.date('T'),
pageviews: faker.number.int({ min: 300, max: 5000 }), author: '@first',
image_uri: faker.image.url({ title: '@title(5, 10)',
width: faker.number.int({ min: 200, max: 400 }), content: baseContent,
height: faker.number.int({ min: 200, max: 400 }) importance: '@integer(1, 3)',
}), display_time: '@datetime',
video_uri: pageviews: '@integer(300, 5000)'
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4' },
} {
] id: toAnyString(),
}, // timestamp: +Mock.Random.date('T'),
{ author: '@first',
id: toAnyString(), title: '@title(5, 10)',
// timestamp: +Mock.Random.date('T'), content: baseContent,
author: faker.person.firstName(), importance: '@integer(1, 3)',
title: faker.lorem.sentence(), display_time: '@datetime',
content: baseContent, pageviews: '@integer(300, 5000)'
importance: faker.number.int({ min: 1, max: 3 }), }
display_time: faker.date.anytime(), ]
pageviews: faker.number.int({ min: 300, max: 5000 }), // image_uri
image_uri: faker.image.url({ })
width: faker.number.int({ min: 200, max: 400 }), )
height: faker.number.int({ min: 200, max: 400 })
}),
video_uri:
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4'
},
{
id: toAnyString(),
// timestamp: +Mock.Random.date('T'),
author: faker.person.firstName(),
title: faker.lorem.sentence(),
content: baseContent,
importance: faker.number.int({ min: 1, max: 3 }),
display_time: faker.date.anytime(),
pageviews: faker.number.int({ min: 300, max: 5000 }),
image_uri: faker.image.url({
width: faker.number.int({ min: 200, max: 400 }),
height: faker.number.int({ min: 200, max: 400 })
}),
video_uri:
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4'
},
{
id: toAnyString(),
// timestamp: +Mock.Random.date('T'),
author: faker.person.firstName(),
title: faker.lorem.sentence(),
content: baseContent,
importance: faker.number.int({ min: 1, max: 3 }),
display_time: faker.date.anytime(),
pageviews: faker.number.int({ min: 300, max: 5000 }),
image_uri: faker.image.url({
width: faker.number.int({ min: 200, max: 400 }),
height: faker.number.int({ min: 200, max: 400 })
}),
video_uri:
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4'
}
]
// image_uri
})
} }
const cardList = [ const cardList = [

View File

@ -27,7 +27,6 @@
"icon": "esno ./scripts/icon.ts" "icon": "esno ./scripts/icon.ts"
}, },
"dependencies": { "dependencies": {
"@faker-js/faker": "^8.3.1",
"@iconify/iconify": "^3.1.1", "@iconify/iconify": "^3.1.1",
"@iconify/vue": "^4.1.1", "@iconify/vue": "^4.1.1",
"@vueuse/core": "^10.7.0", "@vueuse/core": "^10.7.0",
@ -66,6 +65,7 @@
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"@types/inquirer": "^9.0.7", "@types/inquirer": "^9.0.7",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/mockjs": "^1.0.10",
"@types/node": "^20.10.5", "@types/node": "^20.10.5",
"@types/nprogress": "^0.2.3", "@types/nprogress": "^0.2.3",
"@types/qrcode": "^1.5.5", "@types/qrcode": "^1.5.5",
@ -91,6 +91,7 @@
"inquirer": "^9.2.12", "inquirer": "^9.2.12",
"less": "^4.2.0", "less": "^4.2.0",
"lint-staged": "^15.2.0", "lint-staged": "^15.2.0",
"mockjs": "^1.1.0",
"plop": "^4.0.0", "plop": "^4.0.0",
"postcss": "^8.4.32", "postcss": "^8.4.32",
"postcss-html": "^1.5.0", "postcss-html": "^1.5.0",

View File

@ -2,7 +2,7 @@
import { Waterfall } from '@/components/Waterfall' import { Waterfall } from '@/components/Waterfall'
import { ContentWrap } from '@/components/ContentWrap' import { ContentWrap } from '@/components/ContentWrap'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { faker } from '@faker-js/faker' import Mock from 'mockjs'
import { ref, unref } from 'vue' import { ref, unref } from 'vue'
import { toAnyString } from '@/utils' import { toAnyString } from '@/utils'
@ -12,17 +12,17 @@ const getList = () => {
const list: any = [] const list: any = []
for (let i = 0; i < 20; i++) { for (let i = 0; i < 20; i++) {
// 100, 500 // 100, 500
const height = faker.number.int({ min: 100, max: 500 }) const height = Mock.Random.integer(100, 500)
const width = faker.number.int({ min: 100, max: 500 }) const width = Mock.Random.integer(100, 500)
list.push({ list.push(
width, Mock.mock({
height,
id: toAnyString(),
image_uri: faker.image.url({
width, width,
height height,
id: toAnyString(),
// httphttps
image_uri: Mock.Random.image(`${width}x${height}`).replace('http://', 'https://')
}) })
}) )
} }
data.value = [...unref(data), ...list] data.value = [...unref(data), ...list]
if (unref(data).length >= 60) { if (unref(data).length >= 60) {