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.
Files changed (303) hide show
  1. package/package.json +8 -0
  2. package/template/.editorconfig +14 -0
  3. package/template/.env.development +5 -0
  4. package/template/.env.production +6 -0
  5. package/template/.env.staging +8 -0
  6. package/template/.eslintignore +4 -0
  7. package/template/.eslintrc.js +198 -0
  8. package/template/.travis.yml +5 -0
  9. package/template/LICENSE +21 -0
  10. package/template/README.es.md +228 -0
  11. package/template/README.ja.md +224 -0
  12. package/template/README.md +250 -0
  13. package/template/README.zh-CN.md +273 -0
  14. package/template/babel.config.js +14 -0
  15. package/template/build/index.js +35 -0
  16. package/template/jest.config.js +24 -0
  17. package/template/jsconfig.json +9 -0
  18. package/template/mock/article.js +116 -0
  19. package/template/mock/index.js +60 -0
  20. package/template/mock/mock-server.js +81 -0
  21. package/template/mock/remote-search.js +51 -0
  22. package/template/mock/role/index.js +98 -0
  23. package/template/mock/role/routes.js +530 -0
  24. package/template/mock/user.js +84 -0
  25. package/template/mock/utils.js +48 -0
  26. package/template/package.json +111 -0
  27. package/template/plop-templates/component/index.hbs +26 -0
  28. package/template/plop-templates/component/prompt.js +55 -0
  29. package/template/plop-templates/store/index.hbs +16 -0
  30. package/template/plop-templates/store/prompt.js +62 -0
  31. package/template/plop-templates/utils.js +2 -0
  32. package/template/plop-templates/view/index.hbs +26 -0
  33. package/template/plop-templates/view/prompt.js +55 -0
  34. package/template/plopfile.js +9 -0
  35. package/template/postcss.config.js +5 -0
  36. package/template/public/favicon.ico +0 -0
  37. package/template/public/index.html +15 -0
  38. package/template/src/App.vue +11 -0
  39. package/template/src/api/article.js +41 -0
  40. package/template/src/api/qiniu.js +8 -0
  41. package/template/src/api/remote-search.js +17 -0
  42. package/template/src/api/role.js +38 -0
  43. package/template/src/api/user.js +24 -0
  44. package/template/src/assets/401_images/401.gif +0 -0
  45. package/template/src/assets/404_images/404.png +0 -0
  46. package/template/src/assets/404_images/404_cloud.png +0 -0
  47. package/template/src/assets/custom-theme/fonts/element-icons.ttf +0 -0
  48. package/template/src/assets/custom-theme/fonts/element-icons.woff +0 -0
  49. package/template/src/assets/custom-theme/index.css +1 -0
  50. package/template/src/components/BackToTop/index.vue +111 -0
  51. package/template/src/components/Breadcrumb/index.vue +82 -0
  52. package/template/src/components/Charts/Keyboard.vue +155 -0
  53. package/template/src/components/Charts/LineMarker.vue +227 -0
  54. package/template/src/components/Charts/MixChart.vue +271 -0
  55. package/template/src/components/Charts/mixins/resize.js +56 -0
  56. package/template/src/components/DndList/index.vue +166 -0
  57. package/template/src/components/DragSelect/index.vue +65 -0
  58. package/template/src/components/Dropzone/index.vue +297 -0
  59. package/template/src/components/ErrorLog/index.vue +78 -0
  60. package/template/src/components/GithubCorner/index.vue +54 -0
  61. package/template/src/components/Hamburger/index.vue +44 -0
  62. package/template/src/components/HeaderSearch/index.vue +180 -0
  63. package/template/src/components/ImageCropper/index.vue +1779 -0
  64. package/template/src/components/ImageCropper/utils/data2blob.js +19 -0
  65. package/template/src/components/ImageCropper/utils/effectRipple.js +39 -0
  66. package/template/src/components/ImageCropper/utils/language.js +232 -0
  67. package/template/src/components/ImageCropper/utils/mimes.js +7 -0
  68. package/template/src/components/JsonEditor/index.vue +77 -0
  69. package/template/src/components/Kanban/index.vue +99 -0
  70. package/template/src/components/MDinput/index.vue +360 -0
  71. package/template/src/components/MarkdownEditor/default-options.js +31 -0
  72. package/template/src/components/MarkdownEditor/index.vue +118 -0
  73. package/template/src/components/Pagination/index.vue +101 -0
  74. package/template/src/components/PanThumb/index.vue +142 -0
  75. package/template/src/components/RightPanel/index.vue +145 -0
  76. package/template/src/components/Screenfull/index.vue +60 -0
  77. package/template/src/components/Share/DropdownMenu.vue +103 -0
  78. package/template/src/components/SizeSelect/index.vue +57 -0
  79. package/template/src/components/Sticky/index.vue +91 -0
  80. package/template/src/components/SvgIcon/index.vue +62 -0
  81. package/template/src/components/TextHoverEffect/Mallki.vue +113 -0
  82. package/template/src/components/ThemePicker/index.vue +175 -0
  83. package/template/src/components/Tinymce/components/EditorImage.vue +111 -0
  84. package/template/src/components/Tinymce/dynamicLoadScript.js +59 -0
  85. package/template/src/components/Tinymce/index.vue +247 -0
  86. package/template/src/components/Tinymce/plugins.js +7 -0
  87. package/template/src/components/Tinymce/toolbar.js +6 -0
  88. package/template/src/components/Upload/SingleImage.vue +134 -0
  89. package/template/src/components/Upload/SingleImage2.vue +130 -0
  90. package/template/src/components/Upload/SingleImage3.vue +157 -0
  91. package/template/src/components/UploadExcel/index.vue +138 -0
  92. package/template/src/directive/clipboard/clipboard.js +49 -0
  93. package/template/src/directive/clipboard/index.js +13 -0
  94. package/template/src/directive/el-drag-dialog/drag.js +77 -0
  95. package/template/src/directive/el-drag-dialog/index.js +13 -0
  96. package/template/src/directive/el-table/adaptive.js +41 -0
  97. package/template/src/directive/el-table/index.js +13 -0
  98. package/template/src/directive/permission/index.js +13 -0
  99. package/template/src/directive/permission/permission.js +31 -0
  100. package/template/src/directive/sticky.js +91 -0
  101. package/template/src/directive/waves/index.js +13 -0
  102. package/template/src/directive/waves/waves.css +26 -0
  103. package/template/src/directive/waves/waves.js +72 -0
  104. package/template/src/filters/index.js +68 -0
  105. package/template/src/icons/index.js +9 -0
  106. package/template/src/icons/svg/404.svg +1 -0
  107. package/template/src/icons/svg/bug.svg +1 -0
  108. package/template/src/icons/svg/chart.svg +1 -0
  109. package/template/src/icons/svg/clipboard.svg +1 -0
  110. package/template/src/icons/svg/component.svg +1 -0
  111. package/template/src/icons/svg/dashboard.svg +1 -0
  112. package/template/src/icons/svg/documentation.svg +1 -0
  113. package/template/src/icons/svg/drag.svg +1 -0
  114. package/template/src/icons/svg/edit.svg +1 -0
  115. package/template/src/icons/svg/education.svg +1 -0
  116. package/template/src/icons/svg/email.svg +1 -0
  117. package/template/src/icons/svg/example.svg +1 -0
  118. package/template/src/icons/svg/excel.svg +1 -0
  119. package/template/src/icons/svg/exit-fullscreen.svg +1 -0
  120. package/template/src/icons/svg/eye-open.svg +1 -0
  121. package/template/src/icons/svg/eye.svg +1 -0
  122. package/template/src/icons/svg/form.svg +1 -0
  123. package/template/src/icons/svg/fullscreen.svg +1 -0
  124. package/template/src/icons/svg/guide.svg +1 -0
  125. package/template/src/icons/svg/icon.svg +1 -0
  126. package/template/src/icons/svg/international.svg +1 -0
  127. package/template/src/icons/svg/language.svg +1 -0
  128. package/template/src/icons/svg/link.svg +1 -0
  129. package/template/src/icons/svg/list.svg +1 -0
  130. package/template/src/icons/svg/lock.svg +1 -0
  131. package/template/src/icons/svg/message.svg +1 -0
  132. package/template/src/icons/svg/money.svg +1 -0
  133. package/template/src/icons/svg/nested.svg +1 -0
  134. package/template/src/icons/svg/password.svg +1 -0
  135. package/template/src/icons/svg/pdf.svg +1 -0
  136. package/template/src/icons/svg/people.svg +1 -0
  137. package/template/src/icons/svg/peoples.svg +1 -0
  138. package/template/src/icons/svg/qq.svg +1 -0
  139. package/template/src/icons/svg/search.svg +1 -0
  140. package/template/src/icons/svg/shopping.svg +1 -0
  141. package/template/src/icons/svg/size.svg +1 -0
  142. package/template/src/icons/svg/skill.svg +1 -0
  143. package/template/src/icons/svg/star.svg +1 -0
  144. package/template/src/icons/svg/tab.svg +1 -0
  145. package/template/src/icons/svg/table.svg +1 -0
  146. package/template/src/icons/svg/theme.svg +1 -0
  147. package/template/src/icons/svg/tree-table.svg +1 -0
  148. package/template/src/icons/svg/tree.svg +1 -0
  149. package/template/src/icons/svg/user.svg +1 -0
  150. package/template/src/icons/svg/wechat.svg +1 -0
  151. package/template/src/icons/svg/zip.svg +1 -0
  152. package/template/src/icons/svgo.yml +22 -0
  153. package/template/src/layout/components/AppMain.vue +57 -0
  154. package/template/src/layout/components/Navbar.vue +167 -0
  155. package/template/src/layout/components/Settings/index.vue +108 -0
  156. package/template/src/layout/components/Sidebar/FixiOSBug.js +26 -0
  157. package/template/src/layout/components/Sidebar/Item.vue +41 -0
  158. package/template/src/layout/components/Sidebar/Link.vue +43 -0
  159. package/template/src/layout/components/Sidebar/Logo.vue +82 -0
  160. package/template/src/layout/components/Sidebar/SidebarItem.vue +95 -0
  161. package/template/src/layout/components/Sidebar/index.vue +54 -0
  162. package/template/src/layout/components/TagsView/ScrollPane.vue +94 -0
  163. package/template/src/layout/components/TagsView/index.vue +292 -0
  164. package/template/src/layout/components/index.js +5 -0
  165. package/template/src/layout/index.vue +102 -0
  166. package/template/src/layout/mixin/ResizeHandler.js +45 -0
  167. package/template/src/main.js +53 -0
  168. package/template/src/permission.js +74 -0
  169. package/template/src/router/index.js +404 -0
  170. package/template/src/router/modules/charts.js +36 -0
  171. package/template/src/router/modules/components.js +102 -0
  172. package/template/src/router/modules/nested.js +66 -0
  173. package/template/src/router/modules/table.js +41 -0
  174. package/template/src/settings.js +35 -0
  175. package/template/src/store/getters.js +15 -0
  176. package/template/src/store/index.js +25 -0
  177. package/template/src/store/modules/app.js +56 -0
  178. package/template/src/store/modules/errorLog.js +28 -0
  179. package/template/src/store/modules/permission.js +69 -0
  180. package/template/src/store/modules/settings.js +35 -0
  181. package/template/src/store/modules/tagsView.js +160 -0
  182. package/template/src/store/modules/user.js +131 -0
  183. package/template/src/styles/btn.scss +99 -0
  184. package/template/src/styles/element-ui.scss +84 -0
  185. package/template/src/styles/element-variables.scss +31 -0
  186. package/template/src/styles/index.scss +191 -0
  187. package/template/src/styles/mixin.scss +66 -0
  188. package/template/src/styles/sidebar.scss +226 -0
  189. package/template/src/styles/transition.scss +48 -0
  190. package/template/src/styles/variables.scss +35 -0
  191. package/template/src/utils/auth.js +15 -0
  192. package/template/src/utils/clipboard.js +32 -0
  193. package/template/src/utils/error-log.js +35 -0
  194. package/template/src/utils/get-page-title.js +10 -0
  195. package/template/src/utils/index.js +357 -0
  196. package/template/src/utils/open-window.js +25 -0
  197. package/template/src/utils/permission.js +21 -0
  198. package/template/src/utils/request.js +85 -0
  199. package/template/src/utils/scroll-to.js +58 -0
  200. package/template/src/utils/validate.js +87 -0
  201. package/template/src/vendor/Export2Excel.js +220 -0
  202. package/template/src/vendor/Export2Zip.js +24 -0
  203. package/template/src/views/charts/keyboard.vue +23 -0
  204. package/template/src/views/charts/line.vue +23 -0
  205. package/template/src/views/charts/mix-chart.vue +23 -0
  206. package/template/src/views/clipboard/index.vue +49 -0
  207. package/template/src/views/components-demo/avatar-upload.vue +61 -0
  208. package/template/src/views/components-demo/back-to-top.vue +154 -0
  209. package/template/src/views/components-demo/count-to.vue +218 -0
  210. package/template/src/views/components-demo/dnd-list.vue +39 -0
  211. package/template/src/views/components-demo/drag-dialog.vue +61 -0
  212. package/template/src/views/components-demo/drag-kanban.vue +66 -0
  213. package/template/src/views/components-demo/drag-select.vue +43 -0
  214. package/template/src/views/components-demo/dropzone.vue +31 -0
  215. package/template/src/views/components-demo/json-editor.vue +36 -0
  216. package/template/src/views/components-demo/markdown.vue +101 -0
  217. package/template/src/views/components-demo/mixin.vue +169 -0
  218. package/template/src/views/components-demo/split-pane.vue +67 -0
  219. package/template/src/views/components-demo/sticky.vue +135 -0
  220. package/template/src/views/components-demo/tinymce.vue +36 -0
  221. package/template/src/views/dashboard/admin/components/BarChart.vue +102 -0
  222. package/template/src/views/dashboard/admin/components/BoxCard.vue +118 -0
  223. package/template/src/views/dashboard/admin/components/LineChart.vue +135 -0
  224. package/template/src/views/dashboard/admin/components/PanelGroup.vue +181 -0
  225. package/template/src/views/dashboard/admin/components/PieChart.vue +79 -0
  226. package/template/src/views/dashboard/admin/components/RaddarChart.vue +116 -0
  227. package/template/src/views/dashboard/admin/components/TodoList/Todo.vue +81 -0
  228. package/template/src/views/dashboard/admin/components/TodoList/index.scss +320 -0
  229. package/template/src/views/dashboard/admin/components/TodoList/index.vue +127 -0
  230. package/template/src/views/dashboard/admin/components/TransactionTable.vue +55 -0
  231. package/template/src/views/dashboard/admin/components/mixins/resize.js +55 -0
  232. package/template/src/views/dashboard/admin/index.vue +124 -0
  233. package/template/src/views/dashboard/editor/index.vue +74 -0
  234. package/template/src/views/dashboard/index.vue +31 -0
  235. package/template/src/views/documentation/index.vue +57 -0
  236. package/template/src/views/error-log/components/ErrorTestA.vue +13 -0
  237. package/template/src/views/error-log/components/ErrorTestB.vue +11 -0
  238. package/template/src/views/error-log/index.vue +32 -0
  239. package/template/src/views/error-page/401.vue +99 -0
  240. package/template/src/views/error-page/404.vue +228 -0
  241. package/template/src/views/example/components/ArticleDetail.vue +289 -0
  242. package/template/src/views/example/components/Dropdown/Comment.vue +41 -0
  243. package/template/src/views/example/components/Dropdown/Platform.vue +46 -0
  244. package/template/src/views/example/components/Dropdown/SourceUrl.vue +38 -0
  245. package/template/src/views/example/components/Dropdown/index.js +3 -0
  246. package/template/src/views/example/components/Warning.vue +13 -0
  247. package/template/src/views/example/create.vue +13 -0
  248. package/template/src/views/example/edit.vue +13 -0
  249. package/template/src/views/example/list.vue +112 -0
  250. package/template/src/views/excel/components/AutoWidthOption.vue +34 -0
  251. package/template/src/views/excel/components/BookTypeOption.vue +39 -0
  252. package/template/src/views/excel/components/FilenameOption.vue +27 -0
  253. package/template/src/views/excel/export-excel.vue +116 -0
  254. package/template/src/views/excel/merge-header.vue +101 -0
  255. package/template/src/views/excel/select-excel.vue +107 -0
  256. package/template/src/views/excel/upload-excel.vue +42 -0
  257. package/template/src/views/guide/index.vue +36 -0
  258. package/template/src/views/guide/steps.js +53 -0
  259. package/template/src/views/icons/element-icons.js +3 -0
  260. package/template/src/views/icons/index.vue +101 -0
  261. package/template/src/views/icons/svg-icons.js +10 -0
  262. package/template/src/views/login/auth-redirect.vue +15 -0
  263. package/template/src/views/login/components/SocialSignin.vue +72 -0
  264. package/template/src/views/login/index.vue +324 -0
  265. package/template/src/views/nested/menu1/index.vue +7 -0
  266. package/template/src/views/nested/menu1/menu1-1/index.vue +7 -0
  267. package/template/src/views/nested/menu1/menu1-2/index.vue +7 -0
  268. package/template/src/views/nested/menu1/menu1-2/menu1-2-1/index.vue +5 -0
  269. package/template/src/views/nested/menu1/menu1-2/menu1-2-2/index.vue +5 -0
  270. package/template/src/views/nested/menu1/menu1-3/index.vue +5 -0
  271. package/template/src/views/nested/menu2/index.vue +5 -0
  272. package/template/src/views/pdf/content.js +58 -0
  273. package/template/src/views/pdf/download.vue +201 -0
  274. package/template/src/views/pdf/index.vue +13 -0
  275. package/template/src/views/permission/components/SwitchRoles.vue +32 -0
  276. package/template/src/views/permission/directive.vue +111 -0
  277. package/template/src/views/permission/page.vue +19 -0
  278. package/template/src/views/permission/role.vue +270 -0
  279. package/template/src/views/profile/components/Account.vue +38 -0
  280. package/template/src/views/profile/components/Activity.vue +185 -0
  281. package/template/src/views/profile/components/Timeline.vue +43 -0
  282. package/template/src/views/profile/components/UserCard.vue +134 -0
  283. package/template/src/views/profile/index.vue +68 -0
  284. package/template/src/views/qiniu/upload.vue +41 -0
  285. package/template/src/views/redirect/index.vue +12 -0
  286. package/template/src/views/tab/components/TabPane.vue +103 -0
  287. package/template/src/views/tab/index.vue +57 -0
  288. package/template/src/views/table/complex-table.vue +379 -0
  289. package/template/src/views/table/drag-table.vue +153 -0
  290. package/template/src/views/table/dynamic-table/components/FixedThead.vue +62 -0
  291. package/template/src/views/table/dynamic-table/components/UnfixedThead.vue +50 -0
  292. package/template/src/views/table/dynamic-table/index.vue +24 -0
  293. package/template/src/views/table/inline-edit-table.vue +149 -0
  294. package/template/src/views/theme/index.vue +120 -0
  295. package/template/src/views/zip/index.vue +77 -0
  296. package/template/tests/unit/.eslintrc.js +5 -0
  297. package/template/tests/unit/components/Hamburger.spec.js +18 -0
  298. package/template/tests/unit/components/SvgIcon.spec.js +22 -0
  299. package/template/tests/unit/utils/formatTime.spec.js +29 -0
  300. package/template/tests/unit/utils/param2Obj.spec.js +14 -0
  301. package/template/tests/unit/utils/parseTime.spec.js +37 -0
  302. package/template/tests/unit/utils/validate.spec.js +28 -0
  303. package/template/vue.config.js +124 -0
@@ -0,0 +1,41 @@
1
+ /** When your routing table is too long, you can split it into small modules **/
2
+
3
+ import Layout from '@/layout'
4
+
5
+ const tableRouter = {
6
+ path: '/table',
7
+ component: Layout,
8
+ redirect: '/table/complex-table',
9
+ name: 'Table',
10
+ meta: {
11
+ title: 'Table',
12
+ icon: 'table'
13
+ },
14
+ children: [
15
+ {
16
+ path: 'dynamic-table',
17
+ component: () => import('@/views/table/dynamic-table/index'),
18
+ name: 'DynamicTable',
19
+ meta: { title: 'Dynamic Table' }
20
+ },
21
+ {
22
+ path: 'drag-table',
23
+ component: () => import('@/views/table/drag-table'),
24
+ name: 'DragTable',
25
+ meta: { title: 'Drag Table' }
26
+ },
27
+ {
28
+ path: 'inline-edit-table',
29
+ component: () => import('@/views/table/inline-edit-table'),
30
+ name: 'InlineEditTable',
31
+ meta: { title: 'Inline Edit' }
32
+ },
33
+ {
34
+ path: 'complex-table',
35
+ component: () => import('@/views/table/complex-table'),
36
+ name: 'ComplexTable',
37
+ meta: { title: 'Complex Table' }
38
+ }
39
+ ]
40
+ }
41
+ export default tableRouter
@@ -0,0 +1,35 @@
1
+ module.exports = {
2
+ title: 'Vue Element Admin',
3
+
4
+ /**
5
+ * @type {boolean} true | false
6
+ * @description Whether show the settings right-panel
7
+ */
8
+ showSettings: true,
9
+
10
+ /**
11
+ * @type {boolean} true | false
12
+ * @description Whether need tagsView
13
+ */
14
+ tagsView: true,
15
+
16
+ /**
17
+ * @type {boolean} true | false
18
+ * @description Whether fix the header
19
+ */
20
+ fixedHeader: false,
21
+
22
+ /**
23
+ * @type {boolean} true | false
24
+ * @description Whether show the logo in sidebar
25
+ */
26
+ sidebarLogo: false,
27
+
28
+ /**
29
+ * @type {string | array} 'production' | ['production', 'development']
30
+ * @description Need show err logs component.
31
+ * The default is only used in the production env
32
+ * If you want to also use it in dev, you can pass ['production', 'development']
33
+ */
34
+ errorLog: 'production'
35
+ }
@@ -0,0 +1,15 @@
1
+ const getters = {
2
+ sidebar: state => state.app.sidebar,
3
+ size: state => state.app.size,
4
+ device: state => state.app.device,
5
+ visitedViews: state => state.tagsView.visitedViews,
6
+ cachedViews: state => state.tagsView.cachedViews,
7
+ token: state => state.user.token,
8
+ avatar: state => state.user.avatar,
9
+ name: state => state.user.name,
10
+ introduction: state => state.user.introduction,
11
+ roles: state => state.user.roles,
12
+ permission_routes: state => state.permission.routes,
13
+ errorLogs: state => state.errorLog.logs
14
+ }
15
+ export default getters
@@ -0,0 +1,25 @@
1
+ import Vue from 'vue'
2
+ import Vuex from 'vuex'
3
+ import getters from './getters'
4
+
5
+ Vue.use(Vuex)
6
+
7
+ // https://webpack.js.org/guides/dependency-management/#requirecontext
8
+ const modulesFiles = require.context('./modules', true, /\.js$/)
9
+
10
+ // you do not need `import app from './modules/app'`
11
+ // it will auto require all vuex module from modules file
12
+ const modules = modulesFiles.keys().reduce((modules, modulePath) => {
13
+ // set './app.js' => 'app'
14
+ const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
15
+ const value = modulesFiles(modulePath)
16
+ modules[moduleName] = value.default
17
+ return modules
18
+ }, {})
19
+
20
+ const store = new Vuex.Store({
21
+ modules,
22
+ getters
23
+ })
24
+
25
+ export default store
@@ -0,0 +1,56 @@
1
+ import Cookies from 'js-cookie'
2
+
3
+ const state = {
4
+ sidebar: {
5
+ opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
6
+ withoutAnimation: false
7
+ },
8
+ device: 'desktop',
9
+ size: Cookies.get('size') || 'medium'
10
+ }
11
+
12
+ const mutations = {
13
+ TOGGLE_SIDEBAR: state => {
14
+ state.sidebar.opened = !state.sidebar.opened
15
+ state.sidebar.withoutAnimation = false
16
+ if (state.sidebar.opened) {
17
+ Cookies.set('sidebarStatus', 1)
18
+ } else {
19
+ Cookies.set('sidebarStatus', 0)
20
+ }
21
+ },
22
+ CLOSE_SIDEBAR: (state, withoutAnimation) => {
23
+ Cookies.set('sidebarStatus', 0)
24
+ state.sidebar.opened = false
25
+ state.sidebar.withoutAnimation = withoutAnimation
26
+ },
27
+ TOGGLE_DEVICE: (state, device) => {
28
+ state.device = device
29
+ },
30
+ SET_SIZE: (state, size) => {
31
+ state.size = size
32
+ Cookies.set('size', size)
33
+ }
34
+ }
35
+
36
+ const actions = {
37
+ toggleSideBar({ commit }) {
38
+ commit('TOGGLE_SIDEBAR')
39
+ },
40
+ closeSideBar({ commit }, { withoutAnimation }) {
41
+ commit('CLOSE_SIDEBAR', withoutAnimation)
42
+ },
43
+ toggleDevice({ commit }, device) {
44
+ commit('TOGGLE_DEVICE', device)
45
+ },
46
+ setSize({ commit }, size) {
47
+ commit('SET_SIZE', size)
48
+ }
49
+ }
50
+
51
+ export default {
52
+ namespaced: true,
53
+ state,
54
+ mutations,
55
+ actions
56
+ }
@@ -0,0 +1,28 @@
1
+ const state = {
2
+ logs: []
3
+ }
4
+
5
+ const mutations = {
6
+ ADD_ERROR_LOG: (state, log) => {
7
+ state.logs.push(log)
8
+ },
9
+ CLEAR_ERROR_LOG: (state) => {
10
+ state.logs.splice(0)
11
+ }
12
+ }
13
+
14
+ const actions = {
15
+ addErrorLog({ commit }, log) {
16
+ commit('ADD_ERROR_LOG', log)
17
+ },
18
+ clearErrorLog({ commit }) {
19
+ commit('CLEAR_ERROR_LOG')
20
+ }
21
+ }
22
+
23
+ export default {
24
+ namespaced: true,
25
+ state,
26
+ mutations,
27
+ actions
28
+ }
@@ -0,0 +1,69 @@
1
+ import { asyncRoutes, constantRoutes } from '@/router'
2
+
3
+ /**
4
+ * Use meta.role to determine if the current user has permission
5
+ * @param roles
6
+ * @param route
7
+ */
8
+ function hasPermission(roles, route) {
9
+ if (route.meta && route.meta.roles) {
10
+ return roles.some(role => route.meta.roles.includes(role))
11
+ } else {
12
+ return true
13
+ }
14
+ }
15
+
16
+ /**
17
+ * Filter asynchronous routing tables by recursion
18
+ * @param routes asyncRoutes
19
+ * @param roles
20
+ */
21
+ export function filterAsyncRoutes(routes, roles) {
22
+ const res = []
23
+
24
+ routes.forEach(route => {
25
+ const tmp = { ...route }
26
+ if (hasPermission(roles, tmp)) {
27
+ if (tmp.children) {
28
+ tmp.children = filterAsyncRoutes(tmp.children, roles)
29
+ }
30
+ res.push(tmp)
31
+ }
32
+ })
33
+
34
+ return res
35
+ }
36
+
37
+ const state = {
38
+ routes: [],
39
+ addRoutes: []
40
+ }
41
+
42
+ const mutations = {
43
+ SET_ROUTES: (state, routes) => {
44
+ state.addRoutes = routes
45
+ state.routes = constantRoutes.concat(routes)
46
+ }
47
+ }
48
+
49
+ const actions = {
50
+ generateRoutes({ commit }, roles) {
51
+ return new Promise(resolve => {
52
+ let accessedRoutes
53
+ if (roles.includes('admin')) {
54
+ accessedRoutes = asyncRoutes || []
55
+ } else {
56
+ accessedRoutes = filterAsyncRoutes(asyncRoutes, roles)
57
+ }
58
+ commit('SET_ROUTES', accessedRoutes)
59
+ resolve(accessedRoutes)
60
+ })
61
+ }
62
+ }
63
+
64
+ export default {
65
+ namespaced: true,
66
+ state,
67
+ mutations,
68
+ actions
69
+ }
@@ -0,0 +1,35 @@
1
+ import variables from '@/styles/element-variables.scss'
2
+ import defaultSettings from '@/settings'
3
+
4
+ const { showSettings, tagsView, fixedHeader, sidebarLogo } = defaultSettings
5
+
6
+ const state = {
7
+ theme: variables.theme,
8
+ showSettings: showSettings,
9
+ tagsView: tagsView,
10
+ fixedHeader: fixedHeader,
11
+ sidebarLogo: sidebarLogo
12
+ }
13
+
14
+ const mutations = {
15
+ CHANGE_SETTING: (state, { key, value }) => {
16
+ // eslint-disable-next-line no-prototype-builtins
17
+ if (state.hasOwnProperty(key)) {
18
+ state[key] = value
19
+ }
20
+ }
21
+ }
22
+
23
+ const actions = {
24
+ changeSetting({ commit }, data) {
25
+ commit('CHANGE_SETTING', data)
26
+ }
27
+ }
28
+
29
+ export default {
30
+ namespaced: true,
31
+ state,
32
+ mutations,
33
+ actions
34
+ }
35
+
@@ -0,0 +1,160 @@
1
+ const state = {
2
+ visitedViews: [],
3
+ cachedViews: []
4
+ }
5
+
6
+ const mutations = {
7
+ ADD_VISITED_VIEW: (state, view) => {
8
+ if (state.visitedViews.some(v => v.path === view.path)) return
9
+ state.visitedViews.push(
10
+ Object.assign({}, view, {
11
+ title: view.meta.title || 'no-name'
12
+ })
13
+ )
14
+ },
15
+ ADD_CACHED_VIEW: (state, view) => {
16
+ if (state.cachedViews.includes(view.name)) return
17
+ if (!view.meta.noCache) {
18
+ state.cachedViews.push(view.name)
19
+ }
20
+ },
21
+
22
+ DEL_VISITED_VIEW: (state, view) => {
23
+ for (const [i, v] of state.visitedViews.entries()) {
24
+ if (v.path === view.path) {
25
+ state.visitedViews.splice(i, 1)
26
+ break
27
+ }
28
+ }
29
+ },
30
+ DEL_CACHED_VIEW: (state, view) => {
31
+ const index = state.cachedViews.indexOf(view.name)
32
+ index > -1 && state.cachedViews.splice(index, 1)
33
+ },
34
+
35
+ DEL_OTHERS_VISITED_VIEWS: (state, view) => {
36
+ state.visitedViews = state.visitedViews.filter(v => {
37
+ return v.meta.affix || v.path === view.path
38
+ })
39
+ },
40
+ DEL_OTHERS_CACHED_VIEWS: (state, view) => {
41
+ const index = state.cachedViews.indexOf(view.name)
42
+ if (index > -1) {
43
+ state.cachedViews = state.cachedViews.slice(index, index + 1)
44
+ } else {
45
+ // if index = -1, there is no cached tags
46
+ state.cachedViews = []
47
+ }
48
+ },
49
+
50
+ DEL_ALL_VISITED_VIEWS: state => {
51
+ // keep affix tags
52
+ const affixTags = state.visitedViews.filter(tag => tag.meta.affix)
53
+ state.visitedViews = affixTags
54
+ },
55
+ DEL_ALL_CACHED_VIEWS: state => {
56
+ state.cachedViews = []
57
+ },
58
+
59
+ UPDATE_VISITED_VIEW: (state, view) => {
60
+ for (let v of state.visitedViews) {
61
+ if (v.path === view.path) {
62
+ v = Object.assign(v, view)
63
+ break
64
+ }
65
+ }
66
+ }
67
+ }
68
+
69
+ const actions = {
70
+ addView({ dispatch }, view) {
71
+ dispatch('addVisitedView', view)
72
+ dispatch('addCachedView', view)
73
+ },
74
+ addVisitedView({ commit }, view) {
75
+ commit('ADD_VISITED_VIEW', view)
76
+ },
77
+ addCachedView({ commit }, view) {
78
+ commit('ADD_CACHED_VIEW', view)
79
+ },
80
+
81
+ delView({ dispatch, state }, view) {
82
+ return new Promise(resolve => {
83
+ dispatch('delVisitedView', view)
84
+ dispatch('delCachedView', view)
85
+ resolve({
86
+ visitedViews: [...state.visitedViews],
87
+ cachedViews: [...state.cachedViews]
88
+ })
89
+ })
90
+ },
91
+ delVisitedView({ commit, state }, view) {
92
+ return new Promise(resolve => {
93
+ commit('DEL_VISITED_VIEW', view)
94
+ resolve([...state.visitedViews])
95
+ })
96
+ },
97
+ delCachedView({ commit, state }, view) {
98
+ return new Promise(resolve => {
99
+ commit('DEL_CACHED_VIEW', view)
100
+ resolve([...state.cachedViews])
101
+ })
102
+ },
103
+
104
+ delOthersViews({ dispatch, state }, view) {
105
+ return new Promise(resolve => {
106
+ dispatch('delOthersVisitedViews', view)
107
+ dispatch('delOthersCachedViews', view)
108
+ resolve({
109
+ visitedViews: [...state.visitedViews],
110
+ cachedViews: [...state.cachedViews]
111
+ })
112
+ })
113
+ },
114
+ delOthersVisitedViews({ commit, state }, view) {
115
+ return new Promise(resolve => {
116
+ commit('DEL_OTHERS_VISITED_VIEWS', view)
117
+ resolve([...state.visitedViews])
118
+ })
119
+ },
120
+ delOthersCachedViews({ commit, state }, view) {
121
+ return new Promise(resolve => {
122
+ commit('DEL_OTHERS_CACHED_VIEWS', view)
123
+ resolve([...state.cachedViews])
124
+ })
125
+ },
126
+
127
+ delAllViews({ dispatch, state }, view) {
128
+ return new Promise(resolve => {
129
+ dispatch('delAllVisitedViews', view)
130
+ dispatch('delAllCachedViews', view)
131
+ resolve({
132
+ visitedViews: [...state.visitedViews],
133
+ cachedViews: [...state.cachedViews]
134
+ })
135
+ })
136
+ },
137
+ delAllVisitedViews({ commit, state }) {
138
+ return new Promise(resolve => {
139
+ commit('DEL_ALL_VISITED_VIEWS')
140
+ resolve([...state.visitedViews])
141
+ })
142
+ },
143
+ delAllCachedViews({ commit, state }) {
144
+ return new Promise(resolve => {
145
+ commit('DEL_ALL_CACHED_VIEWS')
146
+ resolve([...state.cachedViews])
147
+ })
148
+ },
149
+
150
+ updateVisitedView({ commit }, view) {
151
+ commit('UPDATE_VISITED_VIEW', view)
152
+ }
153
+ }
154
+
155
+ export default {
156
+ namespaced: true,
157
+ state,
158
+ mutations,
159
+ actions
160
+ }
@@ -0,0 +1,131 @@
1
+ import { login, logout, getInfo } from '@/api/user'
2
+ import { getToken, setToken, removeToken } from '@/utils/auth'
3
+ import router, { resetRouter } from '@/router'
4
+
5
+ const state = {
6
+ token: getToken(),
7
+ name: '',
8
+ avatar: '',
9
+ introduction: '',
10
+ roles: []
11
+ }
12
+
13
+ const mutations = {
14
+ SET_TOKEN: (state, token) => {
15
+ state.token = token
16
+ },
17
+ SET_INTRODUCTION: (state, introduction) => {
18
+ state.introduction = introduction
19
+ },
20
+ SET_NAME: (state, name) => {
21
+ state.name = name
22
+ },
23
+ SET_AVATAR: (state, avatar) => {
24
+ state.avatar = avatar
25
+ },
26
+ SET_ROLES: (state, roles) => {
27
+ state.roles = roles
28
+ }
29
+ }
30
+
31
+ const actions = {
32
+ // user login
33
+ login({ commit }, userInfo) {
34
+ const { username, password } = userInfo
35
+ return new Promise((resolve, reject) => {
36
+ login({ username: username.trim(), password: password }).then(response => {
37
+ const { data } = response
38
+ commit('SET_TOKEN', data.token)
39
+ setToken(data.token)
40
+ resolve()
41
+ }).catch(error => {
42
+ reject(error)
43
+ })
44
+ })
45
+ },
46
+
47
+ // get user info
48
+ getInfo({ commit, state }) {
49
+ return new Promise((resolve, reject) => {
50
+ getInfo(state.token).then(response => {
51
+ const { data } = response
52
+
53
+ if (!data) {
54
+ reject('Verification failed, please Login again.')
55
+ }
56
+
57
+ const { roles, name, avatar, introduction } = data
58
+
59
+ // roles must be a non-empty array
60
+ if (!roles || roles.length <= 0) {
61
+ reject('getInfo: roles must be a non-null array!')
62
+ }
63
+
64
+ commit('SET_ROLES', roles)
65
+ commit('SET_NAME', name)
66
+ commit('SET_AVATAR', avatar)
67
+ commit('SET_INTRODUCTION', introduction)
68
+ resolve(data)
69
+ }).catch(error => {
70
+ reject(error)
71
+ })
72
+ })
73
+ },
74
+
75
+ // user logout
76
+ logout({ commit, state, dispatch }) {
77
+ return new Promise((resolve, reject) => {
78
+ logout(state.token).then(() => {
79
+ commit('SET_TOKEN', '')
80
+ commit('SET_ROLES', [])
81
+ removeToken()
82
+ resetRouter()
83
+
84
+ // reset visited views and cached views
85
+ // to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485
86
+ dispatch('tagsView/delAllViews', null, { root: true })
87
+
88
+ resolve()
89
+ }).catch(error => {
90
+ reject(error)
91
+ })
92
+ })
93
+ },
94
+
95
+ // remove token
96
+ resetToken({ commit }) {
97
+ return new Promise(resolve => {
98
+ commit('SET_TOKEN', '')
99
+ commit('SET_ROLES', [])
100
+ removeToken()
101
+ resolve()
102
+ })
103
+ },
104
+
105
+ // dynamically modify permissions
106
+ async changeRoles({ commit, dispatch }, role) {
107
+ const token = role + '-token'
108
+
109
+ commit('SET_TOKEN', token)
110
+ setToken(token)
111
+
112
+ const { roles } = await dispatch('getInfo')
113
+
114
+ resetRouter()
115
+
116
+ // generate accessible routes map based on roles
117
+ const accessRoutes = await dispatch('permission/generateRoutes', roles, { root: true })
118
+ // dynamically add accessible routes
119
+ router.addRoutes(accessRoutes)
120
+
121
+ // reset visited views and cached views
122
+ dispatch('tagsView/delAllViews', null, { root: true })
123
+ }
124
+ }
125
+
126
+ export default {
127
+ namespaced: true,
128
+ state,
129
+ mutations,
130
+ actions
131
+ }
@@ -0,0 +1,99 @@
1
+ @import './variables.scss';
2
+
3
+ @mixin colorBtn($color) {
4
+ background: $color;
5
+
6
+ &:hover {
7
+ color: $color;
8
+
9
+ &:before,
10
+ &:after {
11
+ background: $color;
12
+ }
13
+ }
14
+ }
15
+
16
+ .blue-btn {
17
+ @include colorBtn($blue)
18
+ }
19
+
20
+ .light-blue-btn {
21
+ @include colorBtn($light-blue)
22
+ }
23
+
24
+ .red-btn {
25
+ @include colorBtn($red)
26
+ }
27
+
28
+ .pink-btn {
29
+ @include colorBtn($pink)
30
+ }
31
+
32
+ .green-btn {
33
+ @include colorBtn($green)
34
+ }
35
+
36
+ .tiffany-btn {
37
+ @include colorBtn($tiffany)
38
+ }
39
+
40
+ .yellow-btn {
41
+ @include colorBtn($yellow)
42
+ }
43
+
44
+ .pan-btn {
45
+ font-size: 14px;
46
+ color: #fff;
47
+ padding: 14px 36px;
48
+ border-radius: 8px;
49
+ border: none;
50
+ outline: none;
51
+ transition: 600ms ease all;
52
+ position: relative;
53
+ display: inline-block;
54
+
55
+ &:hover {
56
+ background: #fff;
57
+
58
+ &:before,
59
+ &:after {
60
+ width: 100%;
61
+ transition: 600ms ease all;
62
+ }
63
+ }
64
+
65
+ &:before,
66
+ &:after {
67
+ content: '';
68
+ position: absolute;
69
+ top: 0;
70
+ right: 0;
71
+ height: 2px;
72
+ width: 0;
73
+ transition: 400ms ease all;
74
+ }
75
+
76
+ &::after {
77
+ right: inherit;
78
+ top: inherit;
79
+ left: 0;
80
+ bottom: 0;
81
+ }
82
+ }
83
+
84
+ .custom-button {
85
+ display: inline-block;
86
+ line-height: 1;
87
+ white-space: nowrap;
88
+ cursor: pointer;
89
+ background: #fff;
90
+ color: #fff;
91
+ -webkit-appearance: none;
92
+ text-align: center;
93
+ box-sizing: border-box;
94
+ outline: 0;
95
+ margin: 0;
96
+ padding: 10px 15px;
97
+ font-size: 14px;
98
+ border-radius: 4px;
99
+ }