From 73c837a1e12839c5bdcad55464a6e7e278cc143d Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sat, 7 Jun 2025 16:21:38 +0900 Subject: [PATCH 1/5] enhance(frontend): refine postform uploader --- .../src/components/MkDriveFileThumbnail.vue | 35 +- .../frontend/src/components/MkPostForm.vue | 188 ++++++++--- .../src/components/MkPostFormAttaches.vue | 313 ++++++++++++++---- packages/frontend/src/utility/file-type.ts | 57 ++++ 4 files changed, 448 insertions(+), 145 deletions(-) create mode 100644 packages/frontend/src/utility/file-type.ts diff --git a/packages/frontend/src/components/MkDriveFileThumbnail.vue b/packages/frontend/src/components/MkDriveFileThumbnail.vue index 88afdef114..81494eef83 100644 --- a/packages/frontend/src/components/MkDriveFileThumbnail.vue +++ b/packages/frontend/src/components/MkDriveFileThumbnail.vue @@ -23,20 +23,13 @@ SPDX-License-Identifier: AGPL-3.0-only /> - - - - - - - - + @@ -46,6 +39,7 @@ SPDX-License-Identifier: AGPL-3.0-only import { computed } from 'vue'; import * as Misskey from 'misskey-js'; import MkImgWithBlurhash from '@/components/MkImgWithBlurhash.vue'; +import { getFileType, getFileTypeIcon } from '@/utility/file-type.js'; import { prefer } from '@/preferences.js'; const props = defineProps<{ @@ -56,27 +50,8 @@ const props = defineProps<{ large?: boolean; }>(); -const is = computed(() => { - if (props.file.type.startsWith('image/')) return 'image'; - if (props.file.type.startsWith('video/')) return 'video'; - if (props.file.type === 'audio/midi') return 'midi'; - if (props.file.type.startsWith('audio/')) return 'audio'; - if (props.file.type.endsWith('/csv')) return 'csv'; - if (props.file.type.endsWith('/pdf')) return 'pdf'; - if (props.file.type.startsWith('text/')) return 'textfile'; - if ([ - 'application/zip', - 'application/x-cpio', - 'application/x-bzip', - 'application/x-bzip2', - 'application/java-archive', - 'application/x-rar-compressed', - 'application/x-tar', - 'application/gzip', - 'application/x-7z-compressed', - ].some(archiveType => archiveType === props.file.type)) return 'archive'; - return 'unknown'; -}); +const is = computed(() => getFileType(props.file.type)); +const fileIcon = computed(() => getFileTypeIcon(is.value)); const isThumbnailAvailable = computed(() => { return props.file.thumbnailUrl diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index e319c9bacb..b5f0d25ae5 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -71,22 +71,22 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ maxTextLength - textLength }}
- -
- - {{ i18n.ts._postForm.uploaderTip }} - - -
+