11<script lang="ts" setup>
2- import {watch } from ' vue'
3- import {PreviewRules , getPreviewTypeByFileType } from ' ../../preview.const'
4- import type {IPreviewRule , PreviewProps } from ' ../../preview.interface'
5- import {PreviewType } from ' ../../preview.interface'
6- import {getFileName , getFileType } from ' ../../utils/utils'
2+ import { watch } from ' vue'
3+ import { PreviewRules , getPreviewTypeByFileType } from ' ../../preview.const'
4+ import type { IPreviewRule , PreviewProps } from ' ../../preview.interface'
5+ import { PreviewType } from ' ../../preview.interface'
6+ import { getFileName , getFileType } from ' ../../utils/utils'
77
88const props = withDefaults (
9- defineProps < PreviewProps & {
10- width?: string
11- height ?: string
12- }> (),
13- {
14- file : () => null ,
15- url : () => null ,
16- width : () => ' 100%' ,
17- height : () => ' 100%' ,
18- overflow : () => ' auto' ,
19- },
9+ defineProps < PreviewProps & {
10+ width?: string
11+ height ?: string
12+ overflow ?: string
13+ }> (),
14+ {
15+ file : () => null ,
16+ url : () => null ,
17+ width : () => ' 100%' ,
18+ height : () => ' 100%' ,
19+ overflow : () => ' auto' ,
20+ },
2021)
2122
2223const currentPreview = shallowRef <IPreviewRule >(PreviewRules [PreviewType .NONE ])
@@ -30,24 +31,19 @@ function syncPreview(file: File): void {
3031}
3132
3233watch (
33- () => props .file ,
34- (file ) => {
35- if (file ) {
36- syncPreview (file )
37- }
38- },
39- { immediate: true },
34+ () => props .file ,
35+ (file ) => {
36+ if (file ) {
37+ syncPreview (file )
38+ }
39+ },
40+ { immediate: true },
4041)
4142 </script >
4243
4344<template >
4445 <div class =" vue-files-preview" :style =" { width, height, overflow }" >
45- <component
46- :is =" currentPreview.component"
47- :name =" currentPreview.name"
48- :file =" file"
49- :url =" url"
50- />
46+ <component :is =" currentPreview.component" :name =" currentPreview.name" :file =" file" :url =" url" />
5147 </div >
5248</template >
5349
0 commit comments