From 0525c389e8365ece47a09146d0bf879a6c8c8800 Mon Sep 17 00:00:00 2001 From: KUN1007 Date: Sat, 11 Nov 2023 20:52:47 +0800 Subject: [PATCH] rebuild: rebuild store --- src/api/topic/types/aside.ts | 2 + src/components/KUNGalgameFooter.vue | 2 +- .../milkdown/MilkdownEditorWrapper.vue | 31 +- .../components/EditorSettingsMenu.vue | 32 +- .../milkdown/components/Settings.vue | 4 +- .../milkdown/components/SwitchButton.vue | 24 +- src/components/milkdown/plugins/Size.vue | 10 +- .../skeleton/home/HomeTopicSkeleton.vue | 8 +- src/store/index.ts | 7 +- src/store/modules/kungalgamer.ts | 1 - src/store/modules/topic.ts | 339 ------------------ src/store/modules/topic/reply.ts | 91 +++++ src/store/modules/topic/topic.ts | 13 + src/store/temp/comment.ts | 20 -- src/store/temp/home.ts | 0 src/store/temp/reply.ts | 40 --- src/store/temp/replyRewrite.ts | 13 - src/store/temp/topic/comment.ts | 89 +++++ src/store/temp/topic/reply.ts | 131 +++++++ src/store/temp/topic/topic.ts | 89 +++++ src/store/types/topic.d.ts | 73 ---- src/store/types/topic/comment.d.ts | 10 + src/store/types/topic/reply.d.ts | 61 ++++ src/store/types/topic/topic.d.ts | 8 + .../article/components/ArticleContent.vue | 2 +- src/views/edit/components/Tags.vue | 48 ++- src/views/topic/KUNGalgameTopicPage.vue | 59 ++- src/views/topic/aside/Aside.vue | 12 +- .../topic/aside/components/AsideActive.vue | 10 +- .../topic/aside/components/AsideBase.vue | 15 +- .../topic/aside/components/TopicAsideNav.vue | 11 +- .../topic/aside/components/TopicMaster.vue | 9 +- .../topic/aside/components/TopicOtherTag.vue | 10 +- src/views/topic/components/Content.vue | 9 +- src/views/topic/components/Master.vue | 2 +- .../topic/components/comment/CommentPanel.vue | 5 +- .../topic/components/comment/Comments.vue | 12 +- .../topic/components/comment/Dislike.vue | 13 +- src/views/topic/components/comment/Like.vue | 10 +- src/views/topic/components/footer/Dislike.vue | 29 +- src/views/topic/components/footer/Footer.vue | 21 +- src/views/topic/components/footer/Like.vue | 32 +- src/views/topic/components/footer/Reply.vue | 21 +- src/views/topic/components/footer/Rewrite.vue | 30 +- src/views/topic/components/footer/Upvote.vue | 32 +- src/views/topic/components/reply/Reply.vue | 10 +- .../topic/components/reply/ReplyPanel.vue | 33 +- .../topic/components/reply/ReplyPanelBtn.vue | 61 ++-- 48 files changed, 752 insertions(+), 842 deletions(-) delete mode 100644 src/store/modules/topic.ts create mode 100644 src/store/modules/topic/reply.ts create mode 100644 src/store/modules/topic/topic.ts delete mode 100644 src/store/temp/comment.ts create mode 100644 src/store/temp/home.ts delete mode 100644 src/store/temp/reply.ts delete mode 100644 src/store/temp/replyRewrite.ts create mode 100644 src/store/temp/topic/comment.ts create mode 100644 src/store/temp/topic/reply.ts create mode 100644 src/store/temp/topic/topic.ts delete mode 100644 src/store/types/topic.d.ts create mode 100644 src/store/types/topic/comment.d.ts create mode 100644 src/store/types/topic/reply.d.ts create mode 100644 src/store/types/topic/topic.d.ts diff --git a/src/api/topic/types/aside.ts b/src/api/topic/types/aside.ts index b69bf5b9..2fbb726a 100644 --- a/src/api/topic/types/aside.ts +++ b/src/api/topic/types/aside.ts @@ -13,6 +13,8 @@ export interface TopicAsideOtherTagRequestData { } export interface TopicAsideMasterRequestData { + // User uid + uid: number // The tid of the current topic, as other topics under the same tag should not include the current one tid: string } diff --git a/src/components/KUNGalgameFooter.vue b/src/components/KUNGalgameFooter.vue index 9e89822a..f93a1a9e 100644 --- a/src/components/KUNGalgameFooter.vue +++ b/src/components/KUNGalgameFooter.vue @@ -3,7 +3,7 @@ diff --git a/src/components/milkdown/MilkdownEditorWrapper.vue b/src/components/milkdown/MilkdownEditorWrapper.vue index 123b75cb..cbd10bad 100644 --- a/src/components/milkdown/MilkdownEditorWrapper.vue +++ b/src/components/milkdown/MilkdownEditorWrapper.vue @@ -9,13 +9,22 @@ import MilkdownEditor from './MilkdownEditor.vue' // KUN Visual Novel store import { useKUNGalgameEditStore } from '@/store/modules/edit' -import { useKUNGalgameTopicStore } from '@/store/modules/topic' +import { usePersistKUNGalgameReplyStore } from '@/store/modules/topic/reply' import { storeToRefs } from 'pinia' -const { editorHeight, isSaveTopic, content, topicRewrite } = storeToRefs( - useKUNGalgameEditStore() -) -const { replyDraft, replyRewrite } = storeToRefs(useKUNGalgameTopicStore()) +const { + editorHeight: editEditorHeight, + isSaveTopic, + content, + topicRewrite, +} = storeToRefs(useKUNGalgameEditStore()) +const { + editorHeight: replyEditorHeight, + isSaveReply, + isReplyRewriting, + replyDraft, + replyRewrite, +} = storeToRefs(usePersistKUNGalgameReplyStore()) const props = defineProps<{ isShowMenu: boolean @@ -29,9 +38,7 @@ const valueMarkdown = ref('') // Editor height, determined by the route name const editorHeightStyle = computed(() => - routeName.value === 'Edit' - ? editorHeight.value - : replyDraft.value.editorHeight + routeName.value === 'Edit' ? editEditorHeight.value : replyEditorHeight.value ) onBeforeMount(() => { @@ -53,13 +60,13 @@ onBeforeMount(() => { * Editor is in the reply mode */ // Load reply data before mounting if not saved (and must be on the Topic page) - if (replyDraft.value.isSaveReply && routeName.value === 'Topic') { + if (isSaveReply.value && routeName.value === 'Topic') { valueMarkdown.value = replyDraft.value.content } /** * Editor is in the re-editing reply mode */ - if (replyRewrite.value.isReplyRewriting && routeName.value === 'Topic') { + if (isReplyRewriting.value && routeName.value === 'Topic') { valueMarkdown.value = replyRewrite.value.content } }) @@ -85,13 +92,13 @@ const saveMarkdown = (editorMarkdown: string) => { * Editor is in reply mode */ // Save to the reply store if not in reply re-edit mode - if (!replyRewrite.value.isReplyRewriting && routeName.value === 'Topic') { + if (!isReplyRewriting.value && routeName.value === 'Topic') { replyDraft.value.content = editorMarkdown } /** * Editor is in re-editing reply mode */ - if (replyRewrite.value.isReplyRewriting && routeName.value === 'Topic') { + if (isReplyRewriting.value && routeName.value === 'Topic') { replyRewrite.value.content = editorMarkdown } }, 1007) diff --git a/src/components/milkdown/components/EditorSettingsMenu.vue b/src/components/milkdown/components/EditorSettingsMenu.vue index cc2b996a..23b1fe72 100644 --- a/src/components/milkdown/components/EditorSettingsMenu.vue +++ b/src/components/milkdown/components/EditorSettingsMenu.vue @@ -1,40 +1,36 @@ @@ -35,13 +38,14 @@ watch( v-if="routeName === 'Edit'" type="checkbox" id="switch" - v-model="isShowHotKeywords" + v-model="isShowEditHotKeywords" /> + diff --git a/src/components/milkdown/plugins/Size.vue b/src/components/milkdown/plugins/Size.vue index 2738935b..eecbe46b 100644 --- a/src/components/milkdown/plugins/Size.vue +++ b/src/components/milkdown/plugins/Size.vue @@ -7,11 +7,11 @@ import Settings from '../components/Settings.vue' import { usePluginViewContext } from '@prosemirror-adapter/vue' import { useKUNGalgameEditStore } from '@/store/modules/edit' -import { useKUNGalgameTopicStore } from '@/store/modules/topic' +import { useTempReplyStore } from '@/store/temp/topic/reply' import { storeToRefs } from 'pinia' -const { textCount } = storeToRefs(useKUNGalgameEditStore()) -const { replyDraft } = storeToRefs(useKUNGalgameTopicStore()) +const { textCount: textCountEdit } = storeToRefs(useKUNGalgameEditStore()) +const { textCount: textCountReply } = storeToRefs(useTempReplyStore()) const { view } = usePluginViewContext() @@ -26,10 +26,10 @@ watch( () => size.value, () => { if (routeName.value === 'Edit') { - textCount.value = size.value + textCountEdit.value = size.value } if (routeName.value === 'Topic') { - replyDraft.value.textCount = size.value + textCountReply.value = size.value } } ) diff --git a/src/components/skeleton/home/HomeTopicSkeleton.vue b/src/components/skeleton/home/HomeTopicSkeleton.vue index 0cd1f6a7..a7c7809d 100644 --- a/src/components/skeleton/home/HomeTopicSkeleton.vue +++ b/src/components/skeleton/home/HomeTopicSkeleton.vue @@ -1,5 +1,11 @@