@@ -17,18 +17,27 @@ const { entity, metadata } = defineProps<{
1717}>();
1818
1919const data = ref ();
20- const downloadUrl = ref (' ' );
2120const streamUrl = ref (' ' );
2221
2322const resolveFile = async () => {
2423 if (entity .entityType !== ' http://schema.org/MediaObject' ) {
2524 return ;
2625 }
2726
28- downloadUrl .value = (await api .getFileUrl (entity .fileId , metadata .filename , true )) || ' ' ;
2927 streamUrl .value = (await api .getFileUrl (entity .fileId , metadata .filename , false )) || ' ' ;
3028};
3129
30+ const handleDownload = async () => {
31+ if (entity .entityType !== ' http://schema.org/MediaObject' ) {
32+ return ;
33+ }
34+
35+ const url = await api .getFileUrl (entity .fileId , metadata .filename , true );
36+ if (url ) {
37+ window .location .href = url ;
38+ }
39+ };
40+
3241const extension = metadata .filename .split (' .' ).pop () || ' ' ;
3342const encodingFormat = [metadata .encodingFormat ].flat ();
3443const plainEncodingFormats = encodingFormat .filter ((ef ) => typeof ef === ' string' );
@@ -94,10 +103,8 @@ resolveFile();
94103
95104 <el-row class =" flex justify-center" v-if =" entity.access.content" >
96105 <el-button-group class =" m-2" >
97- <el-link class =" mr-2" underline =" never" :href =" downloadUrl" >
98- <el-button type =" default" >Download File  ; <font-awesome-icon icon =" fa fa-download" />
99- </el-button >
100- </el-link >
106+ <el-button type =" default" @click =" handleDownload" >Download File  ; <font-awesome-icon icon =" fa fa-download" />
107+ </el-button >
101108 </el-button-group >
102109 </el-row >
103110 </el-col >
0 commit comments