zetan-cli-dev-template-vue-element-admin 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +8 -0
- package/template/.editorconfig +14 -0
- package/template/.env.development +5 -0
- package/template/.env.production +6 -0
- package/template/.env.staging +8 -0
- package/template/.eslintignore +4 -0
- package/template/.eslintrc.js +198 -0
- package/template/.travis.yml +5 -0
- package/template/LICENSE +21 -0
- package/template/README.es.md +228 -0
- package/template/README.ja.md +224 -0
- package/template/README.md +250 -0
- package/template/README.zh-CN.md +273 -0
- package/template/babel.config.js +14 -0
- package/template/build/index.js +35 -0
- package/template/jest.config.js +24 -0
- package/template/jsconfig.json +9 -0
- package/template/mock/article.js +116 -0
- package/template/mock/index.js +60 -0
- package/template/mock/mock-server.js +81 -0
- package/template/mock/remote-search.js +51 -0
- package/template/mock/role/index.js +98 -0
- package/template/mock/role/routes.js +530 -0
- package/template/mock/user.js +84 -0
- package/template/mock/utils.js +48 -0
- package/template/package.json +111 -0
- package/template/plop-templates/component/index.hbs +26 -0
- package/template/plop-templates/component/prompt.js +55 -0
- package/template/plop-templates/store/index.hbs +16 -0
- package/template/plop-templates/store/prompt.js +62 -0
- package/template/plop-templates/utils.js +2 -0
- package/template/plop-templates/view/index.hbs +26 -0
- package/template/plop-templates/view/prompt.js +55 -0
- package/template/plopfile.js +9 -0
- package/template/postcss.config.js +5 -0
- package/template/public/favicon.ico +0 -0
- package/template/public/index.html +15 -0
- package/template/src/App.vue +11 -0
- package/template/src/api/article.js +41 -0
- package/template/src/api/qiniu.js +8 -0
- package/template/src/api/remote-search.js +17 -0
- package/template/src/api/role.js +38 -0
- package/template/src/api/user.js +24 -0
- package/template/src/assets/401_images/401.gif +0 -0
- package/template/src/assets/404_images/404.png +0 -0
- package/template/src/assets/404_images/404_cloud.png +0 -0
- package/template/src/assets/custom-theme/fonts/element-icons.ttf +0 -0
- package/template/src/assets/custom-theme/fonts/element-icons.woff +0 -0
- package/template/src/assets/custom-theme/index.css +1 -0
- package/template/src/components/BackToTop/index.vue +111 -0
- package/template/src/components/Breadcrumb/index.vue +82 -0
- package/template/src/components/Charts/Keyboard.vue +155 -0
- package/template/src/components/Charts/LineMarker.vue +227 -0
- package/template/src/components/Charts/MixChart.vue +271 -0
- package/template/src/components/Charts/mixins/resize.js +56 -0
- package/template/src/components/DndList/index.vue +166 -0
- package/template/src/components/DragSelect/index.vue +65 -0
- package/template/src/components/Dropzone/index.vue +297 -0
- package/template/src/components/ErrorLog/index.vue +78 -0
- package/template/src/components/GithubCorner/index.vue +54 -0
- package/template/src/components/Hamburger/index.vue +44 -0
- package/template/src/components/HeaderSearch/index.vue +180 -0
- package/template/src/components/ImageCropper/index.vue +1779 -0
- package/template/src/components/ImageCropper/utils/data2blob.js +19 -0
- package/template/src/components/ImageCropper/utils/effectRipple.js +39 -0
- package/template/src/components/ImageCropper/utils/language.js +232 -0
- package/template/src/components/ImageCropper/utils/mimes.js +7 -0
- package/template/src/components/JsonEditor/index.vue +77 -0
- package/template/src/components/Kanban/index.vue +99 -0
- package/template/src/components/MDinput/index.vue +360 -0
- package/template/src/components/MarkdownEditor/default-options.js +31 -0
- package/template/src/components/MarkdownEditor/index.vue +118 -0
- package/template/src/components/Pagination/index.vue +101 -0
- package/template/src/components/PanThumb/index.vue +142 -0
- package/template/src/components/RightPanel/index.vue +145 -0
- package/template/src/components/Screenfull/index.vue +60 -0
- package/template/src/components/Share/DropdownMenu.vue +103 -0
- package/template/src/components/SizeSelect/index.vue +57 -0
- package/template/src/components/Sticky/index.vue +91 -0
- package/template/src/components/SvgIcon/index.vue +62 -0
- package/template/src/components/TextHoverEffect/Mallki.vue +113 -0
- package/template/src/components/ThemePicker/index.vue +175 -0
- package/template/src/components/Tinymce/components/EditorImage.vue +111 -0
- package/template/src/components/Tinymce/dynamicLoadScript.js +59 -0
- package/template/src/components/Tinymce/index.vue +247 -0
- package/template/src/components/Tinymce/plugins.js +7 -0
- package/template/src/components/Tinymce/toolbar.js +6 -0
- package/template/src/components/Upload/SingleImage.vue +134 -0
- package/template/src/components/Upload/SingleImage2.vue +130 -0
- package/template/src/components/Upload/SingleImage3.vue +157 -0
- package/template/src/components/UploadExcel/index.vue +138 -0
- package/template/src/directive/clipboard/clipboard.js +49 -0
- package/template/src/directive/clipboard/index.js +13 -0
- package/template/src/directive/el-drag-dialog/drag.js +77 -0
- package/template/src/directive/el-drag-dialog/index.js +13 -0
- package/template/src/directive/el-table/adaptive.js +41 -0
- package/template/src/directive/el-table/index.js +13 -0
- package/template/src/directive/permission/index.js +13 -0
- package/template/src/directive/permission/permission.js +31 -0
- package/template/src/directive/sticky.js +91 -0
- package/template/src/directive/waves/index.js +13 -0
- package/template/src/directive/waves/waves.css +26 -0
- package/template/src/directive/waves/waves.js +72 -0
- package/template/src/filters/index.js +68 -0
- package/template/src/icons/index.js +9 -0
- package/template/src/icons/svg/404.svg +1 -0
- package/template/src/icons/svg/bug.svg +1 -0
- package/template/src/icons/svg/chart.svg +1 -0
- package/template/src/icons/svg/clipboard.svg +1 -0
- package/template/src/icons/svg/component.svg +1 -0
- package/template/src/icons/svg/dashboard.svg +1 -0
- package/template/src/icons/svg/documentation.svg +1 -0
- package/template/src/icons/svg/drag.svg +1 -0
- package/template/src/icons/svg/edit.svg +1 -0
- package/template/src/icons/svg/education.svg +1 -0
- package/template/src/icons/svg/email.svg +1 -0
- package/template/src/icons/svg/example.svg +1 -0
- package/template/src/icons/svg/excel.svg +1 -0
- package/template/src/icons/svg/exit-fullscreen.svg +1 -0
- package/template/src/icons/svg/eye-open.svg +1 -0
- package/template/src/icons/svg/eye.svg +1 -0
- package/template/src/icons/svg/form.svg +1 -0
- package/template/src/icons/svg/fullscreen.svg +1 -0
- package/template/src/icons/svg/guide.svg +1 -0
- package/template/src/icons/svg/icon.svg +1 -0
- package/template/src/icons/svg/international.svg +1 -0
- package/template/src/icons/svg/language.svg +1 -0
- package/template/src/icons/svg/link.svg +1 -0
- package/template/src/icons/svg/list.svg +1 -0
- package/template/src/icons/svg/lock.svg +1 -0
- package/template/src/icons/svg/message.svg +1 -0
- package/template/src/icons/svg/money.svg +1 -0
- package/template/src/icons/svg/nested.svg +1 -0
- package/template/src/icons/svg/password.svg +1 -0
- package/template/src/icons/svg/pdf.svg +1 -0
- package/template/src/icons/svg/people.svg +1 -0
- package/template/src/icons/svg/peoples.svg +1 -0
- package/template/src/icons/svg/qq.svg +1 -0
- package/template/src/icons/svg/search.svg +1 -0
- package/template/src/icons/svg/shopping.svg +1 -0
- package/template/src/icons/svg/size.svg +1 -0
- package/template/src/icons/svg/skill.svg +1 -0
- package/template/src/icons/svg/star.svg +1 -0
- package/template/src/icons/svg/tab.svg +1 -0
- package/template/src/icons/svg/table.svg +1 -0
- package/template/src/icons/svg/theme.svg +1 -0
- package/template/src/icons/svg/tree-table.svg +1 -0
- package/template/src/icons/svg/tree.svg +1 -0
- package/template/src/icons/svg/user.svg +1 -0
- package/template/src/icons/svg/wechat.svg +1 -0
- package/template/src/icons/svg/zip.svg +1 -0
- package/template/src/icons/svgo.yml +22 -0
- package/template/src/layout/components/AppMain.vue +57 -0
- package/template/src/layout/components/Navbar.vue +167 -0
- package/template/src/layout/components/Settings/index.vue +108 -0
- package/template/src/layout/components/Sidebar/FixiOSBug.js +26 -0
- package/template/src/layout/components/Sidebar/Item.vue +41 -0
- package/template/src/layout/components/Sidebar/Link.vue +43 -0
- package/template/src/layout/components/Sidebar/Logo.vue +82 -0
- package/template/src/layout/components/Sidebar/SidebarItem.vue +95 -0
- package/template/src/layout/components/Sidebar/index.vue +54 -0
- package/template/src/layout/components/TagsView/ScrollPane.vue +94 -0
- package/template/src/layout/components/TagsView/index.vue +292 -0
- package/template/src/layout/components/index.js +5 -0
- package/template/src/layout/index.vue +102 -0
- package/template/src/layout/mixin/ResizeHandler.js +45 -0
- package/template/src/main.js +53 -0
- package/template/src/permission.js +74 -0
- package/template/src/router/index.js +404 -0
- package/template/src/router/modules/charts.js +36 -0
- package/template/src/router/modules/components.js +102 -0
- package/template/src/router/modules/nested.js +66 -0
- package/template/src/router/modules/table.js +41 -0
- package/template/src/settings.js +35 -0
- package/template/src/store/getters.js +15 -0
- package/template/src/store/index.js +25 -0
- package/template/src/store/modules/app.js +56 -0
- package/template/src/store/modules/errorLog.js +28 -0
- package/template/src/store/modules/permission.js +69 -0
- package/template/src/store/modules/settings.js +35 -0
- package/template/src/store/modules/tagsView.js +160 -0
- package/template/src/store/modules/user.js +131 -0
- package/template/src/styles/btn.scss +99 -0
- package/template/src/styles/element-ui.scss +84 -0
- package/template/src/styles/element-variables.scss +31 -0
- package/template/src/styles/index.scss +191 -0
- package/template/src/styles/mixin.scss +66 -0
- package/template/src/styles/sidebar.scss +226 -0
- package/template/src/styles/transition.scss +48 -0
- package/template/src/styles/variables.scss +35 -0
- package/template/src/utils/auth.js +15 -0
- package/template/src/utils/clipboard.js +32 -0
- package/template/src/utils/error-log.js +35 -0
- package/template/src/utils/get-page-title.js +10 -0
- package/template/src/utils/index.js +357 -0
- package/template/src/utils/open-window.js +25 -0
- package/template/src/utils/permission.js +21 -0
- package/template/src/utils/request.js +85 -0
- package/template/src/utils/scroll-to.js +58 -0
- package/template/src/utils/validate.js +87 -0
- package/template/src/vendor/Export2Excel.js +220 -0
- package/template/src/vendor/Export2Zip.js +24 -0
- package/template/src/views/charts/keyboard.vue +23 -0
- package/template/src/views/charts/line.vue +23 -0
- package/template/src/views/charts/mix-chart.vue +23 -0
- package/template/src/views/clipboard/index.vue +49 -0
- package/template/src/views/components-demo/avatar-upload.vue +61 -0
- package/template/src/views/components-demo/back-to-top.vue +154 -0
- package/template/src/views/components-demo/count-to.vue +218 -0
- package/template/src/views/components-demo/dnd-list.vue +39 -0
- package/template/src/views/components-demo/drag-dialog.vue +61 -0
- package/template/src/views/components-demo/drag-kanban.vue +66 -0
- package/template/src/views/components-demo/drag-select.vue +43 -0
- package/template/src/views/components-demo/dropzone.vue +31 -0
- package/template/src/views/components-demo/json-editor.vue +36 -0
- package/template/src/views/components-demo/markdown.vue +101 -0
- package/template/src/views/components-demo/mixin.vue +169 -0
- package/template/src/views/components-demo/split-pane.vue +67 -0
- package/template/src/views/components-demo/sticky.vue +135 -0
- package/template/src/views/components-demo/tinymce.vue +36 -0
- package/template/src/views/dashboard/admin/components/BarChart.vue +102 -0
- package/template/src/views/dashboard/admin/components/BoxCard.vue +118 -0
- package/template/src/views/dashboard/admin/components/LineChart.vue +135 -0
- package/template/src/views/dashboard/admin/components/PanelGroup.vue +181 -0
- package/template/src/views/dashboard/admin/components/PieChart.vue +79 -0
- package/template/src/views/dashboard/admin/components/RaddarChart.vue +116 -0
- package/template/src/views/dashboard/admin/components/TodoList/Todo.vue +81 -0
- package/template/src/views/dashboard/admin/components/TodoList/index.scss +320 -0
- package/template/src/views/dashboard/admin/components/TodoList/index.vue +127 -0
- package/template/src/views/dashboard/admin/components/TransactionTable.vue +55 -0
- package/template/src/views/dashboard/admin/components/mixins/resize.js +55 -0
- package/template/src/views/dashboard/admin/index.vue +124 -0
- package/template/src/views/dashboard/editor/index.vue +74 -0
- package/template/src/views/dashboard/index.vue +31 -0
- package/template/src/views/documentation/index.vue +57 -0
- package/template/src/views/error-log/components/ErrorTestA.vue +13 -0
- package/template/src/views/error-log/components/ErrorTestB.vue +11 -0
- package/template/src/views/error-log/index.vue +32 -0
- package/template/src/views/error-page/401.vue +99 -0
- package/template/src/views/error-page/404.vue +228 -0
- package/template/src/views/example/components/ArticleDetail.vue +289 -0
- package/template/src/views/example/components/Dropdown/Comment.vue +41 -0
- package/template/src/views/example/components/Dropdown/Platform.vue +46 -0
- package/template/src/views/example/components/Dropdown/SourceUrl.vue +38 -0
- package/template/src/views/example/components/Dropdown/index.js +3 -0
- package/template/src/views/example/components/Warning.vue +13 -0
- package/template/src/views/example/create.vue +13 -0
- package/template/src/views/example/edit.vue +13 -0
- package/template/src/views/example/list.vue +112 -0
- package/template/src/views/excel/components/AutoWidthOption.vue +34 -0
- package/template/src/views/excel/components/BookTypeOption.vue +39 -0
- package/template/src/views/excel/components/FilenameOption.vue +27 -0
- package/template/src/views/excel/export-excel.vue +116 -0
- package/template/src/views/excel/merge-header.vue +101 -0
- package/template/src/views/excel/select-excel.vue +107 -0
- package/template/src/views/excel/upload-excel.vue +42 -0
- package/template/src/views/guide/index.vue +36 -0
- package/template/src/views/guide/steps.js +53 -0
- package/template/src/views/icons/element-icons.js +3 -0
- package/template/src/views/icons/index.vue +101 -0
- package/template/src/views/icons/svg-icons.js +10 -0
- package/template/src/views/login/auth-redirect.vue +15 -0
- package/template/src/views/login/components/SocialSignin.vue +72 -0
- package/template/src/views/login/index.vue +324 -0
- package/template/src/views/nested/menu1/index.vue +7 -0
- package/template/src/views/nested/menu1/menu1-1/index.vue +7 -0
- package/template/src/views/nested/menu1/menu1-2/index.vue +7 -0
- package/template/src/views/nested/menu1/menu1-2/menu1-2-1/index.vue +5 -0
- package/template/src/views/nested/menu1/menu1-2/menu1-2-2/index.vue +5 -0
- package/template/src/views/nested/menu1/menu1-3/index.vue +5 -0
- package/template/src/views/nested/menu2/index.vue +5 -0
- package/template/src/views/pdf/content.js +58 -0
- package/template/src/views/pdf/download.vue +201 -0
- package/template/src/views/pdf/index.vue +13 -0
- package/template/src/views/permission/components/SwitchRoles.vue +32 -0
- package/template/src/views/permission/directive.vue +111 -0
- package/template/src/views/permission/page.vue +19 -0
- package/template/src/views/permission/role.vue +270 -0
- package/template/src/views/profile/components/Account.vue +38 -0
- package/template/src/views/profile/components/Activity.vue +185 -0
- package/template/src/views/profile/components/Timeline.vue +43 -0
- package/template/src/views/profile/components/UserCard.vue +134 -0
- package/template/src/views/profile/index.vue +68 -0
- package/template/src/views/qiniu/upload.vue +41 -0
- package/template/src/views/redirect/index.vue +12 -0
- package/template/src/views/tab/components/TabPane.vue +103 -0
- package/template/src/views/tab/index.vue +57 -0
- package/template/src/views/table/complex-table.vue +379 -0
- package/template/src/views/table/drag-table.vue +153 -0
- package/template/src/views/table/dynamic-table/components/FixedThead.vue +62 -0
- package/template/src/views/table/dynamic-table/components/UnfixedThead.vue +50 -0
- package/template/src/views/table/dynamic-table/index.vue +24 -0
- package/template/src/views/table/inline-edit-table.vue +149 -0
- package/template/src/views/theme/index.vue +120 -0
- package/template/src/views/zip/index.vue +77 -0
- package/template/tests/unit/.eslintrc.js +5 -0
- package/template/tests/unit/components/Hamburger.spec.js +18 -0
- package/template/tests/unit/components/SvgIcon.spec.js +22 -0
- package/template/tests/unit/utils/formatTime.spec.js +29 -0
- package/template/tests/unit/utils/param2Obj.spec.js +14 -0
- package/template/tests/unit/utils/parseTime.spec.js +37 -0
- package/template/tests/unit/utils/validate.spec.js +28 -0
- package/template/vue.config.js +124 -0
@@ -0,0 +1,273 @@
|
|
1
|
+
<p align="center">
|
2
|
+
<img width="320" src="https://wpimg.wallstcn.com/ecc53a42-d79b-42e2-8852-5126b810a4c8.svg">
|
3
|
+
</p>
|
4
|
+
|
5
|
+
<p align="center">
|
6
|
+
<a href="https://github.com/vuejs/vue">
|
7
|
+
<img src="https://img.shields.io/badge/vue-2.6.10-brightgreen.svg" alt="vue">
|
8
|
+
</a>
|
9
|
+
<a href="https://github.com/ElemeFE/element">
|
10
|
+
<img src="https://img.shields.io/badge/element--ui-2.7.0-brightgreen.svg" alt="element-ui">
|
11
|
+
</a>
|
12
|
+
<a href="https://travis-ci.org/PanJiaChen/vue-element-admin" rel="nofollow">
|
13
|
+
<img src="https://travis-ci.org/PanJiaChen/vue-element-admin.svg?branch=master" alt="Build Status">
|
14
|
+
</a>
|
15
|
+
<a href="https://github.com/PanJiaChen/vue-element-admin/blob/master/LICENSE">
|
16
|
+
<img src="https://img.shields.io/github/license/mashape/apistatus.svg" alt="license">
|
17
|
+
</a>
|
18
|
+
<a href="https://github.com/PanJiaChen/vue-element-admin/releases">
|
19
|
+
<img src="https://img.shields.io/github/release/PanJiaChen/vue-element-admin.svg" alt="GitHub release">
|
20
|
+
</a>
|
21
|
+
<a href="https://gitter.im/vue-element-admin/discuss">
|
22
|
+
<img src="https://badges.gitter.im/Join%20Chat.svg" alt="gitter">
|
23
|
+
</a>
|
24
|
+
<a href="https://panjiachen.gitee.io/vue-element-admin-site/zh/donate">
|
25
|
+
<img src="https://img.shields.io/badge/%24-donate-ff69b4.svg" alt="donate">
|
26
|
+
</a>
|
27
|
+
</p>
|
28
|
+
|
29
|
+
简体中文 | [English](./README.md) | [日本語](./README.ja.md) | [Spanish](./README.es.md)
|
30
|
+
|
31
|
+
<p align="center">
|
32
|
+
<b>SPONSORED BY</b>
|
33
|
+
</p>
|
34
|
+
<table align="center" cellspacing="0" cellpadding="0">
|
35
|
+
<tbody>
|
36
|
+
<tr>
|
37
|
+
<td align="center" valign="middle" width="250">
|
38
|
+
<a href="https://www.duohui.cn/?utm_source=vue-element-admin&utm_medium=web&utm_campaign=vue-element-admin_github" title="多会" target="_blank">
|
39
|
+
<img height="60px" src="https://qiniu.cdn.duohui.co/brand/duohui.png" title="多会 - 活动服务销售平台">
|
40
|
+
<p>活动服务销售平台</p>
|
41
|
+
</a>
|
42
|
+
</td>
|
43
|
+
<td align="center" valign="middle" width="250">
|
44
|
+
<a href="https://youke.co/?utm_source=vue-element-admin&utm_medium=web&utm_campaign=vue-element-admin_github" title="有客" target="_blank">
|
45
|
+
<img height="60px" src="https://qiniu.cdn.duohui.co/brand/youke.png" title="有客 - 客户消息直达工作群">
|
46
|
+
<p>客户消息直达工作群</p>
|
47
|
+
</a>
|
48
|
+
</td>
|
49
|
+
</tr>
|
50
|
+
</tbody>
|
51
|
+
</table>
|
52
|
+
|
53
|
+
## 简介
|
54
|
+
|
55
|
+
[vue-element-admin](https://panjiachen.github.io/vue-element-admin) 是一个后台前端解决方案,它基于 [vue](https://github.com/vuejs/vue) 和 [element-ui](https://github.com/ElemeFE/element)实现。它使用了最新的前端技术栈,内置了 i18n 国际化解决方案,动态路由,权限验证,提炼了典型的业务模型,提供了丰富的功能组件,它可以帮助你快速搭建企业级中后台产品原型。相信不管你的需求是什么,本项目都能帮助到你。
|
56
|
+
|
57
|
+
- [在线预览](https://panjiachen.github.io/vue-element-admin)
|
58
|
+
|
59
|
+
- [使用文档](https://panjiachen.github.io/vue-element-admin-site/zh/)
|
60
|
+
|
61
|
+
- [Gitter 讨论组](https://gitter.im/vue-element-admin/discuss)
|
62
|
+
|
63
|
+
- [Donate](https://panjiachen.gitee.io/vue-element-admin-site/zh/donate)
|
64
|
+
|
65
|
+
- [Wiki](https://github.com/PanJiaChen/vue-element-admin/wiki)
|
66
|
+
|
67
|
+
- [Gitee](https://panjiachen.gitee.io/vue-element-admin/) 在线预览(国内用户可访问该地址)
|
68
|
+
|
69
|
+
- [国内访问文档](https://panjiachen.gitee.io/vue-element-admin-site/zh/) 文档(方便没翻墙的用户查看)
|
70
|
+
|
71
|
+
- 基础模板建议使用: [vue-admin-template](https://github.com/PanJiaChen/vue-admin-template)
|
72
|
+
- 桌面端: [electron-vue-admin](https://github.com/PanJiaChen/electron-vue-admin)
|
73
|
+
- Typescript 版: [vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template) (鸣谢: [@Armour](https://github.com/Armour))
|
74
|
+
- [awesome-project](https://github.com/PanJiaChen/vue-element-admin/issues/2312)
|
75
|
+
|
76
|
+
**`v4.1.0+`版本之后默认 master 分支将不支持国际化,有需要的请使用[i18n](https://github.com/PanJiaChen/vue-element-admin/tree/i18n)分支,它会和 master 保持同步更新**
|
77
|
+
|
78
|
+
**该项目不支持低版本浏览器(如 ie),有需求请自行添加 polyfill [详情](https://github.com/PanJiaChen/vue-element-admin/wiki#babel-polyfill)**
|
79
|
+
|
80
|
+
**目前版本为 `v4.0+` 基于 `vue-cli` 进行构建,若发现问题,欢迎提[issue](https://github.com/PanJiaChen/vue-element-admin/issues/new)。若你想使用旧版本,可以切换分支到[tag/3.11.0](https://github.com/PanJiaChen/vue-element-admin/tree/tag/3.11.0),它不依赖 `vue-cli`**
|
81
|
+
|
82
|
+
群主 **[圈子](https://jianshiapp.com/circles/1209)** 群主会经常分享一些技术相关的东西,或者加入 [qq 群](https://github.com/PanJiaChen/vue-element-admin/issues/602) 或者关注 [微博](https://weibo.com/u/3423485724?is_all=1)
|
83
|
+
|
84
|
+
## 前序准备
|
85
|
+
|
86
|
+
你需要在本地安装 [node](http://nodejs.org/) 和 [git](https://git-scm.com/)。本项目技术栈基于 [ES2015+](http://es6.ruanyifeng.com/)、[vue](https://cn.vuejs.org/index.html)、[vuex](https://vuex.vuejs.org/zh-cn/)、[vue-router](https://router.vuejs.org/zh-cn/) 、[vue-cli](https://github.com/vuejs/vue-cli) 、[axios](https://github.com/axios/axios) 和 [element-ui](https://github.com/ElemeFE/element),所有的请求数据都使用[Mock.js](https://github.com/nuysoft/Mock)进行模拟,提前了解和学习这些知识会对使用本项目有很大的帮助。
|
87
|
+
|
88
|
+
同时配套了系列教程文章,如何从零构建后一个完整的后台项目,建议大家先看完这些文章再来实践本项目
|
89
|
+
|
90
|
+
- [手摸手,带你用 vue 撸后台 系列一(基础篇)](https://juejin.im/post/59097cd7a22b9d0065fb61d2)
|
91
|
+
- [手摸手,带你用 vue 撸后台 系列二(登录权限篇)](https://juejin.im/post/591aa14f570c35006961acac)
|
92
|
+
- [手摸手,带你用 vue 撸后台 系列三 (实战篇)](https://juejin.im/post/593121aa0ce4630057f70d35)
|
93
|
+
- [手摸手,带你用 vue 撸后台 系列四(vueAdmin 一个极简的后台基础模板)](https://juejin.im/post/595b4d776fb9a06bbe7dba56)
|
94
|
+
- [手摸手,带你用vue撸后台 系列五(v4.0新版本)](https://juejin.im/post/5c92ff94f265da6128275a85)
|
95
|
+
- [手摸手,带你封装一个 vue component](https://segmentfault.com/a/1190000009090836)
|
96
|
+
- [手摸手,带你优雅的使用 icon](https://juejin.im/post/59bb864b5188257e7a427c09)
|
97
|
+
- [手摸手,带你用合理的姿势使用 webpack4(上)](https://juejin.im/post/5b56909a518825195f499806)
|
98
|
+
- [手摸手,带你用合理的姿势使用 webpack4(下)](https://juejin.im/post/5b5d6d6f6fb9a04fea58aabc)
|
99
|
+
|
100
|
+
**如有问题请先看上述使用文档和文章,若不能满足,欢迎 issue 和 pr**
|
101
|
+
|
102
|
+
[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/PanJiaChen/vue-element-admin/tree/CodeSandbox)
|
103
|
+
|
104
|
+
<p align="center">
|
105
|
+
<img width="900" src="https://wpimg.wallstcn.com/a5894c1b-f6af-456e-82df-1151da0839bf.png">
|
106
|
+
</p>
|
107
|
+
|
108
|
+
## Sponsors
|
109
|
+
|
110
|
+
Become a sponsor and get your logo on our README on GitHub with a link to your site. [[Become a sponsor]](https://www.patreon.com/panjiachen)
|
111
|
+
|
112
|
+
### Akveo
|
113
|
+
<a href="https://store.akveo.com/products/vue-java-admin-dashboard-spring?utm_campaign=akveo_store-Vue-Vue_demo%2Fgithub&utm_source=vue_admin&utm_medium=referral&utm_content=github_banner"><img width="500px" src="https://raw.githubusercontent.com/PanJiaChen/vue-element-admin-site/master/docs/.vuepress/public/images/vue-java-banner.png" /></a><p>Java 后端整合,可以使用优惠码:SWB0RAZPZR1M,获得20%的价格优化</p>
|
114
|
+
|
115
|
+
### Flatlogic
|
116
|
+
|
117
|
+
<a href="https://flatlogic.com/admin-dashboards?from=vue-element-admin"><img width="150px" src="https://wpimg.wallstcn.com/9c0b719b-5551-4c1e-b776-63994632d94a.png" /></a><p>Admin Dashboard Templates made with Vue, React and Angular.</p>
|
118
|
+
|
119
|
+
|
120
|
+
## 功能
|
121
|
+
|
122
|
+
```
|
123
|
+
- 登录 / 注销
|
124
|
+
|
125
|
+
- 权限验证
|
126
|
+
- 页面权限
|
127
|
+
- 指令权限
|
128
|
+
- 权限配置
|
129
|
+
- 二步登录
|
130
|
+
|
131
|
+
- 多环境发布
|
132
|
+
- dev
|
133
|
+
- sit
|
134
|
+
- stage
|
135
|
+
- prod
|
136
|
+
|
137
|
+
- 全局功能
|
138
|
+
- 国际化多语言
|
139
|
+
- 多种动态换肤
|
140
|
+
- 动态侧边栏(支持多级路由嵌套)
|
141
|
+
- 动态面包屑
|
142
|
+
- 快捷导航(标签页)
|
143
|
+
- Svg Sprite 图标
|
144
|
+
- 本地/后端 mock 数据
|
145
|
+
- Screenfull全屏
|
146
|
+
- 自适应收缩侧边栏
|
147
|
+
|
148
|
+
- 编辑器
|
149
|
+
- 富文本
|
150
|
+
- Markdown
|
151
|
+
- JSON 等多格式
|
152
|
+
|
153
|
+
- Excel
|
154
|
+
- 导出excel
|
155
|
+
- 导入excel
|
156
|
+
- 前端可视化excel
|
157
|
+
- 导出zip
|
158
|
+
|
159
|
+
- 表格
|
160
|
+
- 动态表格
|
161
|
+
- 拖拽表格
|
162
|
+
- 内联编辑
|
163
|
+
|
164
|
+
- 错误页面
|
165
|
+
- 401
|
166
|
+
- 404
|
167
|
+
|
168
|
+
- 組件
|
169
|
+
- 头像上传
|
170
|
+
- 返回顶部
|
171
|
+
- 拖拽Dialog
|
172
|
+
- 拖拽Select
|
173
|
+
- 拖拽看板
|
174
|
+
- 列表拖拽
|
175
|
+
- SplitPane
|
176
|
+
- Dropzone
|
177
|
+
- Sticky
|
178
|
+
- CountTo
|
179
|
+
|
180
|
+
- 综合实例
|
181
|
+
- 错误日志
|
182
|
+
- Dashboard
|
183
|
+
- 引导页
|
184
|
+
- ECharts 图表
|
185
|
+
- Clipboard(剪贴复制)
|
186
|
+
- Markdown2html
|
187
|
+
```
|
188
|
+
|
189
|
+
## 开发
|
190
|
+
|
191
|
+
```bash
|
192
|
+
# 克隆项目
|
193
|
+
git clone https://github.com/PanJiaChen/vue-element-admin.git
|
194
|
+
|
195
|
+
# 进入项目目录
|
196
|
+
cd vue-element-admin
|
197
|
+
|
198
|
+
# 安装依赖
|
199
|
+
npm install
|
200
|
+
|
201
|
+
# 建议不要直接使用 cnpm 安装依赖,会有各种诡异的 bug。可以通过如下操作解决 npm 下载速度慢的问题
|
202
|
+
npm install --registry=https://registry.npm.taobao.org
|
203
|
+
|
204
|
+
# 启动服务
|
205
|
+
npm run dev
|
206
|
+
```
|
207
|
+
|
208
|
+
浏览器访问 http://localhost:9527
|
209
|
+
|
210
|
+
## 发布
|
211
|
+
|
212
|
+
```bash
|
213
|
+
# 构建测试环境
|
214
|
+
npm run build:stage
|
215
|
+
|
216
|
+
# 构建生产环境
|
217
|
+
npm run build:prod
|
218
|
+
```
|
219
|
+
|
220
|
+
## 其它
|
221
|
+
|
222
|
+
```bash
|
223
|
+
# 预览发布环境效果
|
224
|
+
npm run preview
|
225
|
+
|
226
|
+
# 预览发布环境效果 + 静态资源分析
|
227
|
+
npm run preview -- --report
|
228
|
+
|
229
|
+
# 代码格式检查
|
230
|
+
npm run lint
|
231
|
+
|
232
|
+
# 代码格式检查并自动修复
|
233
|
+
npm run lint -- --fix
|
234
|
+
```
|
235
|
+
|
236
|
+
更多信息请参考 [使用文档](https://panjiachen.github.io/vue-element-admin-site/zh/)
|
237
|
+
|
238
|
+
## Changelog
|
239
|
+
|
240
|
+
Detailed changes for each release are documented in the [release notes](https://github.com/PanJiaChen/vue-element-admin/releases).
|
241
|
+
|
242
|
+
## Online Demo
|
243
|
+
|
244
|
+
[在线 Demo](https://panjiachen.github.io/vue-element-admin)
|
245
|
+
|
246
|
+
## Donate
|
247
|
+
|
248
|
+
如果你觉得这个项目帮助到了你,你可以帮作者买一杯果汁表示鼓励 :tropical_drink:
|
249
|
+
![donate](https://panjiachen.github.io/donate/donation.png)
|
250
|
+
|
251
|
+
[更多捐赠方式](https://panjiachen.gitee.io/vue-element-admin-site/zh/donate)
|
252
|
+
|
253
|
+
[Paypal Me](https://www.paypal.me/panfree23)
|
254
|
+
|
255
|
+
[Buy me a coffee](https://www.buymeacoffee.com/Pan)
|
256
|
+
|
257
|
+
## 购买贴纸
|
258
|
+
|
259
|
+
你也可以通过 购买[官方授权的贴纸](https://smallsticker.com/product/vue-element-admin) 的方式来支持 vue-element-admin - 每售出一张贴纸,本项目将获得 2 元的捐赠。
|
260
|
+
|
261
|
+
## Browsers support
|
262
|
+
|
263
|
+
Modern browsers and Internet Explorer 10+.
|
264
|
+
|
265
|
+
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)</br>Safari |
|
266
|
+
| --------- | --------- | --------- | --------- |
|
267
|
+
| IE10, IE11, Edge | last 2 versions | last 2 versions | last 2 versions |
|
268
|
+
|
269
|
+
## License
|
270
|
+
|
271
|
+
[MIT](https://github.com/PanJiaChen/vue-element-admin/blob/master/LICENSE)
|
272
|
+
|
273
|
+
Copyright (c) 2017-present PanJiaChen
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module.exports = {
|
2
|
+
presets: [
|
3
|
+
// https://github.com/vuejs/vue-cli/tree/master/packages/@vue/babel-preset-app
|
4
|
+
'@vue/cli-plugin-babel/preset'
|
5
|
+
],
|
6
|
+
'env': {
|
7
|
+
'development': {
|
8
|
+
// babel-plugin-dynamic-import-node plugin only does one thing by converting all import() to require().
|
9
|
+
// This plugin can significantly increase the speed of hot updates, when you have a large number of pages.
|
10
|
+
// https://panjiachen.github.io/vue-element-admin-site/guide/advanced/lazy-loading.html
|
11
|
+
'plugins': ['dynamic-import-node']
|
12
|
+
}
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
const { run } = require('runjs')
|
2
|
+
const chalk = require('chalk')
|
3
|
+
const config = require('../vue.config.js')
|
4
|
+
const rawArgv = process.argv.slice(2)
|
5
|
+
const args = rawArgv.join(' ')
|
6
|
+
|
7
|
+
if (process.env.npm_config_preview || rawArgv.includes('--preview')) {
|
8
|
+
const report = rawArgv.includes('--report')
|
9
|
+
|
10
|
+
run(`vue-cli-service build ${args}`)
|
11
|
+
|
12
|
+
const port = 9526
|
13
|
+
const publicPath = config.publicPath
|
14
|
+
|
15
|
+
var connect = require('connect')
|
16
|
+
var serveStatic = require('serve-static')
|
17
|
+
const app = connect()
|
18
|
+
|
19
|
+
app.use(
|
20
|
+
publicPath,
|
21
|
+
serveStatic('./dist', {
|
22
|
+
index: ['index.html', '/']
|
23
|
+
})
|
24
|
+
)
|
25
|
+
|
26
|
+
app.listen(port, function () {
|
27
|
+
console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`))
|
28
|
+
if (report) {
|
29
|
+
console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}report.html`))
|
30
|
+
}
|
31
|
+
|
32
|
+
})
|
33
|
+
} else {
|
34
|
+
run(`vue-cli-service build ${args}`)
|
35
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module.exports = {
|
2
|
+
moduleFileExtensions: ['js', 'jsx', 'json', 'vue'],
|
3
|
+
transform: {
|
4
|
+
'^.+\\.vue$': 'vue-jest',
|
5
|
+
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$':
|
6
|
+
'jest-transform-stub',
|
7
|
+
'^.+\\.jsx?$': 'babel-jest'
|
8
|
+
},
|
9
|
+
moduleNameMapper: {
|
10
|
+
'^@/(.*)$': '<rootDir>/src/$1'
|
11
|
+
},
|
12
|
+
snapshotSerializers: ['jest-serializer-vue'],
|
13
|
+
testMatch: [
|
14
|
+
'**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
|
15
|
+
],
|
16
|
+
collectCoverageFrom: ['src/utils/**/*.{js,vue}', '!src/utils/auth.js', '!src/utils/request.js', 'src/components/**/*.{js,vue}'],
|
17
|
+
coverageDirectory: '<rootDir>/tests/unit/coverage',
|
18
|
+
// 'collectCoverage': true,
|
19
|
+
'coverageReporters': [
|
20
|
+
'lcov',
|
21
|
+
'text-summary'
|
22
|
+
],
|
23
|
+
testURL: 'http://localhost/'
|
24
|
+
}
|
@@ -0,0 +1,116 @@
|
|
1
|
+
const Mock = require('mockjs')
|
2
|
+
|
3
|
+
const List = []
|
4
|
+
const count = 100
|
5
|
+
|
6
|
+
const baseContent = '<p>I am testing data, I am testing data.</p><p><img src="https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943"></p>'
|
7
|
+
const image_uri = 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3'
|
8
|
+
|
9
|
+
for (let i = 0; i < count; i++) {
|
10
|
+
List.push(Mock.mock({
|
11
|
+
id: '@increment',
|
12
|
+
timestamp: +Mock.Random.date('T'),
|
13
|
+
author: '@first',
|
14
|
+
reviewer: '@first',
|
15
|
+
title: '@title(5, 10)',
|
16
|
+
content_short: 'mock data',
|
17
|
+
content: baseContent,
|
18
|
+
forecast: '@float(0, 100, 2, 2)',
|
19
|
+
importance: '@integer(1, 3)',
|
20
|
+
'type|1': ['CN', 'US', 'JP', 'EU'],
|
21
|
+
'status|1': ['published', 'draft'],
|
22
|
+
display_time: '@datetime',
|
23
|
+
comment_disabled: true,
|
24
|
+
pageviews: '@integer(300, 5000)',
|
25
|
+
image_uri,
|
26
|
+
platforms: ['a-platform']
|
27
|
+
}))
|
28
|
+
}
|
29
|
+
|
30
|
+
module.exports = [
|
31
|
+
{
|
32
|
+
url: '/vue-element-admin/article/list',
|
33
|
+
type: 'get',
|
34
|
+
response: config => {
|
35
|
+
const { importance, type, title, page = 1, limit = 20, sort } = config.query
|
36
|
+
|
37
|
+
let mockList = List.filter(item => {
|
38
|
+
if (importance && item.importance !== +importance) return false
|
39
|
+
if (type && item.type !== type) return false
|
40
|
+
if (title && item.title.indexOf(title) < 0) return false
|
41
|
+
return true
|
42
|
+
})
|
43
|
+
|
44
|
+
if (sort === '-id') {
|
45
|
+
mockList = mockList.reverse()
|
46
|
+
}
|
47
|
+
|
48
|
+
const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
|
49
|
+
|
50
|
+
return {
|
51
|
+
code: 20000,
|
52
|
+
data: {
|
53
|
+
total: mockList.length,
|
54
|
+
items: pageList
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
},
|
59
|
+
|
60
|
+
{
|
61
|
+
url: '/vue-element-admin/article/detail',
|
62
|
+
type: 'get',
|
63
|
+
response: config => {
|
64
|
+
const { id } = config.query
|
65
|
+
for (const article of List) {
|
66
|
+
if (article.id === +id) {
|
67
|
+
return {
|
68
|
+
code: 20000,
|
69
|
+
data: article
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
},
|
75
|
+
|
76
|
+
{
|
77
|
+
url: '/vue-element-admin/article/pv',
|
78
|
+
type: 'get',
|
79
|
+
response: _ => {
|
80
|
+
return {
|
81
|
+
code: 20000,
|
82
|
+
data: {
|
83
|
+
pvData: [
|
84
|
+
{ key: 'PC', pv: 1024 },
|
85
|
+
{ key: 'mobile', pv: 1024 },
|
86
|
+
{ key: 'ios', pv: 1024 },
|
87
|
+
{ key: 'android', pv: 1024 }
|
88
|
+
]
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
},
|
93
|
+
|
94
|
+
{
|
95
|
+
url: '/vue-element-admin/article/create',
|
96
|
+
type: 'post',
|
97
|
+
response: _ => {
|
98
|
+
return {
|
99
|
+
code: 20000,
|
100
|
+
data: 'success'
|
101
|
+
}
|
102
|
+
}
|
103
|
+
},
|
104
|
+
|
105
|
+
{
|
106
|
+
url: '/vue-element-admin/article/update',
|
107
|
+
type: 'post',
|
108
|
+
response: _ => {
|
109
|
+
return {
|
110
|
+
code: 20000,
|
111
|
+
data: 'success'
|
112
|
+
}
|
113
|
+
}
|
114
|
+
}
|
115
|
+
]
|
116
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
const Mock = require('mockjs')
|
2
|
+
const { param2Obj } = require('./utils')
|
3
|
+
|
4
|
+
const user = require('./user')
|
5
|
+
const role = require('./role')
|
6
|
+
const article = require('./article')
|
7
|
+
const search = require('./remote-search')
|
8
|
+
|
9
|
+
const mocks = [
|
10
|
+
...user,
|
11
|
+
...role,
|
12
|
+
...article,
|
13
|
+
...search
|
14
|
+
]
|
15
|
+
|
16
|
+
// for front mock
|
17
|
+
// please use it cautiously, it will redefine XMLHttpRequest,
|
18
|
+
// which will cause many of your third-party libraries to be invalidated(like progress event).
|
19
|
+
function mockXHR() {
|
20
|
+
// mock patch
|
21
|
+
// https://github.com/nuysoft/Mock/issues/300
|
22
|
+
Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
|
23
|
+
Mock.XHR.prototype.send = function() {
|
24
|
+
if (this.custom.xhr) {
|
25
|
+
this.custom.xhr.withCredentials = this.withCredentials || false
|
26
|
+
|
27
|
+
if (this.responseType) {
|
28
|
+
this.custom.xhr.responseType = this.responseType
|
29
|
+
}
|
30
|
+
}
|
31
|
+
this.proxy_send(...arguments)
|
32
|
+
}
|
33
|
+
|
34
|
+
function XHR2ExpressReqWrap(respond) {
|
35
|
+
return function(options) {
|
36
|
+
let result = null
|
37
|
+
if (respond instanceof Function) {
|
38
|
+
const { body, type, url } = options
|
39
|
+
// https://expressjs.com/en/4x/api.html#req
|
40
|
+
result = respond({
|
41
|
+
method: type,
|
42
|
+
body: JSON.parse(body),
|
43
|
+
query: param2Obj(url)
|
44
|
+
})
|
45
|
+
} else {
|
46
|
+
result = respond
|
47
|
+
}
|
48
|
+
return Mock.mock(result)
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
for (const i of mocks) {
|
53
|
+
Mock.mock(new RegExp(i.url), i.type || 'get', XHR2ExpressReqWrap(i.response))
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
module.exports = {
|
58
|
+
mocks,
|
59
|
+
mockXHR
|
60
|
+
}
|
@@ -0,0 +1,81 @@
|
|
1
|
+
const chokidar = require('chokidar')
|
2
|
+
const bodyParser = require('body-parser')
|
3
|
+
const chalk = require('chalk')
|
4
|
+
const path = require('path')
|
5
|
+
const Mock = require('mockjs')
|
6
|
+
|
7
|
+
const mockDir = path.join(process.cwd(), 'mock')
|
8
|
+
|
9
|
+
function registerRoutes(app) {
|
10
|
+
let mockLastIndex
|
11
|
+
const { mocks } = require('./index.js')
|
12
|
+
const mocksForServer = mocks.map(route => {
|
13
|
+
return responseFake(route.url, route.type, route.response)
|
14
|
+
})
|
15
|
+
for (const mock of mocksForServer) {
|
16
|
+
app[mock.type](mock.url, mock.response)
|
17
|
+
mockLastIndex = app._router.stack.length
|
18
|
+
}
|
19
|
+
const mockRoutesLength = Object.keys(mocksForServer).length
|
20
|
+
return {
|
21
|
+
mockRoutesLength: mockRoutesLength,
|
22
|
+
mockStartIndex: mockLastIndex - mockRoutesLength
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
function unregisterRoutes() {
|
27
|
+
Object.keys(require.cache).forEach(i => {
|
28
|
+
if (i.includes(mockDir)) {
|
29
|
+
delete require.cache[require.resolve(i)]
|
30
|
+
}
|
31
|
+
})
|
32
|
+
}
|
33
|
+
|
34
|
+
// for mock server
|
35
|
+
const responseFake = (url, type, respond) => {
|
36
|
+
return {
|
37
|
+
url: new RegExp(`${process.env.VUE_APP_BASE_API}${url}`),
|
38
|
+
type: type || 'get',
|
39
|
+
response(req, res) {
|
40
|
+
console.log('request invoke:' + req.path)
|
41
|
+
res.json(Mock.mock(respond instanceof Function ? respond(req, res) : respond))
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
module.exports = app => {
|
47
|
+
// parse app.body
|
48
|
+
// https://expressjs.com/en/4x/api.html#req.body
|
49
|
+
app.use(bodyParser.json())
|
50
|
+
app.use(bodyParser.urlencoded({
|
51
|
+
extended: true
|
52
|
+
}))
|
53
|
+
|
54
|
+
const mockRoutes = registerRoutes(app)
|
55
|
+
var mockRoutesLength = mockRoutes.mockRoutesLength
|
56
|
+
var mockStartIndex = mockRoutes.mockStartIndex
|
57
|
+
|
58
|
+
// watch files, hot reload mock server
|
59
|
+
chokidar.watch(mockDir, {
|
60
|
+
ignored: /mock-server/,
|
61
|
+
ignoreInitial: true
|
62
|
+
}).on('all', (event, path) => {
|
63
|
+
if (event === 'change' || event === 'add') {
|
64
|
+
try {
|
65
|
+
// remove mock routes stack
|
66
|
+
app._router.stack.splice(mockStartIndex, mockRoutesLength)
|
67
|
+
|
68
|
+
// clear routes cache
|
69
|
+
unregisterRoutes()
|
70
|
+
|
71
|
+
const mockRoutes = registerRoutes(app)
|
72
|
+
mockRoutesLength = mockRoutes.mockRoutesLength
|
73
|
+
mockStartIndex = mockRoutes.mockStartIndex
|
74
|
+
|
75
|
+
console.log(chalk.magentaBright(`\n > Mock Server hot reload success! changed ${path}`))
|
76
|
+
} catch (error) {
|
77
|
+
console.log(chalk.redBright(error))
|
78
|
+
}
|
79
|
+
}
|
80
|
+
})
|
81
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
const Mock = require('mockjs')
|
2
|
+
|
3
|
+
const NameList = []
|
4
|
+
const count = 100
|
5
|
+
|
6
|
+
for (let i = 0; i < count; i++) {
|
7
|
+
NameList.push(Mock.mock({
|
8
|
+
name: '@first'
|
9
|
+
}))
|
10
|
+
}
|
11
|
+
NameList.push({ name: 'mock-Pan' })
|
12
|
+
|
13
|
+
module.exports = [
|
14
|
+
// username search
|
15
|
+
{
|
16
|
+
url: '/vue-element-admin/search/user',
|
17
|
+
type: 'get',
|
18
|
+
response: config => {
|
19
|
+
const { name } = config.query
|
20
|
+
const mockNameList = NameList.filter(item => {
|
21
|
+
const lowerCaseName = item.name.toLowerCase()
|
22
|
+
return !(name && lowerCaseName.indexOf(name.toLowerCase()) < 0)
|
23
|
+
})
|
24
|
+
return {
|
25
|
+
code: 20000,
|
26
|
+
data: { items: mockNameList }
|
27
|
+
}
|
28
|
+
}
|
29
|
+
},
|
30
|
+
|
31
|
+
// transaction list
|
32
|
+
{
|
33
|
+
url: '/vue-element-admin/transaction/list',
|
34
|
+
type: 'get',
|
35
|
+
response: _ => {
|
36
|
+
return {
|
37
|
+
code: 20000,
|
38
|
+
data: {
|
39
|
+
total: 20,
|
40
|
+
'items|20': [{
|
41
|
+
order_no: '@guid()',
|
42
|
+
timestamp: +Mock.Random.date('T'),
|
43
|
+
username: '@name()',
|
44
|
+
price: '@float(1000, 15000, 0, 2)',
|
45
|
+
'status|1': ['success', 'pending']
|
46
|
+
}]
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
]
|