fix:第三方资源图片预览修改;

This commit is contained in:
小杨 2024-10-25 13:56:34 +08:00
parent 4b6a7918a9
commit 5790e87a85
2 changed files with 43 additions and 29 deletions

View File

@ -0,0 +1,35 @@
<template>
<el-drawer v-model="model" class="preview-drawer" :modal="true" :destroy-on-close="true" :with-header="false" :append-to-body="true"
size="50%">
<div class="drawer-content">
<el-image v-for="(url,index) in srcList" :key="index" :src="url" lazy />
</div>
</el-drawer>
</template>
<script setup>
import {ref} from 'vue'
import {getImgPath} from "@/api/file/third";
const model = defineModel()
//
const srcList = ref([])
const init = (id) => {
srcList.value = []
getImgPath({itemId:id}).then(res => {
if(res.code === 200){
res.data.forEach(item => {
item.subsets.forEach(previewItem => {
previewItem.previewFiles.forEach(fileItem => {
srcList.value.push(fileItem.fileUrl)
})
})
})
}
})
}
defineExpose({
init
})
</script>

View File

@ -7,12 +7,11 @@
v-for="item in sourceStore.thirdResult.list" v-for="item in sourceStore.thirdResult.list"
:key="item.itemId" :key="item.itemId"
class="list-item" class="list-item"
@click="handleRow" @click="handleRow(item)"
> >
<div class="item-left flex"> <div class="item-left flex">
<div style="position: relative" @click="clickImg(item.itemId)"> <div style="position: relative">
<FileImage :file-name="item.fileType" :size="50" /> <FileImage :file-name="item.fileType" :size="50" />
<el-icon style="position: absolute;top: 1px;right: 5px"><Search /></el-icon>
</div> </div>
<div class="flex item-left-content"> <div class="flex item-left-content">
<div class="name flex" :title="item.title"> <div class="name flex" :title="item.title">
@ -66,14 +65,7 @@
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
/> />
</div> </div>
<el-dialog v-model="isViewImg" width="80%" :modal-append-to-body="false" :append-to-body="false"> <FilePreview ref="thirdPreview" v-model="isViewImg"></FilePreview>
<div class="demo-image__lazy">
<el-image v-for="(url,index) in srcList" :key="index" :src="url" lazy />
</div>
</el-dialog>
<!-- <video width="550" controls autoplay loop>-->
<!-- <source src="https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-360p.mp4" type="video/mp4" />-->
<!-- </video>-->
</div> </div>
</template> </template>
@ -82,10 +74,9 @@ import { ref } from 'vue'
// import { ElMessage, ElMessageBox } from 'element-plus' // import { ElMessage, ElMessageBox } from 'element-plus'
import { Clock,View,Folder,Search } from '@element-plus/icons-vue' import { Clock,View,Folder,Search } from '@element-plus/icons-vue'
import FileImage from '@/components/file-image/index.vue' import FileImage from '@/components/file-image/index.vue'
import { getFileSuffix } from '@/utils/ruoyi' import FilePreview from '@/components/thirdFile-preview/index.vue'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import useResoureStore from '../store' import useResoureStore from '../store'
import {getImgPath} from "@/api/file/third";
const userstore = useUserStore() const userstore = useUserStore()
const sourceStore = useResoureStore() const sourceStore = useResoureStore()
@ -93,8 +84,7 @@ const sourceStore = useResoureStore()
// const userInfo = userstore.user // const userInfo = userstore.user
// //
const isViewImg = ref(false) const isViewImg = ref(false)
// const thirdPreview = ref()
const srcList = ref([])
// change // change
const handleSizeChange = (limit) => { const handleSizeChange = (limit) => {
@ -120,20 +110,9 @@ function timestampToDate(timestamp) {
return `${year}-${month}-${day}`; return `${year}-${month}-${day}`;
} }
// //
const clickImg = (id) => { const handleRow = (item) => {
srcList.value = [] isViewImg.value = true
getImgPath({itemId:id}).then(res => { thirdPreview.value.init(item.itemId)
if(res.code === 200){
isViewImg.value = true
res.data.forEach(item => {
item.subsets.forEach(previewItem => {
previewItem.previewFiles.forEach(fileItem => {
srcList.value.push(fileItem.fileUrl)
})
})
})
}
})
} }
</script> </script>