|
@@ -17,6 +17,14 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
+ <div v-else-if="fileType === 'mp3'" class="audio-file">
|
|
|
+ <audio :src="fileUrl" controls></audio>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div v-else-if="fileType === 'mp4'" class="video-file">
|
|
|
+ <video :src="fileUrl" controls></video>
|
|
|
+ </div>
|
|
|
+
|
|
|
<template v-else>
|
|
|
<iframe
|
|
|
:src="'https://view.officeapps.live.com/op/view.aspx?src=' + `${fileUrl}`"
|
|
@@ -35,6 +43,7 @@
|
|
|
<script>
|
|
|
import pdf from 'vue-pdf';
|
|
|
import { GetFileStoreInfo } from '@/api/app';
|
|
|
+import { getFileType } from '@/utils/filter';
|
|
|
|
|
|
export default {
|
|
|
components: { pdf },
|
|
@@ -58,21 +67,29 @@ export default {
|
|
|
},
|
|
|
computed: {
|
|
|
fileType() {
|
|
|
- return this.fileName.slice(this.fileName.lastIndexOf('.') + 1, this.fileName.length);
|
|
|
+ return getFileType(this.fileName);
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
- fileId() {
|
|
|
- this.getFileStoreInfo();
|
|
|
+ fileId(newVal) {
|
|
|
+ if (newVal.length > 0) {
|
|
|
+ this.getFileStoreInfo();
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
getFileStoreInfo() {
|
|
|
GetFileStoreInfo({ file_id: this.fileId }).then(({ file_url_https }) => {
|
|
|
this.fileUrl = file_url_https;
|
|
|
+
|
|
|
if (this.fileType === 'pdf') {
|
|
|
this.getNumPages(file_url_https);
|
|
|
}
|
|
|
+
|
|
|
+ if (this.fileType === 'txt') {
|
|
|
+ this.dialogVisibleShowFile = false;
|
|
|
+ window.open(file_url_https, '_blank');
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
|
|
@@ -95,6 +112,7 @@ export default {
|
|
|
|
|
|
dialogShowFileClose() {
|
|
|
this.dialogVisibleShowFile = false;
|
|
|
+ this.$emit('dialogShowFileClose');
|
|
|
},
|
|
|
|
|
|
isImage(type) {
|
|
@@ -118,5 +136,13 @@ export default {
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
}
|
|
|
+
|
|
|
+ .audio-file {
|
|
|
+ @extend .image-parent;
|
|
|
+ }
|
|
|
+
|
|
|
+ .video-file {
|
|
|
+ @extend .image-parent;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|