From d7d2a5c00b9b1d98729eeb7bfff54fe395179ef2 Mon Sep 17 00:00:00 2001 From: keven1024 Date: Wed, 17 Dec 2025 08:11:02 +0800 Subject: [PATCH] refactor(front): update component props and types for FileShareResult and TextShareResult, and introduce a new types file for better type management --- front/components/Result/FileShareResult.vue | 6 ++---- front/components/Result/ResultIndexView.vue | 12 +++--------- front/components/Result/TextShareResult.vue | 6 ++---- front/components/Result/types.ts | 11 +++++++++++ 4 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 front/components/Result/types.ts diff --git a/front/components/Result/FileShareResult.vue b/front/components/Result/FileShareResult.vue index 9a543ef..d0bb35f 100644 --- a/front/components/Result/FileShareResult.vue +++ b/front/components/Result/FileShareResult.vue @@ -12,11 +12,9 @@ import showDrawer from '@/lib/showDrawer' import QrCoreDrawer from '@/components/Drawer/QrCoreDrawer.vue' import { h } from 'vue' import { cx } from 'class-variance-authority' -import type { FileHandleKey } from '../Preprocessing/types' +import type { handleFileComponentProps } from './types' -const props = defineProps<{ - data: { files: { id: string; file: File }[]; config: Record; handle_type: FileHandleKey } -}>() +const props = defineProps() const emit = defineEmits<{ (e: 'change', key: string): void }>() diff --git a/front/components/Result/ResultIndexView.vue b/front/components/Result/ResultIndexView.vue index 80dbf01..0c52a1d 100644 --- a/front/components/Result/ResultIndexView.vue +++ b/front/components/Result/ResultIndexView.vue @@ -2,13 +2,7 @@ import FileShareResult from '@/components/Result/FileShareResult.vue' import TextShareResult from '@/components/Result/TextShareResult.vue' import ImageCompressResult from '@/components/Result/ImageCompressResult.vue' -import type { FileHandleKey, TextHandleKey } from '../Preprocessing/types' - -type basehandleData = { config: Record } - -type filehandleData = { files: { id: string; file: File }[]; handle_type: FileHandleKey } & basehandleData -type texthandleData = { text: string; handle_type: TextHandleKey } & basehandleData -type handleKey = 'file-share' | 'text-share' | 'file-image-compress' +import type { filehandleData, handleComponent, handleKey, texthandleData } from './types' const props = defineProps<{ data: filehandleData | texthandleData @@ -18,7 +12,7 @@ const emit = defineEmits<{ (e: 'change', key: string): void }>() -const handleList: { component: Component<{ data: filehandleData | texthandleData }>; key: handleKey }[] = [ +const handleList: { component: handleComponent; key: handleKey }[] = [ { component: FileShareResult, key: 'file-share' }, { component: TextShareResult, key: 'text-share' }, { component: ImageCompressResult, key: 'file-image-compress' }, @@ -31,7 +25,7 @@ const activeHandle = computed(() => { diff --git a/front/components/Result/TextShareResult.vue b/front/components/Result/TextShareResult.vue index 7769ad4..b135e8a 100644 --- a/front/components/Result/TextShareResult.vue +++ b/front/components/Result/TextShareResult.vue @@ -10,11 +10,9 @@ import showDrawer from '@/lib/showDrawer' import QrCoreDrawer from '@/components/Drawer/QrCoreDrawer.vue' import dayjs from 'dayjs' import { h } from 'vue' -import type { TextHandleKey } from '../Preprocessing/types' +import type { handleTextComponentProps } from './types' -const props = defineProps<{ - data: { text: string; config: Record; handle_type: TextHandleKey } -}>() +const props = defineProps() const emit = defineEmits<{ (e: 'change', key: string): void diff --git a/front/components/Result/types.ts b/front/components/Result/types.ts new file mode 100644 index 0000000..35e25f5 --- /dev/null +++ b/front/components/Result/types.ts @@ -0,0 +1,11 @@ +import type { FileHandleKey, TextHandleKey } from '../Preprocessing/types' + +type basehandleData = { config: Record } + +export type filehandleData = { files: { id: string; file: File }[]; handle_type: FileHandleKey } & basehandleData +export type texthandleData = { text: string; handle_type: TextHandleKey } & basehandleData +export type handleKey = FileHandleKey | TextHandleKey + +export type handleTextComponentProps = { data: texthandleData } +export type handleFileComponentProps = { data: filehandleData } +export type handleComponent = Component