提交 2cb347a3 authored 作者: matian's avatar matian

修改zip 和rar为可下载

上级 5ac958be
<script setup lang="ts"> <script setup lang="ts">
const props = defineProps({ const props = defineProps({
url: { item: {
type: String, type: Object,
require: true require: true
} }
}) })
let isShowType = ref(1) let isShowType = ref(1)
// 判断用什么标签展示内容 // 判断用什么标签展示内容
if (props.url?.indexOf('.pdf') !== -1 || props.url?.indexOf('.txt') !== -1) { if (props.item?.url?.indexOf('.pdf') !== -1 || props.item?.url?.indexOf('.txt') !== -1) {
isShowType.value = 2 isShowType.value = 2
} else if (props.url?.indexOf('.mp4') !== -1) { } else if (props.item?.url?.indexOf('.mp4') !== -1) {
isShowType.value = 3 isShowType.value = 3
} else if (props.url?.indexOf('.mp3') !== -1) { } else if (props.item?.url?.indexOf('.mp3') !== -1) {
isShowType.value = 4 isShowType.value = 4
} else if ( } else if (
props.url?.indexOf('.png') !== -1 || props.item?.url?.indexOf('.png') !== -1 ||
props.url?.indexOf('.jpg') !== -1 || props.item?.url?.indexOf('.jpg') !== -1 ||
props.url?.indexOf('.jpeg') !== -1 props.item?.url?.indexOf('.jpeg') !== -1
) { ) {
isShowType.value = 5 isShowType.value = 5
} else if (props.url?.indexOf('.rar') !== -1 || props.url?.indexOf('.zip') !== -1) { } else if (props.item?.url?.indexOf('.rar') !== -1 || props.item?.url?.indexOf('.zip') !== -1) {
isShowType.value = 6 isShowType.value = 6
} }
</script> </script>
...@@ -28,25 +28,33 @@ if (props.url?.indexOf('.pdf') !== -1 || props.url?.indexOf('.txt') !== -1) { ...@@ -28,25 +28,33 @@ if (props.url?.indexOf('.pdf') !== -1 || props.url?.indexOf('.txt') !== -1) {
<template> <template>
<el-card> <el-card>
<div class="max-w-h"> <div class="max-w-h">
<iframe v-if="isShowType === 1" :src="`https://view.officeapps.live.com/op/view.aspx?src=${props.url}`"></iframe> <iframe
<embed :src="props.url" v-else-if="isShowType === 2" /> v-if="isShowType === 1"
:src="`https://view.officeapps.live.com/op/view.aspx?src=${props.item?.url}`"
></iframe>
<embed :src="props.item?.url" v-else-if="isShowType === 2" />
<video v-else-if="isShowType === 3" controls id="video"> <video v-else-if="isShowType === 3" controls id="video">
<source :src="props.url" /> <source :src="props.item?.url" />
</video> </video>
<audio v-else-if="isShowType === 4" :src="props.url" controls></audio> <audio v-else-if="isShowType === 4" :src="props.item?.url" controls></audio>
<img v-else-if="isShowType === 5" :src="props.url" /> <img v-else-if="isShowType === 5" :src="props.item?.url" />
<div v-else-if="isShowType === 6" class="zip_con"> <div v-else-if="isShowType === 6" class="zip_con">
<img <a :href="props.item?.url" style="color: #aa1941">
v-if="props.url?.indexOf('.rar') !== -1" <img
src="https://webapp-pub.ezijing.com/center_resource/rar.png" v-if="props.item?.url?.indexOf('.rar') !== -1"
class="img_zip" src="https://webapp-pub.ezijing.com/center_resource/rar.png"
/> class="img_zip"
<img />
v-else-if="props.url?.indexOf('.zip') !== -1"
src="https://webapp-pub.ezijing.com/center_resource/zip.png" <img
class="img_zip" v-else-if="props.item?.url?.indexOf('.zip') !== -1"
/> src="https://webapp-pub.ezijing.com/center_resource/zip.png"
<div class="zip_tips">* 该文件格式暂不支持预览</div> class="img_zip"
/>
{{ props.item?.name }}
</a>
<div class="zip_tips">* 该文件格式暂不支持预览,可点击上方文件名下载</div>
</div> </div>
</div> </div>
</el-card> </el-card>
......
...@@ -260,8 +260,9 @@ const handleExamDetail = (row: any) => { ...@@ -260,8 +260,9 @@ const handleExamDetail = (row: any) => {
<el-empty description="暂无数据" v-if="!resourceData.lessonPlan.length" /> <el-empty description="暂无数据" v-if="!resourceData.lessonPlan.length" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="资料" name="3"> <el-tab-pane label="资料" name="3">
{{ resourceData.data }}
<PreviewFiles <PreviewFiles
:url="item.url" :item="item"
v-for="item in resourceData.data" v-for="item in resourceData.data"
:key="item.id" :key="item.id"
style="margin-top: 10px" style="margin-top: 10px"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论