feat: 替换mockjs
This commit is contained in:
parent
b8f9a9940d
commit
7c76d945be
|
@ -1,7 +1,7 @@
|
|||
import config from '@/config/axios/config'
|
||||
|
||||
import { toAnyString } from '@/utils'
|
||||
import Mock from 'mockjs'
|
||||
import { faker } from '@faker-js/faker'
|
||||
|
||||
const { code } = config
|
||||
|
||||
|
@ -14,65 +14,64 @@ for (let i = 0; i < 5; i++) {
|
|||
// 部门名称
|
||||
departmentName: citys[i],
|
||||
id: toAnyString(),
|
||||
createTime: '@datetime',
|
||||
// 状态
|
||||
status: Mock.Random.integer(0, 1),
|
||||
createTime: faker.date.anytime(),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
// 备注
|
||||
remark: '@cword(10, 15)',
|
||||
remark: faker.lorem.sentence(),
|
||||
children: [
|
||||
{
|
||||
// 部门名称
|
||||
departmentName: '研发部',
|
||||
createTime: '@datetime',
|
||||
createTime: faker.date.anytime(),
|
||||
// 状态
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: toAnyString(),
|
||||
remark: '@cword(10, 15)'
|
||||
remark: faker.lorem.sentence()
|
||||
},
|
||||
{
|
||||
// 部门名称
|
||||
departmentName: '产品部',
|
||||
createTime: '@datetime',
|
||||
createTime: faker.date.anytime(),
|
||||
// 状态
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: toAnyString(),
|
||||
remark: '@cword(10, 15)'
|
||||
remark: faker.lorem.sentence()
|
||||
},
|
||||
{
|
||||
// 部门名称
|
||||
departmentName: '运营部',
|
||||
createTime: '@datetime',
|
||||
createTime: faker.date.anytime(),
|
||||
// 状态
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: toAnyString(),
|
||||
remark: '@cword(10, 15)'
|
||||
remark: faker.lorem.sentence()
|
||||
},
|
||||
{
|
||||
// 部门名称
|
||||
departmentName: '市场部',
|
||||
createTime: '@datetime',
|
||||
createTime: faker.date.anytime(),
|
||||
// 状态
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: toAnyString(),
|
||||
remark: '@cword(10, 15)'
|
||||
remark: faker.lorem.sentence()
|
||||
},
|
||||
{
|
||||
// 部门名称
|
||||
departmentName: '销售部',
|
||||
createTime: '@datetime',
|
||||
createTime: faker.date.anytime(),
|
||||
// 状态
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: toAnyString(),
|
||||
remark: '@cword(10, 15)'
|
||||
remark: faker.lorem.sentence()
|
||||
},
|
||||
{
|
||||
// 部门名称
|
||||
departmentName: '客服部',
|
||||
createTime: '@datetime',
|
||||
createTime: faker.date.anytime(),
|
||||
// 状态
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: toAnyString(),
|
||||
remark: '@cword(10, 15)'
|
||||
remark: faker.lorem.sentence()
|
||||
}
|
||||
]
|
||||
})
|
||||
|
@ -114,20 +113,18 @@ export default [
|
|||
// 根据pageSize来创建数据
|
||||
const mockList: any = []
|
||||
for (let i = 0; i < pageSize; i++) {
|
||||
mockList.push(
|
||||
Mock.mock({
|
||||
// 用户名
|
||||
username: '@cname',
|
||||
// 账号
|
||||
account: '@first',
|
||||
// 邮箱
|
||||
email: '@EMAIL',
|
||||
// 创建时间
|
||||
createTime: '@datetime',
|
||||
// 用户id
|
||||
id: toAnyString()
|
||||
})
|
||||
)
|
||||
mockList.push({
|
||||
// 用户名
|
||||
username: faker.person.firstName(),
|
||||
// 账号
|
||||
account: faker.person.lastName(),
|
||||
// 邮箱
|
||||
email: faker.internet.email(),
|
||||
// 创建时间
|
||||
createTime: faker.date.anytime(),
|
||||
// 用户id
|
||||
id: toAnyString()
|
||||
})
|
||||
}
|
||||
return {
|
||||
code: code,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import config from '@/config/axios/config'
|
||||
|
||||
import Mock from 'mockjs'
|
||||
import { faker } from '@faker-js/faker'
|
||||
|
||||
const { code } = config
|
||||
|
||||
|
@ -22,7 +21,7 @@ export default [
|
|||
component: '#',
|
||||
redirect: '/dashboard/analysis',
|
||||
name: 'Dashboard',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 1,
|
||||
type: 0,
|
||||
parentId: undefined,
|
||||
|
@ -37,7 +36,7 @@ export default [
|
|||
path: 'analysis',
|
||||
component: 'views/Dashboard/Analysis',
|
||||
name: 'Analysis',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 2,
|
||||
type: 1,
|
||||
parentId: 1,
|
||||
|
@ -62,7 +61,7 @@ export default [
|
|||
path: 'workplace',
|
||||
component: 'views/Dashboard/Workplace',
|
||||
name: 'Workplace',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 3,
|
||||
type: 1,
|
||||
parentId: 1,
|
||||
|
@ -96,7 +95,7 @@ export default [
|
|||
icon: 'clarity:document-solid'
|
||||
},
|
||||
name: 'ExternalLink',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 4,
|
||||
type: 0,
|
||||
parentId: undefined,
|
||||
|
@ -105,7 +104,7 @@ export default [
|
|||
{
|
||||
path: 'https://element-plus-admin-doc.cn/',
|
||||
name: 'DocumentLink',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 5,
|
||||
type: 1,
|
||||
parentId: 4,
|
||||
|
@ -121,7 +120,7 @@ export default [
|
|||
component: '#',
|
||||
redirect: '/level/menu1/menu1-1/menu1-1-1',
|
||||
name: 'Level',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 6,
|
||||
type: 0,
|
||||
parentId: undefined,
|
||||
|
@ -135,7 +134,7 @@ export default [
|
|||
path: 'menu1',
|
||||
name: 'Menu1',
|
||||
component: '##',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 7,
|
||||
type: 0,
|
||||
parentId: 6,
|
||||
|
@ -149,7 +148,7 @@ export default [
|
|||
path: 'menu1-1',
|
||||
name: 'Menu11',
|
||||
component: '##',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 8,
|
||||
type: 0,
|
||||
parentId: 7,
|
||||
|
@ -164,7 +163,7 @@ export default [
|
|||
path: 'menu1-1-1',
|
||||
name: 'Menu111',
|
||||
component: 'views/Level/Menu111',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 9,
|
||||
type: 1,
|
||||
parentId: 8,
|
||||
|
@ -179,7 +178,7 @@ export default [
|
|||
path: 'menu1-2',
|
||||
name: 'Menu12',
|
||||
component: 'views/Level/Menu12',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 10,
|
||||
type: 1,
|
||||
parentId: 7,
|
||||
|
@ -194,7 +193,7 @@ export default [
|
|||
path: 'menu2',
|
||||
name: 'Menu2Demo',
|
||||
component: 'views/Level/Menu2',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 11,
|
||||
type: 1,
|
||||
parentId: 6,
|
||||
|
@ -210,7 +209,7 @@ export default [
|
|||
component: '#',
|
||||
redirect: '/example/example-dialog',
|
||||
name: 'Example',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 12,
|
||||
type: 0,
|
||||
parentId: undefined,
|
||||
|
@ -225,7 +224,7 @@ export default [
|
|||
path: 'example-dialog',
|
||||
component: 'views/Example/Dialog/ExampleDialog',
|
||||
name: 'ExampleDialog',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 13,
|
||||
type: 1,
|
||||
parentId: 12,
|
||||
|
@ -256,7 +255,7 @@ export default [
|
|||
path: 'example-page',
|
||||
component: 'views/Example/Page/ExamplePage',
|
||||
name: 'ExamplePage',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 14,
|
||||
type: 1,
|
||||
parentId: 12,
|
||||
|
@ -287,7 +286,7 @@ export default [
|
|||
path: 'example-add',
|
||||
component: 'views/Example/Page/ExampleAdd',
|
||||
name: 'ExampleAdd',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 15,
|
||||
type: 1,
|
||||
parentId: 12,
|
||||
|
@ -305,7 +304,7 @@ export default [
|
|||
path: 'example-edit',
|
||||
component: 'views/Example/Page/ExampleEdit',
|
||||
name: 'ExampleEdit',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 16,
|
||||
type: 1,
|
||||
parentId: 12,
|
||||
|
@ -323,7 +322,7 @@ export default [
|
|||
path: 'example-detail',
|
||||
component: 'views/Example/Page/ExampleDetail',
|
||||
name: 'ExampleDetail',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 17,
|
||||
type: 1,
|
||||
parentId: 12,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import config from '@/config/axios/config'
|
||||
import { faker } from '@faker-js/faker'
|
||||
|
||||
import Mock from 'mockjs'
|
||||
import { toAnyString } from '@/utils'
|
||||
|
||||
const { code } = config
|
||||
|
@ -723,7 +723,7 @@ const menus = [
|
|||
component: '#',
|
||||
redirect: '/dashboard/analysis',
|
||||
name: 'Dashboard',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 1,
|
||||
meta: {
|
||||
title: '首页',
|
||||
|
@ -735,7 +735,7 @@ const menus = [
|
|||
path: 'analysis',
|
||||
component: 'views/Dashboard/Analysis',
|
||||
name: 'Analysis',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 2,
|
||||
meta: {
|
||||
title: '分析页',
|
||||
|
@ -746,7 +746,7 @@ const menus = [
|
|||
path: 'workplace',
|
||||
component: 'views/Dashboard/Workplace',
|
||||
name: 'Workplace',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 3,
|
||||
meta: {
|
||||
title: '工作台',
|
||||
|
@ -763,13 +763,13 @@ const menus = [
|
|||
icon: 'clarity:document-solid'
|
||||
},
|
||||
name: 'ExternalLink',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 4,
|
||||
children: [
|
||||
{
|
||||
path: 'https://element-plus-admin-doc.cn/',
|
||||
name: 'DocumentLink',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 5,
|
||||
meta: {
|
||||
title: '文档'
|
||||
|
@ -782,7 +782,7 @@ const menus = [
|
|||
component: '#',
|
||||
redirect: '/level/menu1/menu1-1/menu1-1-1',
|
||||
name: 'Level',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 6,
|
||||
meta: {
|
||||
title: '菜单',
|
||||
|
@ -793,7 +793,7 @@ const menus = [
|
|||
path: 'menu1',
|
||||
name: 'Menu1',
|
||||
component: '##',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 7,
|
||||
redirect: '/level/menu1/menu1-1/menu1-1-1',
|
||||
meta: {
|
||||
|
@ -804,7 +804,7 @@ const menus = [
|
|||
path: 'menu1-1',
|
||||
name: 'Menu11',
|
||||
component: '##',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 8,
|
||||
redirect: '/level/menu1/menu1-1/menu1-1-1',
|
||||
meta: {
|
||||
|
@ -816,7 +816,7 @@ const menus = [
|
|||
path: 'menu1-1-1',
|
||||
name: 'Menu111',
|
||||
component: 'views/Level/Menu111',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 9,
|
||||
permission: ['edit', 'add', 'delete'],
|
||||
meta: {
|
||||
|
@ -830,7 +830,7 @@ const menus = [
|
|||
path: 'menu1-2',
|
||||
name: 'Menu12',
|
||||
component: 'views/Level/Menu12',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 10,
|
||||
permission: ['edit', 'add', 'delete'],
|
||||
meta: {
|
||||
|
@ -844,7 +844,7 @@ const menus = [
|
|||
path: 'menu2',
|
||||
name: 'Menu2Demo',
|
||||
component: 'views/Level/Menu2',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 11,
|
||||
permission: ['edit', 'add', 'delete'],
|
||||
meta: {
|
||||
|
@ -859,7 +859,7 @@ const menus = [
|
|||
component: '#',
|
||||
redirect: '/example/example-dialog',
|
||||
name: 'Example',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 12,
|
||||
meta: {
|
||||
title: '综合示例',
|
||||
|
@ -871,7 +871,7 @@ const menus = [
|
|||
path: 'example-dialog',
|
||||
component: 'views/Example/Dialog/ExampleDialog',
|
||||
name: 'ExampleDialog',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 13,
|
||||
permission: ['edit', 'add', 'delete'],
|
||||
meta: {
|
||||
|
@ -883,7 +883,7 @@ const menus = [
|
|||
path: 'example-page',
|
||||
component: 'views/Example/Page/ExamplePage',
|
||||
name: 'ExamplePage',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 14,
|
||||
permission: ['edit', 'add', 'delete'],
|
||||
meta: {
|
||||
|
@ -895,7 +895,7 @@ const menus = [
|
|||
path: 'example-add',
|
||||
component: 'views/Example/Page/ExampleAdd',
|
||||
name: 'ExampleAdd',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 15,
|
||||
permission: ['edit', 'add', 'delete'],
|
||||
meta: {
|
||||
|
@ -912,7 +912,7 @@ const menus = [
|
|||
path: 'example-edit',
|
||||
component: 'views/Example/Page/ExampleEdit',
|
||||
name: 'ExampleEdit',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 16,
|
||||
permission: ['edit', 'add', 'delete'],
|
||||
meta: {
|
||||
|
@ -929,7 +929,7 @@ const menus = [
|
|||
path: 'example-detail',
|
||||
component: 'views/Example/Page/ExampleDetail',
|
||||
name: 'ExampleDetail',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 17,
|
||||
permission: ['edit', 'add', 'delete'],
|
||||
meta: {
|
||||
|
@ -951,7 +951,7 @@ const menus = [
|
|||
component: '#',
|
||||
redirect: '/dashboard/analysis',
|
||||
name: 'Dashboard',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 1,
|
||||
meta: {
|
||||
title: '首页',
|
||||
|
@ -963,7 +963,7 @@ const menus = [
|
|||
path: 'analysis',
|
||||
component: 'views/Dashboard/Analysis',
|
||||
name: 'Analysis',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 2,
|
||||
meta: {
|
||||
title: '分析页',
|
||||
|
@ -974,7 +974,7 @@ const menus = [
|
|||
path: 'workplace',
|
||||
component: 'views/Dashboard/Workplace',
|
||||
name: 'Workplace',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 3,
|
||||
meta: {
|
||||
title: '工作台',
|
||||
|
@ -993,13 +993,13 @@ const menus = [
|
|||
icon: 'clarity:document-solid'
|
||||
},
|
||||
name: 'ExternalLink',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 4,
|
||||
children: [
|
||||
{
|
||||
path: 'https://element-plus-admin-doc.cn/',
|
||||
name: 'DocumentLink',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 5,
|
||||
meta: {
|
||||
title: '文档'
|
||||
|
@ -1012,7 +1012,7 @@ const menus = [
|
|||
component: '#',
|
||||
redirect: '/level/menu1/menu1-1/menu1-1-1',
|
||||
name: 'Level',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 6,
|
||||
meta: {
|
||||
title: '菜单',
|
||||
|
@ -1023,7 +1023,7 @@ const menus = [
|
|||
path: 'menu1',
|
||||
name: 'Menu1',
|
||||
component: '##',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 7,
|
||||
redirect: '/level/menu1/menu1-1/menu1-1-1',
|
||||
meta: {
|
||||
|
@ -1034,7 +1034,7 @@ const menus = [
|
|||
path: 'menu1-1',
|
||||
name: 'Menu11',
|
||||
component: '##',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 8,
|
||||
redirect: '/level/menu1/menu1-1/menu1-1-1',
|
||||
meta: {
|
||||
|
@ -1046,7 +1046,7 @@ const menus = [
|
|||
path: 'menu1-1-1',
|
||||
name: 'Menu111',
|
||||
component: 'views/Level/Menu111',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 9,
|
||||
permission: ['edit', 'add', 'delete'],
|
||||
meta: {
|
||||
|
@ -1060,7 +1060,7 @@ const menus = [
|
|||
path: 'menu1-2',
|
||||
name: 'Menu12',
|
||||
component: 'views/Level/Menu12',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 10,
|
||||
permission: ['edit', 'add', 'delete'],
|
||||
meta: {
|
||||
|
@ -1074,7 +1074,7 @@ const menus = [
|
|||
path: 'menu2',
|
||||
name: 'Menu2Demo',
|
||||
component: 'views/Level/Menu2',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 11,
|
||||
permission: ['edit', 'add', 'delete'],
|
||||
meta: {
|
||||
|
@ -1091,7 +1091,7 @@ const menus = [
|
|||
component: '#',
|
||||
redirect: '/example/example-dialog',
|
||||
name: 'Example',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 12,
|
||||
meta: {
|
||||
title: '综合示例',
|
||||
|
@ -1103,7 +1103,7 @@ const menus = [
|
|||
path: 'example-detail',
|
||||
component: 'views/Example/Page/ExampleDetail',
|
||||
name: 'ExampleDetail',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
id: 17,
|
||||
permission: ['edit', 'add', 'delete'],
|
||||
meta: {
|
||||
|
@ -1122,18 +1122,16 @@ const menus = [
|
|||
]
|
||||
|
||||
for (let i = 0; i < 4; i++) {
|
||||
List.push(
|
||||
Mock.mock({
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
roleName: roleNames[i],
|
||||
role: '@first',
|
||||
status: Mock.Random.integer(0, 1),
|
||||
createTime: '@datetime',
|
||||
remark: '@cword(10, 15)',
|
||||
menu: menus[i]
|
||||
})
|
||||
)
|
||||
List.push({
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
roleName: roleNames[i],
|
||||
role: faker.lorem.sentence(1),
|
||||
status: faker.number.int({ min: 0, max: 1 }),
|
||||
createTime: faker.date.anytime(),
|
||||
remark: faker.lorem.sentence(),
|
||||
menu: menus[i]
|
||||
})
|
||||
}
|
||||
|
||||
export default [
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import config from '@/config/axios/config'
|
||||
import { faker } from '@faker-js/faker'
|
||||
|
||||
import { toAnyString } from '@/utils'
|
||||
import Mock from 'mockjs'
|
||||
|
||||
const { code } = config
|
||||
|
||||
|
@ -18,9 +18,10 @@ interface ListProps {
|
|||
title: string
|
||||
content: string
|
||||
importance: number
|
||||
display_time: string
|
||||
display_time: any
|
||||
pageviews: number
|
||||
image_uri: string
|
||||
video_uri?: string
|
||||
}
|
||||
|
||||
interface TreeListProps {
|
||||
|
@ -29,111 +30,154 @@ interface TreeListProps {
|
|||
title: string
|
||||
content: string
|
||||
importance: number
|
||||
display_time: string
|
||||
display_time: any
|
||||
image_uri: string
|
||||
pageviews: number
|
||||
children: TreeListProps[]
|
||||
video_uri?: string
|
||||
children?: TreeListProps[]
|
||||
}
|
||||
|
||||
let List: ListProps[] = []
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
List.push(
|
||||
Mock.mock({
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(100, 500)',
|
||||
image_uri: Mock.Random.image('@integer(100, 500)x@integer(100, 500)'),
|
||||
video_uri:
|
||||
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4'
|
||||
})
|
||||
)
|
||||
List.push({
|
||||
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'
|
||||
})
|
||||
}
|
||||
|
||||
const treeList: TreeListProps[] = []
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
treeList.push(
|
||||
Mock.mock({
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(300, 5000)',
|
||||
children: [
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(300, 5000)',
|
||||
children: [
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(300, 5000)'
|
||||
},
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(300, 5000)'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(300, 5000)'
|
||||
},
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(300, 5000)'
|
||||
},
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(300, 5000)'
|
||||
}
|
||||
]
|
||||
// image_uri
|
||||
})
|
||||
)
|
||||
treeList.push({
|
||||
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',
|
||||
children: [
|
||||
{
|
||||
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',
|
||||
children: [
|
||||
{
|
||||
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'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
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'
|
||||
},
|
||||
{
|
||||
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
|
||||
})
|
||||
}
|
||||
|
||||
export default [
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
"element-plus": "^2.4.3",
|
||||
"lodash-es": "^4.17.21",
|
||||
"mitt": "^3.0.1",
|
||||
"mockjs": "^1.1.0",
|
||||
"nprogress": "^0.2.0",
|
||||
"pinia": "^2.1.7",
|
||||
"pinia-plugin-persist": "^1.0.0",
|
||||
|
@ -60,6 +59,7 @@
|
|||
"devDependencies": {
|
||||
"@commitlint/cli": "^18.4.3",
|
||||
"@commitlint/config-conventional": "^18.4.3",
|
||||
"@faker-js/faker": "^8.3.1",
|
||||
"@iconify/json": "^2.2.149",
|
||||
"@intlify/unplugin-vue-i18n": "^1.5.0",
|
||||
"@purge-icons/generated": "^0.10.0",
|
||||
|
|
|
@ -6,6 +6,7 @@ import {
|
|||
} from './types'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import qs from 'qs'
|
||||
// import router from '@/router'
|
||||
|
||||
import { useStorage } from '@/hooks/web/useStorage'
|
||||
|
||||
|
@ -75,6 +76,7 @@ const defaultResponseInterceptors = (response: AxiosResponse<any>) => {
|
|||
// token过期
|
||||
clear()
|
||||
window.location.reload()
|
||||
// router.push('/login')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,6 +106,9 @@ export const isDark = (): boolean => {
|
|||
|
||||
// 是否是图片链接
|
||||
export const isImgPath = (path: string): boolean => {
|
||||
if (path.includes('picsum.photos') || path.includes('loremflickr.com')) {
|
||||
return true
|
||||
}
|
||||
return /(https?:\/\/|data:image\/).*?\.(png|jpg|jpeg|gif|svg|webp|ico)/gi.test(path)
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { Waterfall } from '@/components/Waterfall'
|
||||
import { ContentWrap } from '@/components/ContentWrap'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import Mock from 'mockjs'
|
||||
import { faker } from '@faker-js/faker'
|
||||
import { ref, unref } from 'vue'
|
||||
import { toAnyString } from '@/utils'
|
||||
|
||||
|
@ -12,17 +12,17 @@ const getList = () => {
|
|||
const list: any = []
|
||||
for (let i = 0; i < 20; i++) {
|
||||
// 随机 100, 500 之间的整数
|
||||
const height = Mock.Random.integer(100, 500)
|
||||
const width = Mock.Random.integer(100, 500)
|
||||
list.push(
|
||||
Mock.mock({
|
||||
const height = faker.number.int({ min: 100, max: 500 })
|
||||
const width = faker.number.int({ min: 100, max: 500 })
|
||||
list.push({
|
||||
width,
|
||||
height,
|
||||
id: toAnyString(),
|
||||
image_uri: faker.image.url({
|
||||
width,
|
||||
height,
|
||||
id: toAnyString(),
|
||||
// http更换为https
|
||||
image_uri: Mock.Random.image(`${width}x${height}`).replace('http://', 'https://')
|
||||
height
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
data.value = [...unref(data), ...list]
|
||||
if (unref(data).length >= 60) {
|
||||
|
|
|
@ -156,7 +156,6 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
|||
'vue-json-pretty',
|
||||
'@zxcvbn-ts/core',
|
||||
'dayjs',
|
||||
'mockjs',
|
||||
'cropperjs'
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue