mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 07:08:02 +00:00
refactor(front): enhance FileIcon and FilePreviewView components to support filePreview type for improved flexibility
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
export type filePreview = {
|
||||
type: string
|
||||
name: string
|
||||
size: number
|
||||
}
|
||||
|
||||
import { LucideFileAudio, LucideFileVideo, LucideFile, LucideFileCode, LucideFileArchive, LucideFileText } from 'lucide-vue-next'
|
||||
const props = defineProps<{
|
||||
file: File
|
||||
file: File | filePreview
|
||||
}>()
|
||||
const imageUrl = computed(() => {
|
||||
if (props?.file?.type?.startsWith('image/')) {
|
||||
if (props?.file?.type?.startsWith('image/') && props?.file instanceof File) {
|
||||
return URL.createObjectURL(props?.file)
|
||||
}
|
||||
return null
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script lang="ts" setup>
|
||||
import { filesize } from 'filesize'
|
||||
import type { filePreview } from './FileIcon.vue';
|
||||
const props = defineProps<{
|
||||
value: File
|
||||
value: File | filePreview
|
||||
}>()
|
||||
const fileInfo = computed(() => {
|
||||
const [, name, ext] = props?.value?.name?.match(/^(.+)\.(.+)$/) || []
|
||||
|
||||
Reference in New Issue
Block a user