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,289 @@
1
+ <template>
2
+ <div class="createPost-container">
3
+ <el-form ref="postForm" :model="postForm" :rules="rules" class="form-container">
4
+
5
+ <sticky :z-index="10" :class-name="'sub-navbar '+postForm.status">
6
+ <CommentDropdown v-model="postForm.comment_disabled" />
7
+ <PlatformDropdown v-model="postForm.platforms" />
8
+ <SourceUrlDropdown v-model="postForm.source_uri" />
9
+ <el-button v-loading="loading" style="margin-left: 10px;" type="success" @click="submitForm">
10
+ Publish
11
+ </el-button>
12
+ <el-button v-loading="loading" type="warning" @click="draftForm">
13
+ Draft
14
+ </el-button>
15
+ </sticky>
16
+
17
+ <div class="createPost-main-container">
18
+ <el-row>
19
+ <Warning />
20
+
21
+ <el-col :span="24">
22
+ <el-form-item style="margin-bottom: 40px;" prop="title">
23
+ <MDinput v-model="postForm.title" :maxlength="100" name="name" required>
24
+ Title
25
+ </MDinput>
26
+ </el-form-item>
27
+
28
+ <div class="postInfo-container">
29
+ <el-row>
30
+ <el-col :span="8">
31
+ <el-form-item label-width="60px" label="Author:" class="postInfo-container-item">
32
+ <el-select v-model="postForm.author" :remote-method="getRemoteUserList" filterable default-first-option remote placeholder="Search user">
33
+ <el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item" :value="item" />
34
+ </el-select>
35
+ </el-form-item>
36
+ </el-col>
37
+
38
+ <el-col :span="10">
39
+ <el-form-item label-width="120px" label="Publish Time:" class="postInfo-container-item">
40
+ <el-date-picker v-model="displayTime" type="datetime" format="yyyy-MM-dd HH:mm:ss" placeholder="Select date and time" />
41
+ </el-form-item>
42
+ </el-col>
43
+
44
+ <el-col :span="6">
45
+ <el-form-item label-width="90px" label="Importance:" class="postInfo-container-item">
46
+ <el-rate
47
+ v-model="postForm.importance"
48
+ :max="3"
49
+ :colors="['#99A9BF', '#F7BA2A', '#FF9900']"
50
+ :low-threshold="1"
51
+ :high-threshold="3"
52
+ style="display:inline-block"
53
+ />
54
+ </el-form-item>
55
+ </el-col>
56
+ </el-row>
57
+ </div>
58
+ </el-col>
59
+ </el-row>
60
+
61
+ <el-form-item style="margin-bottom: 40px;" label-width="70px" label="Summary:">
62
+ <el-input v-model="postForm.content_short" :rows="1" type="textarea" class="article-textarea" autosize placeholder="Please enter the content" />
63
+ <span v-show="contentShortLength" class="word-counter">{{ contentShortLength }}words</span>
64
+ </el-form-item>
65
+
66
+ <el-form-item prop="content" style="margin-bottom: 30px;">
67
+ <Tinymce ref="editor" v-model="postForm.content" :height="400" />
68
+ </el-form-item>
69
+
70
+ <el-form-item prop="image_uri" style="margin-bottom: 30px;">
71
+ <Upload v-model="postForm.image_uri" />
72
+ </el-form-item>
73
+ </div>
74
+ </el-form>
75
+ </div>
76
+ </template>
77
+
78
+ <script>
79
+ import Tinymce from '@/components/Tinymce'
80
+ import Upload from '@/components/Upload/SingleImage3'
81
+ import MDinput from '@/components/MDinput'
82
+ import Sticky from '@/components/Sticky' // 粘性header组件
83
+ import { validURL } from '@/utils/validate'
84
+ import { fetchArticle } from '@/api/article'
85
+ import { searchUser } from '@/api/remote-search'
86
+ import Warning from './Warning'
87
+ import { CommentDropdown, PlatformDropdown, SourceUrlDropdown } from './Dropdown'
88
+
89
+ const defaultForm = {
90
+ status: 'draft',
91
+ title: '', // 文章题目
92
+ content: '', // 文章内容
93
+ content_short: '', // 文章摘要
94
+ source_uri: '', // 文章外链
95
+ image_uri: '', // 文章图片
96
+ display_time: undefined, // 前台展示时间
97
+ id: undefined,
98
+ platforms: ['a-platform'],
99
+ comment_disabled: false,
100
+ importance: 0
101
+ }
102
+
103
+ export default {
104
+ name: 'ArticleDetail',
105
+ components: { Tinymce, MDinput, Upload, Sticky, Warning, CommentDropdown, PlatformDropdown, SourceUrlDropdown },
106
+ props: {
107
+ isEdit: {
108
+ type: Boolean,
109
+ default: false
110
+ }
111
+ },
112
+ data() {
113
+ const validateRequire = (rule, value, callback) => {
114
+ if (value === '') {
115
+ this.$message({
116
+ message: rule.field + '为必传项',
117
+ type: 'error'
118
+ })
119
+ callback(new Error(rule.field + '为必传项'))
120
+ } else {
121
+ callback()
122
+ }
123
+ }
124
+ const validateSourceUri = (rule, value, callback) => {
125
+ if (value) {
126
+ if (validURL(value)) {
127
+ callback()
128
+ } else {
129
+ this.$message({
130
+ message: '外链url填写不正确',
131
+ type: 'error'
132
+ })
133
+ callback(new Error('外链url填写不正确'))
134
+ }
135
+ } else {
136
+ callback()
137
+ }
138
+ }
139
+ return {
140
+ postForm: Object.assign({}, defaultForm),
141
+ loading: false,
142
+ userListOptions: [],
143
+ rules: {
144
+ image_uri: [{ validator: validateRequire }],
145
+ title: [{ validator: validateRequire }],
146
+ content: [{ validator: validateRequire }],
147
+ source_uri: [{ validator: validateSourceUri, trigger: 'blur' }]
148
+ },
149
+ tempRoute: {}
150
+ }
151
+ },
152
+ computed: {
153
+ contentShortLength() {
154
+ return this.postForm.content_short.length
155
+ },
156
+ displayTime: {
157
+ // set and get is useful when the data
158
+ // returned by the back end api is different from the front end
159
+ // back end return => "2013-06-25 06:59:25"
160
+ // front end need timestamp => 1372114765000
161
+ get() {
162
+ return (+new Date(this.postForm.display_time))
163
+ },
164
+ set(val) {
165
+ this.postForm.display_time = new Date(val)
166
+ }
167
+ }
168
+ },
169
+ created() {
170
+ if (this.isEdit) {
171
+ const id = this.$route.params && this.$route.params.id
172
+ this.fetchData(id)
173
+ }
174
+
175
+ // Why need to make a copy of this.$route here?
176
+ // Because if you enter this page and quickly switch tag, may be in the execution of the setTagsViewTitle function, this.$route is no longer pointing to the current page
177
+ // https://github.com/PanJiaChen/vue-element-admin/issues/1221
178
+ this.tempRoute = Object.assign({}, this.$route)
179
+ },
180
+ methods: {
181
+ fetchData(id) {
182
+ fetchArticle(id).then(response => {
183
+ this.postForm = response.data
184
+
185
+ // just for test
186
+ this.postForm.title += ` Article Id:${this.postForm.id}`
187
+ this.postForm.content_short += ` Article Id:${this.postForm.id}`
188
+
189
+ // set tagsview title
190
+ this.setTagsViewTitle()
191
+
192
+ // set page title
193
+ this.setPageTitle()
194
+ }).catch(err => {
195
+ console.log(err)
196
+ })
197
+ },
198
+ setTagsViewTitle() {
199
+ const title = 'Edit Article'
200
+ const route = Object.assign({}, this.tempRoute, { title: `${title}-${this.postForm.id}` })
201
+ this.$store.dispatch('tagsView/updateVisitedView', route)
202
+ },
203
+ setPageTitle() {
204
+ const title = 'Edit Article'
205
+ document.title = `${title} - ${this.postForm.id}`
206
+ },
207
+ submitForm() {
208
+ console.log(this.postForm)
209
+ this.$refs.postForm.validate(valid => {
210
+ if (valid) {
211
+ this.loading = true
212
+ this.$notify({
213
+ title: '成功',
214
+ message: '发布文章成功',
215
+ type: 'success',
216
+ duration: 2000
217
+ })
218
+ this.postForm.status = 'published'
219
+ this.loading = false
220
+ } else {
221
+ console.log('error submit!!')
222
+ return false
223
+ }
224
+ })
225
+ },
226
+ draftForm() {
227
+ if (this.postForm.content.length === 0 || this.postForm.title.length === 0) {
228
+ this.$message({
229
+ message: '请填写必要的标题和内容',
230
+ type: 'warning'
231
+ })
232
+ return
233
+ }
234
+ this.$message({
235
+ message: '保存成功',
236
+ type: 'success',
237
+ showClose: true,
238
+ duration: 1000
239
+ })
240
+ this.postForm.status = 'draft'
241
+ },
242
+ getRemoteUserList(query) {
243
+ searchUser(query).then(response => {
244
+ if (!response.data.items) return
245
+ this.userListOptions = response.data.items.map(v => v.name)
246
+ })
247
+ }
248
+ }
249
+ }
250
+ </script>
251
+
252
+ <style lang="scss" scoped>
253
+ @import "~@/styles/mixin.scss";
254
+
255
+ .createPost-container {
256
+ position: relative;
257
+
258
+ .createPost-main-container {
259
+ padding: 40px 45px 20px 50px;
260
+
261
+ .postInfo-container {
262
+ position: relative;
263
+ @include clearfix;
264
+ margin-bottom: 10px;
265
+
266
+ .postInfo-container-item {
267
+ float: left;
268
+ }
269
+ }
270
+ }
271
+
272
+ .word-counter {
273
+ width: 40px;
274
+ position: absolute;
275
+ right: 10px;
276
+ top: 0px;
277
+ }
278
+ }
279
+
280
+ .article-textarea ::v-deep {
281
+ textarea {
282
+ padding-right: 40px;
283
+ resize: none;
284
+ border: none;
285
+ border-radius: 0px;
286
+ border-bottom: 1px solid #bfcbd9;
287
+ }
288
+ }
289
+ </style>
@@ -0,0 +1,41 @@
1
+ <template>
2
+ <el-dropdown :show-timeout="100" trigger="click">
3
+ <el-button plain>
4
+ {{ !comment_disabled?'Comment: opened':'Comment: closed' }}
5
+ <i class="el-icon-caret-bottom el-icon--right" />
6
+ </el-button>
7
+ <el-dropdown-menu slot="dropdown" class="no-padding">
8
+ <el-dropdown-item>
9
+ <el-radio-group v-model="comment_disabled" style="padding: 10px;">
10
+ <el-radio :label="true">
11
+ Close comment
12
+ </el-radio>
13
+ <el-radio :label="false">
14
+ Open comment
15
+ </el-radio>
16
+ </el-radio-group>
17
+ </el-dropdown-item>
18
+ </el-dropdown-menu>
19
+ </el-dropdown>
20
+ </template>
21
+
22
+ <script>
23
+ export default {
24
+ props: {
25
+ value: {
26
+ type: Boolean,
27
+ default: false
28
+ }
29
+ },
30
+ computed: {
31
+ comment_disabled: {
32
+ get() {
33
+ return this.value
34
+ },
35
+ set(val) {
36
+ this.$emit('input', val)
37
+ }
38
+ }
39
+ }
40
+ }
41
+ </script>
@@ -0,0 +1,46 @@
1
+ <template>
2
+ <el-dropdown :hide-on-click="false" :show-timeout="100" trigger="click">
3
+ <el-button plain>
4
+ Platfroms({{ platforms.length }})
5
+ <i class="el-icon-caret-bottom el-icon--right" />
6
+ </el-button>
7
+ <el-dropdown-menu slot="dropdown" class="no-border">
8
+ <el-checkbox-group v-model="platforms" style="padding: 5px 15px;">
9
+ <el-checkbox v-for="item in platformsOptions" :key="item.key" :label="item.key">
10
+ {{ item.name }}
11
+ </el-checkbox>
12
+ </el-checkbox-group>
13
+ </el-dropdown-menu>
14
+ </el-dropdown>
15
+ </template>
16
+
17
+ <script>
18
+ export default {
19
+ props: {
20
+ value: {
21
+ required: true,
22
+ default: () => [],
23
+ type: Array
24
+ }
25
+ },
26
+ data() {
27
+ return {
28
+ platformsOptions: [
29
+ { key: 'a-platform', name: 'a-platform' },
30
+ { key: 'b-platform', name: 'b-platform' },
31
+ { key: 'c-platform', name: 'c-platform' }
32
+ ]
33
+ }
34
+ },
35
+ computed: {
36
+ platforms: {
37
+ get() {
38
+ return this.value
39
+ },
40
+ set(val) {
41
+ this.$emit('input', val)
42
+ }
43
+ }
44
+ }
45
+ }
46
+ </script>
@@ -0,0 +1,38 @@
1
+ <template>
2
+ <el-dropdown :show-timeout="100" trigger="click">
3
+ <el-button plain>
4
+ Link
5
+ <i class="el-icon-caret-bottom el-icon--right" />
6
+ </el-button>
7
+ <el-dropdown-menu slot="dropdown" class="no-padding no-border" style="width:400px">
8
+ <el-form-item label-width="0px" style="margin-bottom: 0px" prop="source_uri">
9
+ <el-input v-model="source_uri" placeholder="Please enter the content">
10
+ <template slot="prepend">
11
+ URL
12
+ </template>
13
+ </el-input>
14
+ </el-form-item>
15
+ </el-dropdown-menu>
16
+ </el-dropdown>
17
+ </template>
18
+
19
+ <script>
20
+ export default {
21
+ props: {
22
+ value: {
23
+ type: String,
24
+ default: ''
25
+ }
26
+ },
27
+ computed: {
28
+ source_uri: {
29
+ get() {
30
+ return this.value
31
+ },
32
+ set(val) {
33
+ this.$emit('input', val)
34
+ }
35
+ }
36
+ }
37
+ }
38
+ </script>
@@ -0,0 +1,3 @@
1
+ export { default as CommentDropdown } from './Comment'
2
+ export { default as PlatformDropdown } from './Platform'
3
+ export { default as SourceUrlDropdown } from './SourceUrl'
@@ -0,0 +1,13 @@
1
+ <template>
2
+ <aside>
3
+ Creating and editing pages cannot be cached by keep-alive because keep-alive include does not currently support
4
+ caching based on routes, so it is currently cached based on component name. If you want to achieve a similar caching
5
+ effect, you can use a browser caching scheme such as localStorage. Or do not use keep-alive include to cache all
6
+ pages directly. See details
7
+ <a
8
+ href="https://panjiachen.github.io/vue-element-admin-site/guide/essentials/tags-view.html"
9
+ target="_blank"
10
+ >Document</a>
11
+ </aside>
12
+ </template>
13
+
@@ -0,0 +1,13 @@
1
+ <template>
2
+ <article-detail :is-edit="false" />
3
+ </template>
4
+
5
+ <script>
6
+ import ArticleDetail from './components/ArticleDetail'
7
+
8
+ export default {
9
+ name: 'CreateArticle',
10
+ components: { ArticleDetail }
11
+ }
12
+ </script>
13
+
@@ -0,0 +1,13 @@
1
+ <template>
2
+ <article-detail :is-edit="true" />
3
+ </template>
4
+
5
+ <script>
6
+ import ArticleDetail from './components/ArticleDetail'
7
+
8
+ export default {
9
+ name: 'EditForm',
10
+ components: { ArticleDetail }
11
+ }
12
+ </script>
13
+
@@ -0,0 +1,112 @@
1
+ <template>
2
+ <div class="app-container">
3
+ <el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%">
4
+ <el-table-column align="center" label="ID" width="80">
5
+ <template slot-scope="scope">
6
+ <span>{{ scope.row.id }}</span>
7
+ </template>
8
+ </el-table-column>
9
+
10
+ <el-table-column width="180px" align="center" label="Date">
11
+ <template slot-scope="scope">
12
+ <span>{{ scope.row.timestamp | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
13
+ </template>
14
+ </el-table-column>
15
+
16
+ <el-table-column width="120px" align="center" label="Author">
17
+ <template slot-scope="scope">
18
+ <span>{{ scope.row.author }}</span>
19
+ </template>
20
+ </el-table-column>
21
+
22
+ <el-table-column width="100px" label="Importance">
23
+ <template slot-scope="scope">
24
+ <svg-icon v-for="n in +scope.row.importance" :key="n" icon-class="star" class="meta-item__icon" />
25
+ </template>
26
+ </el-table-column>
27
+
28
+ <el-table-column class-name="status-col" label="Status" width="110">
29
+ <template slot-scope="{row}">
30
+ <el-tag :type="row.status | statusFilter">
31
+ {{ row.status }}
32
+ </el-tag>
33
+ </template>
34
+ </el-table-column>
35
+
36
+ <el-table-column min-width="300px" label="Title">
37
+ <template slot-scope="{row}">
38
+ <router-link :to="'/example/edit/'+row.id" class="link-type">
39
+ <span>{{ row.title }}</span>
40
+ </router-link>
41
+ </template>
42
+ </el-table-column>
43
+
44
+ <el-table-column align="center" label="Actions" width="120">
45
+ <template slot-scope="scope">
46
+ <router-link :to="'/example/edit/'+scope.row.id">
47
+ <el-button type="primary" size="small" icon="el-icon-edit">
48
+ Edit
49
+ </el-button>
50
+ </router-link>
51
+ </template>
52
+ </el-table-column>
53
+ </el-table>
54
+
55
+ <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
56
+ </div>
57
+ </template>
58
+
59
+ <script>
60
+ import { fetchList } from '@/api/article'
61
+ import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
62
+
63
+ export default {
64
+ name: 'ArticleList',
65
+ components: { Pagination },
66
+ filters: {
67
+ statusFilter(status) {
68
+ const statusMap = {
69
+ published: 'success',
70
+ draft: 'info',
71
+ deleted: 'danger'
72
+ }
73
+ return statusMap[status]
74
+ }
75
+ },
76
+ data() {
77
+ return {
78
+ list: null,
79
+ total: 0,
80
+ listLoading: true,
81
+ listQuery: {
82
+ page: 1,
83
+ limit: 20
84
+ }
85
+ }
86
+ },
87
+ created() {
88
+ this.getList()
89
+ },
90
+ methods: {
91
+ getList() {
92
+ this.listLoading = true
93
+ fetchList(this.listQuery).then(response => {
94
+ this.list = response.data.items
95
+ this.total = response.data.total
96
+ this.listLoading = false
97
+ })
98
+ }
99
+ }
100
+ }
101
+ </script>
102
+
103
+ <style scoped>
104
+ .edit-input {
105
+ padding-right: 100px;
106
+ }
107
+ .cancel-btn {
108
+ position: absolute;
109
+ right: 15px;
110
+ top: 10px;
111
+ }
112
+ </style>
@@ -0,0 +1,34 @@
1
+ <template>
2
+ <div style="display:inline-block;">
3
+ <label class="radio-label">Cell Auto-Width: </label>
4
+ <el-radio-group v-model="autoWidth">
5
+ <el-radio :label="true" border>
6
+ True
7
+ </el-radio>
8
+ <el-radio :label="false" border>
9
+ False
10
+ </el-radio>
11
+ </el-radio-group>
12
+ </div>
13
+ </template>
14
+
15
+ <script>
16
+ export default {
17
+ props: {
18
+ value: {
19
+ type: Boolean,
20
+ default: true
21
+ }
22
+ },
23
+ computed: {
24
+ autoWidth: {
25
+ get() {
26
+ return this.value
27
+ },
28
+ set(val) {
29
+ this.$emit('input', val)
30
+ }
31
+ }
32
+ }
33
+ }
34
+ </script>
@@ -0,0 +1,39 @@
1
+ <template>
2
+ <div style="display:inline-block;">
3
+ <label class="radio-label">Book Type: </label>
4
+ <el-select v-model="bookType" style="width:120px;">
5
+ <el-option
6
+ v-for="item in options"
7
+ :key="item"
8
+ :label="item"
9
+ :value="item"
10
+ />
11
+ </el-select>
12
+ </div>
13
+ </template>
14
+
15
+ <script>
16
+ export default {
17
+ props: {
18
+ value: {
19
+ type: String,
20
+ default: 'xlsx'
21
+ }
22
+ },
23
+ data() {
24
+ return {
25
+ options: ['xlsx', 'csv', 'txt']
26
+ }
27
+ },
28
+ computed: {
29
+ bookType: {
30
+ get() {
31
+ return this.value
32
+ },
33
+ set(val) {
34
+ this.$emit('input', val)
35
+ }
36
+ }
37
+ }
38
+ }
39
+ </script>
@@ -0,0 +1,27 @@
1
+ <template>
2
+ <div style="display:inline-block;">
3
+ <label class="radio-label" style="padding-left:0;">Filename: </label>
4
+ <el-input v-model="filename" placeholder="Please enter the file name (default excel-list)" style="width:345px;" prefix-icon="el-icon-document" />
5
+ </div>
6
+ </template>
7
+
8
+ <script>
9
+ export default {
10
+ props: {
11
+ value: {
12
+ type: String,
13
+ default: ''
14
+ }
15
+ },
16
+ computed: {
17
+ filename: {
18
+ get() {
19
+ return this.value
20
+ },
21
+ set(val) {
22
+ this.$emit('input', val)
23
+ }
24
+ }
25
+ }
26
+ }
27
+ </script>