mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 23:19:37 +00:00
41 lines
1.3 KiB
Vue
41 lines
1.3 KiB
Vue
<script lang="ts" setup>
|
||
import FileShareResult from '@/components/Result/FileShareResult.vue'
|
||
import TextShareResult from '@/components/Result/TextShareResult.vue'
|
||
|
||
type basehandleData = { config: any, handle_type: string }
|
||
|
||
type filehandleData = { file: File, file_id: string } & basehandleData
|
||
type texthandleData = { text: string } & basehandleData
|
||
|
||
const props = defineProps<{
|
||
data: filehandleData | texthandleData
|
||
}>()
|
||
|
||
const emit = defineEmits<{
|
||
(e: 'change', key: string): void
|
||
}>()
|
||
|
||
const handleList = [
|
||
{ component: FileShareResult, key: 'file-share' },
|
||
{ component: TextShareResult, key: 'text-share' },
|
||
]
|
||
const handleComponent = computed(() => {
|
||
return handleList.find((item) => item.key === props?.data?.handle_type)?.component
|
||
})
|
||
// vue这个ts蠢的没边了,本来想写component: FileShareResult | TextShareResult,结果不行
|
||
|
||
</script>
|
||
<template>
|
||
<div>
|
||
<FileShareResult
|
||
v-if="handleComponent === FileShareResult && 'file' in data"
|
||
:data="data"
|
||
@change="(key: string) => emit('change', key)"
|
||
/>
|
||
<TextShareResult
|
||
v-else-if="handleComponent === TextShareResult && 'text' in data"
|
||
:data="data"
|
||
@change="(key: string) => emit('change', key)"
|
||
/>
|
||
</div>
|
||
</template> |