diff --git a/.env.base b/.env.base index 7e2fb8f..e32c0fa 100644 --- a/.env.base +++ b/.env.base @@ -1,5 +1,5 @@ # 环境 -NODE_ENV=development +VITE_NODE_ENV=development # 接口前缀 VITE_API_BASE_PATH= @@ -9,3 +9,9 @@ VITE_BASE_PATH=/ # 标题 VITE_APP_TITLE=ElementAdmin + +# 是否全量引入element-plus样式 +VITE_USE_ALL_ELEMENT_PLUS_STYLE=true + +# 是否开启mock +VITE_USE_MOCK=true diff --git a/.env.dev b/.env.dev index afc3cee..6405df1 100644 --- a/.env.dev +++ b/.env.dev @@ -1,5 +1,5 @@ # 环境 -NODE_ENV=production +VITE_NODE_ENV=production # 接口前缀 VITE_API_BASE_PATH= @@ -21,3 +21,15 @@ VITE_OUT_DIR=dist-dev # 标题 VITE_APP_TITLE=ElementAdmin + +# 是否包分析 +VITE_USE_BUNDLE_ANALYZER=false + +# 是否全量引入element-plus样式 +VITE_USE_ALL_ELEMENT_PLUS_STYLE=false + +# 是否开启mock +VITE_USE_MOCK=true + +# 是否切割css +VITE_USE_CSS_SPLIT=false \ No newline at end of file diff --git a/.env.gitee b/.env.gitee index 9ac2a52..45941a8 100644 --- a/.env.gitee +++ b/.env.gitee @@ -1,5 +1,5 @@ # 环境 -NODE_ENV=production +VITE_NODE_ENV=production # 接口前缀 VITE_API_BASE_PATH= @@ -21,3 +21,15 @@ VITE_OUT_DIR=dist-pro # 标题 VITE_APP_TITLE=ElementAdmin + +# 是否包分析 +VITE_USE_BUNDLE_ANALYZER=false + +# 是否全量引入element-plus样式 +VITE_USE_ALL_ELEMENT_PLUS_STYLE=false + +# 是否开启mock +VITE_USE_MOCK=true + +# 是否切割css +VITE_USE_CSS_SPLIT=false \ No newline at end of file diff --git a/.env.pro b/.env.pro index 432fc46..ed25618 100644 --- a/.env.pro +++ b/.env.pro @@ -1,5 +1,5 @@ # 环境 -NODE_ENV=production +VITE_NODE_ENV=production # 接口前缀 VITE_API_BASE_PATH= @@ -21,3 +21,15 @@ VITE_OUT_DIR=dist-pro # 标题 VITE_APP_TITLE=ElementAdmin + +# 是否包分析 +VITE_USE_BUNDLE_ANALYZER=true + +# 是否全量引入element-plus样式 +VITE_USE_ALL_ELEMENT_PLUS_STYLE=false + +# 是否开启mock +VITE_USE_MOCK=true + +# 是否切割css +VITE_USE_CSS_SPLIT=false \ No newline at end of file diff --git a/.env.test b/.env.test index b6eb7d9..e4a77bf 100644 --- a/.env.test +++ b/.env.test @@ -1,5 +1,5 @@ # 环境 -NODE_ENV=production +VITE_NODE_ENV=production # 接口前缀 VITE_API_BASE_PATH= @@ -21,3 +21,15 @@ VITE_OUT_DIR=dist-test # 标题 VITE_APP_TITLE=ElementAdmin + +# 是否包分析 +VITE_USE_BUNDLE_ANALYZER=false + +# 是否全量引入element-plus样式 +VITE_USE_ALL_ELEMENT_PLUS_STYLE=false + +# 是否开启mock +VITE_USE_MOCK=true + +# 是否切割css +VITE_USE_CSS_SPLIT=false \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0b05e6a..7f5d52e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ dist-ssr /dist* *-lock.* pnpm-debug +stats.html + diff --git a/.prettierignore b/.prettierignore index 15cf071..4ff8c9d 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,7 +3,6 @@ /dist* /public/* /docs/* -/vite.config.ts /src/types/env.d.ts /docs/**/* /plop/**/* diff --git a/README.md b/README.md index 383d508..3db6283 100644 --- a/README.md +++ b/README.md @@ -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 - [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 -- [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 diff --git a/README.zh-CN.md b/README.zh-CN.md index e03a232..1caf7b6 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -50,7 +50,7 @@ vue-element-plus-admin 的定位是后台集成方案,不太适合当基础模 - [Es6+](http://es6.ruanyifeng.com/) - 熟悉 es6 基本语法 - [Vue-Router-Next](https://next.router.vuejs.org/) - 熟悉 vue-router 基本使用 - [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 基本语法 ## 安装和使用 diff --git a/mock/department/index.mock.ts b/mock/department/index.mock.ts index 891300a..443907e 100644 --- a/mock/department/index.mock.ts +++ b/mock/department/index.mock.ts @@ -1,5 +1,5 @@ import { toAnyString } from '@/utils' -import { faker } from '@faker-js/faker' +import Mock from 'mockjs' import { SUCCESS_CODE } from '@/constants' const departmentList: any = [] @@ -11,64 +11,71 @@ for (let i = 0; i < 5; i++) { // 部门名称 departmentName: citys[i], id: toAnyString(), - createTime: faker.date.anytime(), - status: faker.number.int({ min: 0, max: 1 }), + createTime: '@datetime', + // 状态 + status: Mock.Random.integer(0, 1), // 备注 - remark: faker.lorem.sentence(), + remark: '@cword(10, 15)', children: [ { // 部门名称 departmentName: '研发部', - createTime: faker.date.anytime(), - // 状态 - status: faker.number.int({ min: 0, max: 1 }), id: toAnyString(), - remark: faker.lorem.sentence() + createTime: '@datetime', + // 状态 + status: Mock.Random.integer(0, 1), + // 备注 + remark: '@cword(10, 15)' }, { // 部门名称 departmentName: '产品部', - createTime: faker.date.anytime(), - // 状态 - status: faker.number.int({ min: 0, max: 1 }), id: toAnyString(), - remark: faker.lorem.sentence() + createTime: '@datetime', + // 状态 + status: Mock.Random.integer(0, 1), + // 备注 + remark: '@cword(10, 15)' }, { // 部门名称 departmentName: '运营部', - createTime: faker.date.anytime(), - // 状态 - status: faker.number.int({ min: 0, max: 1 }), id: toAnyString(), - remark: faker.lorem.sentence() + createTime: '@datetime', + // 状态 + status: Mock.Random.integer(0, 1), + // 备注 + remark: '@cword(10, 15)' }, { // 部门名称 departmentName: '市场部', - createTime: faker.date.anytime(), - // 状态 - status: faker.number.int({ min: 0, max: 1 }), id: toAnyString(), - remark: faker.lorem.sentence() + createTime: '@datetime', + // 状态 + status: Mock.Random.integer(0, 1), + // 备注 + remark: '@cword(10, 15)' }, { // 部门名称 departmentName: '销售部', - createTime: faker.date.anytime(), - // 状态 - status: faker.number.int({ min: 0, max: 1 }), id: toAnyString(), - remark: faker.lorem.sentence() + createTime: '@datetime', + // 状态 + status: Mock.Random.integer(0, 1), + // 备注 + remark: '@cword(10, 15)' }, { // 部门名称 departmentName: '客服部', - createTime: faker.date.anytime(), - // 状态 - status: faker.number.int({ min: 0, max: 1 }), 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来创建数据 const mockList: any = [] for (let i = 0; i < pageSize; i++) { - mockList.push({ - // 用户名 - username: faker.person.firstName(), - // 账号 - account: faker.person.lastName(), - // 邮箱 - email: faker.internet.email(), - // 创建时间 - createTime: faker.date.anytime(), - // 用户id - id: toAnyString() - }) + mockList.push( + Mock.mock({ + // 用户名 + username: '@cname', + // 账号 + account: '@first', + // 邮箱 + email: '@EMAIL', + // 创建时间 + createTime: '@datetime', + // 用户id + id: toAnyString() + }) + ) } return { code: SUCCESS_CODE, diff --git a/mock/menu/index.mock.ts b/mock/menu/index.mock.ts index 5eca3a0..fd3f732 100644 --- a/mock/menu/index.mock.ts +++ b/mock/menu/index.mock.ts @@ -1,4 +1,4 @@ -import { faker } from '@faker-js/faker' +import Mock from 'mockjs' import { SUCCESS_CODE } from '@/constants' const timeout = 1000 @@ -19,7 +19,7 @@ export default [ component: '#', redirect: '/dashboard/analysis', name: 'Dashboard', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 1, type: 0, parentId: undefined, @@ -34,7 +34,7 @@ export default [ path: 'analysis', component: 'views/Dashboard/Analysis', name: 'Analysis', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 2, type: 1, parentId: 1, @@ -59,7 +59,7 @@ export default [ path: 'workplace', component: 'views/Dashboard/Workplace', name: 'Workplace', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 3, type: 1, parentId: 1, @@ -93,7 +93,7 @@ export default [ icon: 'clarity:document-solid' }, name: 'ExternalLink', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 4, type: 0, parentId: undefined, @@ -102,7 +102,7 @@ export default [ { path: 'https://element-plus-admin-doc.cn/', name: 'DocumentLink', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 5, type: 1, parentId: 4, @@ -118,7 +118,7 @@ export default [ component: '#', redirect: '/level/menu1/menu1-1/menu1-1-1', name: 'Level', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 6, type: 0, parentId: undefined, @@ -132,7 +132,7 @@ export default [ path: 'menu1', name: 'Menu1', component: '##', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 7, type: 0, parentId: 6, @@ -146,7 +146,7 @@ export default [ path: 'menu1-1', name: 'Menu11', component: '##', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 8, type: 0, parentId: 7, @@ -161,7 +161,7 @@ export default [ path: 'menu1-1-1', name: 'Menu111', component: 'views/Level/Menu111', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 9, type: 1, parentId: 8, @@ -176,7 +176,7 @@ export default [ path: 'menu1-2', name: 'Menu12', component: 'views/Level/Menu12', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 10, type: 1, parentId: 7, @@ -191,7 +191,7 @@ export default [ path: 'menu2', name: 'Menu2Demo', component: 'views/Level/Menu2', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 11, type: 1, parentId: 6, @@ -207,7 +207,7 @@ export default [ component: '#', redirect: '/example/example-dialog', name: 'Example', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 12, type: 0, parentId: undefined, @@ -222,7 +222,7 @@ export default [ path: 'example-dialog', component: 'views/Example/Dialog/ExampleDialog', name: 'ExampleDialog', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 13, type: 1, parentId: 12, @@ -253,7 +253,7 @@ export default [ path: 'example-page', component: 'views/Example/Page/ExamplePage', name: 'ExamplePage', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 14, type: 1, parentId: 12, @@ -284,7 +284,7 @@ export default [ path: 'example-add', component: 'views/Example/Page/ExampleAdd', name: 'ExampleAdd', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 15, type: 1, parentId: 12, @@ -302,7 +302,7 @@ export default [ path: 'example-edit', component: 'views/Example/Page/ExampleEdit', name: 'ExampleEdit', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 16, type: 1, parentId: 12, @@ -320,7 +320,7 @@ export default [ path: 'example-detail', component: 'views/Example/Page/ExampleDetail', name: 'ExampleDetail', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 17, type: 1, parentId: 12, diff --git a/mock/role/index.mock.ts b/mock/role/index.mock.ts index 5449d79..0a14b60 100644 --- a/mock/role/index.mock.ts +++ b/mock/role/index.mock.ts @@ -1,4 +1,4 @@ -import { faker } from '@faker-js/faker' +import Mock from 'mockjs' import { SUCCESS_CODE } from '@/constants' import { toAnyString } from '@/utils' @@ -731,7 +731,7 @@ const menus = [ component: '#', redirect: '/dashboard/analysis', name: 'Dashboard', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 1, meta: { title: '首页', @@ -743,7 +743,7 @@ const menus = [ path: 'analysis', component: 'views/Dashboard/Analysis', name: 'Analysis', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 2, meta: { title: '分析页', @@ -754,7 +754,7 @@ const menus = [ path: 'workplace', component: 'views/Dashboard/Workplace', name: 'Workplace', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 3, meta: { title: '工作台', @@ -771,13 +771,13 @@ const menus = [ icon: 'clarity:document-solid' }, name: 'ExternalLink', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 4, children: [ { path: 'https://element-plus-admin-doc.cn/', name: 'DocumentLink', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 5, meta: { title: '文档' @@ -790,7 +790,7 @@ const menus = [ component: '#', redirect: '/level/menu1/menu1-1/menu1-1-1', name: 'Level', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 6, meta: { title: '菜单', @@ -801,7 +801,7 @@ const menus = [ path: 'menu1', name: 'Menu1', component: '##', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 7, redirect: '/level/menu1/menu1-1/menu1-1-1', meta: { @@ -812,7 +812,7 @@ const menus = [ path: 'menu1-1', name: 'Menu11', component: '##', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 8, redirect: '/level/menu1/menu1-1/menu1-1-1', meta: { @@ -824,7 +824,7 @@ const menus = [ path: 'menu1-1-1', name: 'Menu111', component: 'views/Level/Menu111', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 9, permission: ['edit', 'add', 'delete'], meta: { @@ -838,7 +838,7 @@ const menus = [ path: 'menu1-2', name: 'Menu12', component: 'views/Level/Menu12', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 10, permission: ['edit', 'add', 'delete'], meta: { @@ -852,7 +852,7 @@ const menus = [ path: 'menu2', name: 'Menu2Demo', component: 'views/Level/Menu2', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 11, permission: ['edit', 'add', 'delete'], meta: { @@ -867,7 +867,7 @@ const menus = [ component: '#', redirect: '/example/example-dialog', name: 'Example', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 12, meta: { title: '综合示例', @@ -879,7 +879,7 @@ const menus = [ path: 'example-dialog', component: 'views/Example/Dialog/ExampleDialog', name: 'ExampleDialog', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 13, permission: ['edit', 'add', 'delete'], meta: { @@ -891,7 +891,7 @@ const menus = [ path: 'example-page', component: 'views/Example/Page/ExamplePage', name: 'ExamplePage', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 14, permission: ['edit', 'add', 'delete'], meta: { @@ -903,7 +903,7 @@ const menus = [ path: 'example-add', component: 'views/Example/Page/ExampleAdd', name: 'ExampleAdd', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 15, permission: ['edit', 'add', 'delete'], meta: { @@ -920,7 +920,7 @@ const menus = [ path: 'example-edit', component: 'views/Example/Page/ExampleEdit', name: 'ExampleEdit', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 16, permission: ['edit', 'add', 'delete'], meta: { @@ -937,7 +937,7 @@ const menus = [ path: 'example-detail', component: 'views/Example/Page/ExampleDetail', name: 'ExampleDetail', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 17, permission: ['edit', 'add', 'delete'], meta: { @@ -959,7 +959,7 @@ const menus = [ component: '#', redirect: '/dashboard/analysis', name: 'Dashboard', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 1, meta: { title: '首页', @@ -971,7 +971,7 @@ const menus = [ path: 'analysis', component: 'views/Dashboard/Analysis', name: 'Analysis', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 2, meta: { title: '分析页', @@ -982,7 +982,7 @@ const menus = [ path: 'workplace', component: 'views/Dashboard/Workplace', name: 'Workplace', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 3, meta: { title: '工作台', @@ -1001,13 +1001,13 @@ const menus = [ icon: 'clarity:document-solid' }, name: 'ExternalLink', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 4, children: [ { path: 'https://element-plus-admin-doc.cn/', name: 'DocumentLink', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 5, meta: { title: '文档' @@ -1020,7 +1020,7 @@ const menus = [ component: '#', redirect: '/level/menu1/menu1-1/menu1-1-1', name: 'Level', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 6, meta: { title: '菜单', @@ -1031,7 +1031,7 @@ const menus = [ path: 'menu1', name: 'Menu1', component: '##', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 7, redirect: '/level/menu1/menu1-1/menu1-1-1', meta: { @@ -1042,7 +1042,7 @@ const menus = [ path: 'menu1-1', name: 'Menu11', component: '##', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 8, redirect: '/level/menu1/menu1-1/menu1-1-1', meta: { @@ -1054,7 +1054,7 @@ const menus = [ path: 'menu1-1-1', name: 'Menu111', component: 'views/Level/Menu111', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 9, permission: ['edit', 'add', 'delete'], meta: { @@ -1068,7 +1068,7 @@ const menus = [ path: 'menu1-2', name: 'Menu12', component: 'views/Level/Menu12', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 10, permission: ['edit', 'add', 'delete'], meta: { @@ -1082,7 +1082,7 @@ const menus = [ path: 'menu2', name: 'Menu2Demo', component: 'views/Level/Menu2', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 11, permission: ['edit', 'add', 'delete'], meta: { @@ -1099,7 +1099,7 @@ const menus = [ component: '#', redirect: '/example/example-dialog', name: 'Example', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 12, meta: { title: '综合示例', @@ -1111,7 +1111,7 @@ const menus = [ path: 'example-detail', component: 'views/Example/Page/ExampleDetail', name: 'ExampleDetail', - status: faker.number.int({ min: 0, max: 1 }), + status: Mock.Random.integer(0, 1), id: 17, permission: ['edit', 'add', 'delete'], meta: { @@ -1130,16 +1130,18 @@ const menus = [ ] for (let i = 0; i < 4; 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] - }) + 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] + }) + ) } export default [ diff --git a/mock/table/index.mock.ts b/mock/table/index.mock.ts index 13d7778..80520b8 100644 --- a/mock/table/index.mock.ts +++ b/mock/table/index.mock.ts @@ -1,4 +1,4 @@ -import { faker } from '@faker-js/faker' +import Mock from 'mockjs' import { SUCCESS_CODE } from '@/constants' import { toAnyString } from '@/utils' @@ -36,144 +36,103 @@ interface TreeListProps { let List: ListProps[] = [] for (let i = 0; i < count; i++) { - 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' - }) + 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' + }) + ) } const treeList: TreeListProps[] = [] for (let i = 0; i < count; i++) { - 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 - }) + 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 + }) + ) } const cardList = [ diff --git a/package.json b/package.json index 62ca793..271d81a 100644 --- a/package.json +++ b/package.json @@ -27,9 +27,7 @@ "icon": "esno ./scripts/icon.ts" }, "dependencies": { - "@faker-js/faker": "^8.3.1", "@iconify/iconify": "^3.1.1", - "@iconify/vue": "^4.1.1", "@vueuse/core": "^10.7.0", "@wangeditor/editor": "^5.1.23", "@wangeditor/editor-for-vue": "^5.1.10", @@ -41,49 +39,50 @@ "driver.js": "^1.3.1", "echarts": "^5.4.3", "echarts-wordcloud": "^2.1.0", - "element-plus": "^2.4.3", + "element-plus": "^2.4.4", "lodash-es": "^4.17.21", "mitt": "^3.0.1", "nprogress": "^0.2.0", "pinia": "^2.1.7", - "pinia-plugin-persistedstate": "^3.2.0", + "pinia-plugin-persistedstate": "^3.2.1", "qrcode": "^1.5.3", "qs": "^6.11.2", "url": "^0.11.3", - "vue": "3.3.10", + "vue": "3.3.13", + "vue-draggable-plus": "^0.3.2", "vue-i18n": "9.8.0", - "vue-json-pretty": "^2.2.4", + "vue-json-pretty": "^2.3.0", "vue-router": "^4.2.5", "vue-types": "^5.1.1", - "xgplayer": "^3.0.10" + "xgplayer": "^3.0.11" }, "devDependencies": { "@commitlint/cli": "^18.4.3", "@commitlint/config-conventional": "^18.4.3", - "@iconify/json": "^2.2.153", - "@intlify/unplugin-vue-i18n": "^1.5.0", - "@purge-icons/generated": "^0.10.0", + "@iconify/json": "^2.2.160", + "@intlify/unplugin-vue-i18n": "^2.0.0", "@types/fs-extra": "^11.0.4", "@types/inquirer": "^9.0.7", "@types/lodash-es": "^4.17.12", - "@types/node": "^20.10.3", + "@types/mockjs": "^1.0.10", + "@types/node": "^20.10.5", "@types/nprogress": "^0.2.3", "@types/qrcode": "^1.5.5", "@types/qs": "^6.9.10", "@types/sortablejs": "^1.15.7", - "@typescript-eslint/eslint-plugin": "^6.13.2", - "@typescript-eslint/parser": "^6.13.2", + "@typescript-eslint/eslint-plugin": "^6.15.0", + "@typescript-eslint/parser": "^6.15.0", "@unocss/transformer-variant-group": "^0.58.0", "@vitejs/plugin-legacy": "^5.2.0", - "@vitejs/plugin-vue": "^4.5.1", + "@vitejs/plugin-vue": "^4.5.2", "@vitejs/plugin-vue-jsx": "^3.1.0", "autoprefixer": "^10.4.16", "chalk": "^5.3.0", "consola": "^3.2.3", - "eslint": "^8.55.0", + "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", "eslint-define-config": "^2.0.0", - "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-prettier": "^5.1.0", "eslint-plugin-vue": "^9.19.2", "esno": "^4.0.0", "fs-extra": "^11.2.0", @@ -91,22 +90,24 @@ "inquirer": "^9.2.12", "less": "^4.2.0", "lint-staged": "^15.2.0", + "mockjs": "^1.1.0", "plop": "^4.0.0", "postcss": "^8.4.32", "postcss-html": "^1.5.0", "postcss-less": "^6.0.0", - "prettier": "^3.1.0", + "prettier": "^3.1.1", "rimraf": "^5.0.5", - "rollup": "^4.6.1", - "stylelint": "^15.11.0", + "rollup": "^4.9.1", + "rollup-plugin-visualizer": "^5.11.0", + "stylelint": "^16.0.2", "stylelint-config-html": "^1.1.0", - "stylelint-config-recommended": "^13.0.0", - "stylelint-config-standard": "^34.0.0", - "stylelint-order": "^6.0.3", - "terser": "^5.25.0", + "stylelint-config-recommended": "^14.0.0", + "stylelint-config-standard": "^35.0.0", + "stylelint-order": "^6.0.4", + "terser": "^5.26.0", "typescript": "5.3.3", "unocss": "^0.58.0", - "vite": "5.0.6", + "vite": "5.0.10", "vite-plugin-ejs": "^1.7.0", "vite-plugin-eslint": "^1.8.1", "vite-plugin-mock": "^2.9.6", diff --git a/src/App.vue b/src/App.vue index c097654..840ff90 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,9 +2,9 @@ import { computed } from 'vue' import { useAppStore } from '@/store/modules/app' import { ConfigGlobal } from '@/components/ConfigGlobal' -import { isDark } from '@/utils/is' import { useDesign } from '@/hooks/web/useDesign' -import { useStorage } from '@/hooks/web/useStorage' +import { useDark } from '@vueuse/core' +import { ElNotification } from 'element-plus' const { getPrefixCls } = useDesign() @@ -16,19 +16,20 @@ const currentSize = computed(() => appStore.getCurrentSize) const greyMode = computed(() => appStore.getGreyMode) -const { getStorage } = useStorage() +const isDark = useDark({ + valueDark: 'dark', + valueLight: 'light' +}) -// 根据浏览器当前主题设置系统主题色 -const setDefaultTheme = () => { - if (getStorage('isDark') !== null) { - appStore.setIsDark(getStorage('isDark')) - return - } - const isDarkTheme = isDark() - appStore.setIsDark(isDarkTheme) -} - -setDefaultTheme() +isDark.value = appStore.getIsDark +ElNotification({ + title: '提示', + type: 'warning', + duration: 0, + dangerouslyUseHTMLString: true, + message: + '
遇事不决,请先查阅常见问题,说不定你能找到相关解答