@lavida/vue-element-admin-template 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/package.json +15 -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 +222 -0
  11. package/template/README.ja.md +218 -0
  12. package/template/README.md +222 -0
  13. package/template/README.zh-CN.md +245 -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 +250 -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 +25 -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 +56 -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 +125 -0
@@ -0,0 +1,95 @@
1
+ <template>
2
+ <div v-if="!item.hidden">
3
+ <template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow">
4
+ <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
5
+ <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
6
+ <item :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :title="onlyOneChild.meta.title" />
7
+ </el-menu-item>
8
+ </app-link>
9
+ </template>
10
+
11
+ <el-submenu v-else ref="subMenu" :index="resolvePath(item.path)" popper-append-to-body>
12
+ <template slot="title">
13
+ <item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" />
14
+ </template>
15
+ <sidebar-item
16
+ v-for="child in item.children"
17
+ :key="child.path"
18
+ :is-nest="true"
19
+ :item="child"
20
+ :base-path="resolvePath(child.path)"
21
+ class="nest-menu"
22
+ />
23
+ </el-submenu>
24
+ </div>
25
+ </template>
26
+
27
+ <script>
28
+ import path from 'path'
29
+ import { isExternal } from '@/utils/validate'
30
+ import Item from './Item'
31
+ import AppLink from './Link'
32
+ import FixiOSBug from './FixiOSBug'
33
+
34
+ export default {
35
+ name: 'SidebarItem',
36
+ components: { Item, AppLink },
37
+ mixins: [FixiOSBug],
38
+ props: {
39
+ // route object
40
+ item: {
41
+ type: Object,
42
+ required: true
43
+ },
44
+ isNest: {
45
+ type: Boolean,
46
+ default: false
47
+ },
48
+ basePath: {
49
+ type: String,
50
+ default: ''
51
+ }
52
+ },
53
+ data() {
54
+ // To fix https://github.com/PanJiaChen/vue-admin-template/issues/237
55
+ // TODO: refactor with render function
56
+ this.onlyOneChild = null
57
+ return {}
58
+ },
59
+ methods: {
60
+ hasOneShowingChild(children = [], parent) {
61
+ const showingChildren = children.filter(item => {
62
+ if (item.hidden) {
63
+ return false
64
+ } else {
65
+ // Temp set(will be used if only has one showing child)
66
+ this.onlyOneChild = item
67
+ return true
68
+ }
69
+ })
70
+
71
+ // When there is only one child router, the child router is displayed by default
72
+ if (showingChildren.length === 1) {
73
+ return true
74
+ }
75
+
76
+ // Show parent if there are no child router to display
77
+ if (showingChildren.length === 0) {
78
+ this.onlyOneChild = { ... parent, path: '', noShowingChildren: true }
79
+ return true
80
+ }
81
+
82
+ return false
83
+ },
84
+ resolvePath(routePath) {
85
+ if (isExternal(routePath)) {
86
+ return routePath
87
+ }
88
+ if (isExternal(this.basePath)) {
89
+ return this.basePath
90
+ }
91
+ return path.resolve(this.basePath, routePath)
92
+ }
93
+ }
94
+ }
95
+ </script>
@@ -0,0 +1,54 @@
1
+ <template>
2
+ <div :class="{'has-logo':showLogo}">
3
+ <logo v-if="showLogo" :collapse="isCollapse" />
4
+ <el-scrollbar wrap-class="scrollbar-wrapper">
5
+ <el-menu
6
+ :default-active="activeMenu"
7
+ :collapse="isCollapse"
8
+ :background-color="variables.menuBg"
9
+ :text-color="variables.menuText"
10
+ :unique-opened="false"
11
+ :active-text-color="variables.menuActiveText"
12
+ :collapse-transition="false"
13
+ mode="vertical"
14
+ >
15
+ <sidebar-item v-for="route in permission_routes" :key="route.path" :item="route" :base-path="route.path" />
16
+ </el-menu>
17
+ </el-scrollbar>
18
+ </div>
19
+ </template>
20
+
21
+ <script>
22
+ import { mapGetters } from 'vuex'
23
+ import Logo from './Logo'
24
+ import SidebarItem from './SidebarItem'
25
+ import variables from '@/styles/variables.scss'
26
+
27
+ export default {
28
+ components: { SidebarItem, Logo },
29
+ computed: {
30
+ ...mapGetters([
31
+ 'permission_routes',
32
+ 'sidebar'
33
+ ]),
34
+ activeMenu() {
35
+ const route = this.$route
36
+ const { meta, path } = route
37
+ // if set path, the sidebar will highlight the path you set
38
+ if (meta.activeMenu) {
39
+ return meta.activeMenu
40
+ }
41
+ return path
42
+ },
43
+ showLogo() {
44
+ return this.$store.state.settings.sidebarLogo
45
+ },
46
+ variables() {
47
+ return variables
48
+ },
49
+ isCollapse() {
50
+ return !this.sidebar.opened
51
+ }
52
+ }
53
+ }
54
+ </script>
@@ -0,0 +1,94 @@
1
+ <template>
2
+ <el-scrollbar ref="scrollContainer" :vertical="false" class="scroll-container" @wheel.native.prevent="handleScroll">
3
+ <slot />
4
+ </el-scrollbar>
5
+ </template>
6
+
7
+ <script>
8
+ const tagAndTagSpacing = 4 // tagAndTagSpacing
9
+
10
+ export default {
11
+ name: 'ScrollPane',
12
+ data() {
13
+ return {
14
+ left: 0
15
+ }
16
+ },
17
+ computed: {
18
+ scrollWrapper() {
19
+ return this.$refs.scrollContainer.$refs.wrap
20
+ }
21
+ },
22
+ mounted() {
23
+ this.scrollWrapper.addEventListener('scroll', this.emitScroll, true)
24
+ },
25
+ beforeDestroy() {
26
+ this.scrollWrapper.removeEventListener('scroll', this.emitScroll)
27
+ },
28
+ methods: {
29
+ handleScroll(e) {
30
+ const eventDelta = e.wheelDelta || -e.deltaY * 40
31
+ const $scrollWrapper = this.scrollWrapper
32
+ $scrollWrapper.scrollLeft = $scrollWrapper.scrollLeft + eventDelta / 4
33
+ },
34
+ emitScroll() {
35
+ this.$emit('scroll')
36
+ },
37
+ moveToTarget(currentTag) {
38
+ const $container = this.$refs.scrollContainer.$el
39
+ const $containerWidth = $container.offsetWidth
40
+ const $scrollWrapper = this.scrollWrapper
41
+ const tagList = this.$parent.$refs.tag
42
+
43
+ let firstTag = null
44
+ let lastTag = null
45
+
46
+ // find first tag and last tag
47
+ if (tagList.length > 0) {
48
+ firstTag = tagList[0]
49
+ lastTag = tagList[tagList.length - 1]
50
+ }
51
+
52
+ if (firstTag === currentTag) {
53
+ $scrollWrapper.scrollLeft = 0
54
+ } else if (lastTag === currentTag) {
55
+ $scrollWrapper.scrollLeft = $scrollWrapper.scrollWidth - $containerWidth
56
+ } else {
57
+ // find preTag and nextTag
58
+ const currentIndex = tagList.findIndex(item => item === currentTag)
59
+ const prevTag = tagList[currentIndex - 1]
60
+ const nextTag = tagList[currentIndex + 1]
61
+
62
+ // the tag's offsetLeft after of nextTag
63
+ const afterNextTagOffsetLeft = nextTag.$el.offsetLeft + nextTag.$el.offsetWidth + tagAndTagSpacing
64
+
65
+ // the tag's offsetLeft before of prevTag
66
+ const beforePrevTagOffsetLeft = prevTag.$el.offsetLeft - tagAndTagSpacing
67
+
68
+ if (afterNextTagOffsetLeft > $scrollWrapper.scrollLeft + $containerWidth) {
69
+ $scrollWrapper.scrollLeft = afterNextTagOffsetLeft - $containerWidth
70
+ } else if (beforePrevTagOffsetLeft < $scrollWrapper.scrollLeft) {
71
+ $scrollWrapper.scrollLeft = beforePrevTagOffsetLeft
72
+ }
73
+ }
74
+ }
75
+ }
76
+ }
77
+ </script>
78
+
79
+ <style lang="scss" scoped>
80
+ .scroll-container {
81
+ white-space: nowrap;
82
+ position: relative;
83
+ overflow: hidden;
84
+ width: 100%;
85
+ ::v-deep {
86
+ .el-scrollbar__bar {
87
+ bottom: 0px;
88
+ }
89
+ .el-scrollbar__wrap {
90
+ height: 49px;
91
+ }
92
+ }
93
+ }
94
+ </style>
@@ -0,0 +1,292 @@
1
+ <template>
2
+ <div id="tags-view-container" class="tags-view-container">
3
+ <scroll-pane ref="scrollPane" class="tags-view-wrapper" @scroll="handleScroll">
4
+ <router-link
5
+ v-for="tag in visitedViews"
6
+ ref="tag"
7
+ :key="tag.path"
8
+ :class="isActive(tag)?'active':''"
9
+ :to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
10
+ tag="span"
11
+ class="tags-view-item"
12
+ @click.middle.native="!isAffix(tag)?closeSelectedTag(tag):''"
13
+ @contextmenu.prevent.native="openMenu(tag,$event)"
14
+ >
15
+ {{ tag.title }}
16
+ <span v-if="!isAffix(tag)" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" />
17
+ </router-link>
18
+ </scroll-pane>
19
+ <ul v-show="visible" :style="{left:left+'px',top:top+'px'}" class="contextmenu">
20
+ <li @click="refreshSelectedTag(selectedTag)">Refresh</li>
21
+ <li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)">Close</li>
22
+ <li @click="closeOthersTags">Close Others</li>
23
+ <li @click="closeAllTags(selectedTag)">Close All</li>
24
+ </ul>
25
+ </div>
26
+ </template>
27
+
28
+ <script>
29
+ import ScrollPane from './ScrollPane'
30
+ import path from 'path'
31
+
32
+ export default {
33
+ components: { ScrollPane },
34
+ data() {
35
+ return {
36
+ visible: false,
37
+ top: 0,
38
+ left: 0,
39
+ selectedTag: {},
40
+ affixTags: []
41
+ }
42
+ },
43
+ computed: {
44
+ visitedViews() {
45
+ return this.$store.state.tagsView.visitedViews
46
+ },
47
+ routes() {
48
+ return this.$store.state.permission.routes
49
+ }
50
+ },
51
+ watch: {
52
+ $route() {
53
+ this.addTags()
54
+ this.moveToCurrentTag()
55
+ },
56
+ visible(value) {
57
+ if (value) {
58
+ document.body.addEventListener('click', this.closeMenu)
59
+ } else {
60
+ document.body.removeEventListener('click', this.closeMenu)
61
+ }
62
+ }
63
+ },
64
+ mounted() {
65
+ this.initTags()
66
+ this.addTags()
67
+ },
68
+ methods: {
69
+ isActive(route) {
70
+ return route.path === this.$route.path
71
+ },
72
+ isAffix(tag) {
73
+ return tag.meta && tag.meta.affix
74
+ },
75
+ filterAffixTags(routes, basePath = '/') {
76
+ let tags = []
77
+ routes.forEach(route => {
78
+ if (route.meta && route.meta.affix) {
79
+ const tagPath = path.resolve(basePath, route.path)
80
+ tags.push({
81
+ fullPath: tagPath,
82
+ path: tagPath,
83
+ name: route.name,
84
+ meta: { ...route.meta }
85
+ })
86
+ }
87
+ if (route.children) {
88
+ const tempTags = this.filterAffixTags(route.children, route.path)
89
+ if (tempTags.length >= 1) {
90
+ tags = [...tags, ...tempTags]
91
+ }
92
+ }
93
+ })
94
+ return tags
95
+ },
96
+ initTags() {
97
+ const affixTags = this.affixTags = this.filterAffixTags(this.routes)
98
+ for (const tag of affixTags) {
99
+ // Must have tag name
100
+ if (tag.name) {
101
+ this.$store.dispatch('tagsView/addVisitedView', tag)
102
+ }
103
+ }
104
+ },
105
+ addTags() {
106
+ const { name } = this.$route
107
+ if (name) {
108
+ this.$store.dispatch('tagsView/addView', this.$route)
109
+ }
110
+ return false
111
+ },
112
+ moveToCurrentTag() {
113
+ const tags = this.$refs.tag
114
+ this.$nextTick(() => {
115
+ for (const tag of tags) {
116
+ if (tag.to.path === this.$route.path) {
117
+ this.$refs.scrollPane.moveToTarget(tag)
118
+ // when query is different then update
119
+ if (tag.to.fullPath !== this.$route.fullPath) {
120
+ this.$store.dispatch('tagsView/updateVisitedView', this.$route)
121
+ }
122
+ break
123
+ }
124
+ }
125
+ })
126
+ },
127
+ refreshSelectedTag(view) {
128
+ this.$store.dispatch('tagsView/delCachedView', view).then(() => {
129
+ const { fullPath } = view
130
+ this.$nextTick(() => {
131
+ this.$router.replace({
132
+ path: '/redirect' + fullPath
133
+ })
134
+ })
135
+ })
136
+ },
137
+ closeSelectedTag(view) {
138
+ this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => {
139
+ if (this.isActive(view)) {
140
+ this.toLastView(visitedViews, view)
141
+ }
142
+ })
143
+ },
144
+ closeOthersTags() {
145
+ this.$router.push(this.selectedTag)
146
+ this.$store.dispatch('tagsView/delOthersViews', this.selectedTag).then(() => {
147
+ this.moveToCurrentTag()
148
+ })
149
+ },
150
+ closeAllTags(view) {
151
+ this.$store.dispatch('tagsView/delAllViews').then(({ visitedViews }) => {
152
+ if (this.affixTags.some(tag => tag.path === view.path)) {
153
+ return
154
+ }
155
+ this.toLastView(visitedViews, view)
156
+ })
157
+ },
158
+ toLastView(visitedViews, view) {
159
+ const latestView = visitedViews.slice(-1)[0]
160
+ if (latestView) {
161
+ this.$router.push(latestView.fullPath)
162
+ } else {
163
+ // now the default is to redirect to the home page if there is no tags-view,
164
+ // you can adjust it according to your needs.
165
+ if (view.name === 'Dashboard') {
166
+ // to reload home page
167
+ this.$router.replace({ path: '/redirect' + view.fullPath })
168
+ } else {
169
+ this.$router.push('/')
170
+ }
171
+ }
172
+ },
173
+ openMenu(tag, e) {
174
+ const menuMinWidth = 105
175
+ const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
176
+ const offsetWidth = this.$el.offsetWidth // container width
177
+ const maxLeft = offsetWidth - menuMinWidth // left boundary
178
+ const left = e.clientX - offsetLeft + 15 // 15: margin right
179
+
180
+ if (left > maxLeft) {
181
+ this.left = maxLeft
182
+ } else {
183
+ this.left = left
184
+ }
185
+
186
+ this.top = e.clientY
187
+ this.visible = true
188
+ this.selectedTag = tag
189
+ },
190
+ closeMenu() {
191
+ this.visible = false
192
+ },
193
+ handleScroll() {
194
+ this.closeMenu()
195
+ }
196
+ }
197
+ }
198
+ </script>
199
+
200
+ <style lang="scss" scoped>
201
+ .tags-view-container {
202
+ height: 34px;
203
+ width: 100%;
204
+ background: #fff;
205
+ border-bottom: 1px solid #d8dce5;
206
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .12), 0 0 3px 0 rgba(0, 0, 0, .04);
207
+ .tags-view-wrapper {
208
+ .tags-view-item {
209
+ display: inline-block;
210
+ position: relative;
211
+ cursor: pointer;
212
+ height: 26px;
213
+ line-height: 26px;
214
+ border: 1px solid #d8dce5;
215
+ color: #495060;
216
+ background: #fff;
217
+ padding: 0 8px;
218
+ font-size: 12px;
219
+ margin-left: 5px;
220
+ margin-top: 4px;
221
+ &:first-of-type {
222
+ margin-left: 15px;
223
+ }
224
+ &:last-of-type {
225
+ margin-right: 15px;
226
+ }
227
+ &.active {
228
+ background-color: #42b983;
229
+ color: #fff;
230
+ border-color: #42b983;
231
+ &::before {
232
+ content: '';
233
+ background: #fff;
234
+ display: inline-block;
235
+ width: 8px;
236
+ height: 8px;
237
+ border-radius: 50%;
238
+ position: relative;
239
+ margin-right: 2px;
240
+ }
241
+ }
242
+ }
243
+ }
244
+ .contextmenu {
245
+ margin: 0;
246
+ background: #fff;
247
+ z-index: 3000;
248
+ position: absolute;
249
+ list-style-type: none;
250
+ padding: 5px 0;
251
+ border-radius: 4px;
252
+ font-size: 12px;
253
+ font-weight: 400;
254
+ color: #333;
255
+ box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, .3);
256
+ li {
257
+ margin: 0;
258
+ padding: 7px 16px;
259
+ cursor: pointer;
260
+ &:hover {
261
+ background: #eee;
262
+ }
263
+ }
264
+ }
265
+ }
266
+ </style>
267
+
268
+ <style lang="scss">
269
+ //reset element css of el-icon-close
270
+ .tags-view-wrapper {
271
+ .tags-view-item {
272
+ .el-icon-close {
273
+ width: 16px;
274
+ height: 16px;
275
+ vertical-align: 2px;
276
+ border-radius: 50%;
277
+ text-align: center;
278
+ transition: all .3s cubic-bezier(.645, .045, .355, 1);
279
+ transform-origin: 100% 50%;
280
+ &:before {
281
+ transform: scale(.6);
282
+ display: inline-block;
283
+ vertical-align: -3px;
284
+ }
285
+ &:hover {
286
+ background-color: #b4bccc;
287
+ color: #fff;
288
+ }
289
+ }
290
+ }
291
+ }
292
+ </style>
@@ -0,0 +1,5 @@
1
+ export { default as AppMain } from './AppMain'
2
+ export { default as Navbar } from './Navbar'
3
+ export { default as Settings } from './Settings'
4
+ export { default as Sidebar } from './Sidebar/index.vue'
5
+ export { default as TagsView } from './TagsView/index.vue'
@@ -0,0 +1,102 @@
1
+ <template>
2
+ <div :class="classObj" class="app-wrapper">
3
+ <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
4
+ <sidebar class="sidebar-container" />
5
+ <div :class="{hasTagsView:needTagsView}" class="main-container">
6
+ <div :class="{'fixed-header':fixedHeader}">
7
+ <navbar />
8
+ <tags-view v-if="needTagsView" />
9
+ </div>
10
+ <app-main />
11
+ <right-panel v-if="showSettings">
12
+ <settings />
13
+ </right-panel>
14
+ </div>
15
+ </div>
16
+ </template>
17
+
18
+ <script>
19
+ import RightPanel from '@/components/RightPanel'
20
+ import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
21
+ import ResizeMixin from './mixin/ResizeHandler'
22
+ import { mapState } from 'vuex'
23
+
24
+ export default {
25
+ name: 'Layout',
26
+ components: {
27
+ AppMain,
28
+ Navbar,
29
+ RightPanel,
30
+ Settings,
31
+ Sidebar,
32
+ TagsView
33
+ },
34
+ mixins: [ResizeMixin],
35
+ computed: {
36
+ ...mapState({
37
+ sidebar: state => state.app.sidebar,
38
+ device: state => state.app.device,
39
+ showSettings: state => state.settings.showSettings,
40
+ needTagsView: state => state.settings.tagsView,
41
+ fixedHeader: state => state.settings.fixedHeader
42
+ }),
43
+ classObj() {
44
+ return {
45
+ hideSidebar: !this.sidebar.opened,
46
+ openSidebar: this.sidebar.opened,
47
+ withoutAnimation: this.sidebar.withoutAnimation,
48
+ mobile: this.device === 'mobile'
49
+ }
50
+ }
51
+ },
52
+ methods: {
53
+ handleClickOutside() {
54
+ this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
55
+ }
56
+ }
57
+ }
58
+ </script>
59
+
60
+ <style lang="scss" scoped>
61
+ @import "~@/styles/mixin.scss";
62
+ @import "~@/styles/variables.scss";
63
+
64
+ .app-wrapper {
65
+ @include clearfix;
66
+ position: relative;
67
+ height: 100%;
68
+ width: 100%;
69
+
70
+ &.mobile.openSidebar {
71
+ position: fixed;
72
+ top: 0;
73
+ }
74
+ }
75
+
76
+ .drawer-bg {
77
+ background: #000;
78
+ opacity: 0.3;
79
+ width: 100%;
80
+ top: 0;
81
+ height: 100%;
82
+ position: absolute;
83
+ z-index: 999;
84
+ }
85
+
86
+ .fixed-header {
87
+ position: fixed;
88
+ top: 0;
89
+ right: 0;
90
+ z-index: 9;
91
+ width: calc(100% - #{$sideBarWidth});
92
+ transition: width 0.28s;
93
+ }
94
+
95
+ .hideSidebar .fixed-header {
96
+ width: calc(100% - 54px)
97
+ }
98
+
99
+ .mobile .fixed-header {
100
+ width: 100%;
101
+ }
102
+ </style>
@@ -0,0 +1,45 @@
1
+ import store from '@/store'
2
+
3
+ const { body } = document
4
+ const WIDTH = 992 // refer to Bootstrap's responsive design
5
+
6
+ export default {
7
+ watch: {
8
+ $route(route) {
9
+ if (this.device === 'mobile' && this.sidebar.opened) {
10
+ store.dispatch('app/closeSideBar', { withoutAnimation: false })
11
+ }
12
+ }
13
+ },
14
+ beforeMount() {
15
+ window.addEventListener('resize', this.$_resizeHandler)
16
+ },
17
+ beforeDestroy() {
18
+ window.removeEventListener('resize', this.$_resizeHandler)
19
+ },
20
+ mounted() {
21
+ const isMobile = this.$_isMobile()
22
+ if (isMobile) {
23
+ store.dispatch('app/toggleDevice', 'mobile')
24
+ store.dispatch('app/closeSideBar', { withoutAnimation: true })
25
+ }
26
+ },
27
+ methods: {
28
+ // use $_ for mixins properties
29
+ // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
30
+ $_isMobile() {
31
+ const rect = body.getBoundingClientRect()
32
+ return rect.width - 1 < WIDTH
33
+ },
34
+ $_resizeHandler() {
35
+ if (!document.hidden) {
36
+ const isMobile = this.$_isMobile()
37
+ store.dispatch('app/toggleDevice', isMobile ? 'mobile' : 'desktop')
38
+
39
+ if (isMobile) {
40
+ store.dispatch('app/closeSideBar', { withoutAnimation: true })
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }