From 760fffd605d72c468a05e4853dd76b690aac29a3 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Tue, 16 Nov 2021 22:25:52 +0800 Subject: [PATCH] refactor: post setting (#376) * refactor: post setting modal * refactor: pagination * refactor: post setting modal * fix: TagSelect * feat: add draft button * feat: add meta editor * style: remove PostSettingDrawer.vue --- src/components/Post/MetaEditor.vue | 151 +++++ src/filters/filter.js | 8 - src/views/post/PostEdit.vue | 51 +- src/views/post/PostList.vue | 478 ++++++++------- src/views/post/components/CategoryTree.vue | 45 +- .../post/components/PostSettingDrawer.vue | 567 ------------------ .../post/components/PostSettingModal.vue | 394 ++++++++++++ src/views/post/components/TagSelect.vue | 36 +- 8 files changed, 875 insertions(+), 855 deletions(-) create mode 100644 src/components/Post/MetaEditor.vue delete mode 100644 src/views/post/components/PostSettingDrawer.vue create mode 100644 src/views/post/components/PostSettingModal.vue diff --git a/src/components/Post/MetaEditor.vue b/src/components/Post/MetaEditor.vue new file mode 100644 index 00000000..5a8d70b5 --- /dev/null +++ b/src/components/Post/MetaEditor.vue @@ -0,0 +1,151 @@ + + diff --git a/src/filters/filter.js b/src/filters/filter.js index f734772e..d537b9b0 100644 --- a/src/filters/filter.js +++ b/src/filters/filter.js @@ -7,14 +7,6 @@ import { timeAgo } from '@/utils/datetime' dayjs.locale('zh-cn') -Vue.filter('NumberFormat', function(value) { - if (!value) { - return '0' - } - // 将整数部分逢三一断 - return value.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') -}) - Vue.filter('moment', function(dataStr, pattern = 'YYYY-MM-DD HH:mm') { return dayjs(dataStr).format(pattern) }) diff --git a/src/views/post/PostEdit.vue b/src/views/post/PostEdit.vue index ef71002e..cf9bd5f8 100644 --- a/src/views/post/PostEdit.vue +++ b/src/views/post/PostEdit.vue @@ -32,18 +32,11 @@ - @@ -54,7 +47,7 @@ import { mixin, mixinDevice, mixinPostEdit } from '@/mixins/mixin.js' import { datetimeFormat } from '@/utils/datetime' -import PostSettingDrawer from './components/PostSettingDrawer' +import PostSettingModal from './components/PostSettingModal' import AttachmentDrawer from '../attachment/components/AttachmentDrawer' import MarkdownEditor from '@/components/Editor/MarkdownEditor' import { PageView } from '@/layouts' @@ -64,7 +57,7 @@ import postApi from '@/api/post' export default { mixins: [mixin, mixinDevice, mixinPostEdit], components: { - PostSettingDrawer, + PostSettingModal, AttachmentDrawer, MarkdownEditor, PageView @@ -74,9 +67,6 @@ export default { attachmentDrawerVisible: false, postSettingVisible: false, postToStage: {}, - selectedTagIds: [], - selectedCategoryIds: [], - selectedMetas: [], contentChanges: 0, draftSaving: false, previewSaving: false, @@ -89,19 +79,12 @@ export default { next(vm => { if (postId) { postApi.get(postId).then(response => { - const post = response.data.data - vm.postToStage = post - vm.selectedTagIds = post.tagIds - vm.selectedCategoryIds = post.categoryIds - vm.selectedMetas = post.metas + vm.postToStage = response.data.data }) } }) }, - destroyed: function() { - if (this.postSettingVisible) { - this.postSettingVisible = false - } + destroyed() { if (this.attachmentDrawerVisible) { this.attachmentDrawerVisible = false } @@ -110,9 +93,6 @@ export default { } }, beforeRouteLeave(to, from, next) { - if (this.postSettingVisible) { - this.postSettingVisible = false - } if (this.attachmentDrawerVisible) { this.attachmentDrawerVisible = false } @@ -247,17 +227,12 @@ export default { this.contentChanges++ this.postToStage.originalContent = val }, - onRefreshPostFromSetting(post) { - this.postToStage = post - }, - onRefreshTagIdsFromSetting(tagIds) { - this.selectedTagIds = tagIds - }, - onRefreshCategoryIdsFromSetting(categoryIds) { - this.selectedCategoryIds = categoryIds + onPostSavedCallback() { + this.contentChanges = 0 + this.$router.push({ name: 'PostList' }) }, - onRefreshPostMetasFromSetting(metas) { - this.selectedMetas = metas + onUpdateFromSetting(post) { + this.postToStage = post } } } diff --git a/src/views/post/PostList.vue b/src/views/post/PostList.vue index 27df5a1c..9677ea8e 100644 --- a/src/views/post/PostList.vue +++ b/src/views/post/PostList.vue @@ -1,35 +1,35 @@