From 55da1897ae6dc11759c01e59ba3ce18c20c8f892 Mon Sep 17 00:00:00 2001 From: Lhcfl Date: Wed, 22 May 2024 23:47:53 +0800 Subject: [PATCH] refactor: split MkNote into smaller components --- packages/client/src/components/MkNote.vue | 672 ++---------------- .../client/src/components/MkNoteDetailed.vue | 10 +- .../client/src/components/MkNoteSimple.vue | 6 +- packages/client/src/components/MkNoteSub.vue | 334 +-------- .../client/src/components/global/MkError.vue | 6 +- .../MkNoteContent.vue} | 5 +- .../src/components/note/MkNoteFooter.vue | 290 ++++++++ .../src/components/note/MkNoteFooterInfo.vue | 44 ++ .../components/{ => note}/MkNoteHeader.vue | 0 .../src/components/note/MkNoteHeaderInfo.vue | 71 ++ .../src/components/{ => note}/MkNoteMedia.vue | 0 .../components/{ => note}/MkNoteMediaList.vue | 2 +- .../src/components/note/MkNoteTranslation.vue | 110 +++ .../src/components/note/MkRenoteBar.vue | 165 +++++ packages/client/src/pages/user/media-list.vue | 2 +- packages/client/src/scripts/get-note-menu.ts | 43 +- .../src/scripts/show-note-context-menu.ts | 89 +++ 17 files changed, 865 insertions(+), 984 deletions(-) rename packages/client/src/components/{MkSubNoteContent.vue => note/MkNoteContent.vue} (98%) create mode 100644 packages/client/src/components/note/MkNoteFooter.vue create mode 100644 packages/client/src/components/note/MkNoteFooterInfo.vue rename packages/client/src/components/{ => note}/MkNoteHeader.vue (100%) create mode 100644 packages/client/src/components/note/MkNoteHeaderInfo.vue rename packages/client/src/components/{ => note}/MkNoteMedia.vue (100%) rename packages/client/src/components/{ => note}/MkNoteMediaList.vue (88%) create mode 100644 packages/client/src/components/note/MkNoteTranslation.vue create mode 100644 packages/client/src/components/note/MkRenoteBar.vue create mode 100644 packages/client/src/scripts/show-note-context-menu.ts diff --git a/packages/client/src/components/MkNote.vue b/packages/client/src/components/MkNote.vue index 34b1a79831..0b3012da24 100644 --- a/packages/client/src/components/MkNote.vue +++ b/packages/client/src/components/MkNote.vue @@ -10,10 +10,12 @@ :aria-label="accessibleLabel" class="tkcbzcuz note-container" :tabindex="!isDeleted ? '-1' : undefined" - :class="{ renote: isRenote || (renotesSliced && renotesSliced.length > 0) }" + :class="{ renote: isRenote || (renotes && renotes.length > 0) }" > @@ -32,106 +34,11 @@ }" @click="noteClick" > -
-
- - {{ i18n.ts.promotion - }} -
-
- - {{ i18n.ts.featured }} -
-
- {{ i18n.ts.pinnedNote }} -
-
- - - -
-
- - - - - - - -
- - -
-
+ +
- -
- -
- {{ - i18n.t("translatedFrom", { - x: translation.sourceLang, - }) - }}: - - -
-
+ > +
-
- - - - - - {{ appearNote.channel.name }} -
-
+ - - - - - - - - - - -
+ ref="footerEl" + :note="appearNote" + :enableEmojiReactions + :hideEmojiViewer + :detailedView + :note-translation="noteTranslation!" + @deleted="isDeleted = true" + @event:focus="focus" + @event:blur="blur" + />
@@ -333,39 +114,29 @@ + + diff --git a/packages/client/src/components/note/MkNoteFooterInfo.vue b/packages/client/src/components/note/MkNoteFooterInfo.vue new file mode 100644 index 0000000000..1e62053657 --- /dev/null +++ b/packages/client/src/components/note/MkNoteFooterInfo.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/packages/client/src/components/MkNoteHeader.vue b/packages/client/src/components/note/MkNoteHeader.vue similarity index 100% rename from packages/client/src/components/MkNoteHeader.vue rename to packages/client/src/components/note/MkNoteHeader.vue diff --git a/packages/client/src/components/note/MkNoteHeaderInfo.vue b/packages/client/src/components/note/MkNoteHeaderInfo.vue new file mode 100644 index 0000000000..bbd7120aaf --- /dev/null +++ b/packages/client/src/components/note/MkNoteHeaderInfo.vue @@ -0,0 +1,71 @@ + + + + + diff --git a/packages/client/src/components/MkNoteMedia.vue b/packages/client/src/components/note/MkNoteMedia.vue similarity index 100% rename from packages/client/src/components/MkNoteMedia.vue rename to packages/client/src/components/note/MkNoteMedia.vue diff --git a/packages/client/src/components/MkNoteMediaList.vue b/packages/client/src/components/note/MkNoteMediaList.vue similarity index 88% rename from packages/client/src/components/MkNoteMediaList.vue rename to packages/client/src/components/note/MkNoteMediaList.vue index 879ef8d673..cb02eebb3f 100644 --- a/packages/client/src/components/MkNoteMediaList.vue +++ b/packages/client/src/components/note/MkNoteMediaList.vue @@ -16,7 +16,7 @@ + + diff --git a/packages/client/src/components/note/MkRenoteBar.vue b/packages/client/src/components/note/MkRenoteBar.vue new file mode 100644 index 0000000000..948dfbc72f --- /dev/null +++ b/packages/client/src/components/note/MkRenoteBar.vue @@ -0,0 +1,165 @@ + + + + + diff --git a/packages/client/src/pages/user/media-list.vue b/packages/client/src/pages/user/media-list.vue index 533ad2a860..01c4526274 100644 --- a/packages/client/src/pages/user/media-list.vue +++ b/packages/client/src/pages/user/media-list.vue @@ -13,7 +13,7 @@