Merge branch 'develop' of http://25.13.9.101:9000/K17_AITS/tra-app into develop

This commit is contained in:
田岩
2025-07-04 10:11:53 +08:00
7 changed files with 208 additions and 40 deletions
+25 -4
View File
@@ -4,7 +4,10 @@
<script>
import {previewFile, previewCacheThumbImage} from'@/api/common.js'
import {get_base_url} from '@/api/request.js'
import { get_base_url } from '@/api/request.js'
import { useStorageStore } from "@/store/storage.js"
// const storageStore = useStorageStore()
export default {
name:"image-preview",
props:{
@@ -36,6 +39,12 @@
base_url: get_base_url()
};
},
computed:{
storageStore:() => useStorageStore(),
imageObj() {
return this.storageStore?.imgObj||{}
}
},
watch: {
imgId: {
handler(newval, oldval) {
@@ -58,15 +67,26 @@
},
methods: {
getPreviewUrlBlob(id) {
if (id === null) {
console.log('谢谢谢谢谢谢', id);
if (!id) {
this.imgUrlShow = ''
return
}
if(this.isCache){
let _cache = this.imageObj[`/${id}/${this.width}/${this.height}`] || ''
if(_cache){
this.imgUrlShow = _cache;
return
}
previewCacheThumbImage(id, this.width,this.height).then((res) => {
this.imgUrlShow = res;
this.storageStore.setStorage('image', `/${id}/${this.width}/${this.height}`, res)
});
}else{
let _cache = this.imageObj[`${id}`] || ''
if(_cache){
this.imgUrlShow = _cache;
return
}
previewFile(id).then((result) => {
//#ifdef APP-PLUS
let _header = result.header['Content-Type'].split(';')[0]
@@ -76,6 +96,7 @@
// #endif
let base64 = `data:${_header};base64,` + uni.arrayBufferToBase64(result.data)
this.imgUrlShow = base64;
this.storageStore.setStorage('image', id, base64)
});
}
},
+24 -7
View File
@@ -1,27 +1,34 @@
<template>
<view class="video-view-box">
<video class="video-cont" v-if="imgUrlShow" :src="imgUrlShow" controls></video>
<video class="video-cont" v-if="fileUrlShow" :src="fileUrlShow" controls></video>
</view>
</template>
<script>
import { downloadFile } from'@/api/common.js'
import { useStorageStore } from "@/store/storage.js"
export default {
name:"video-preview",
props:{
imgId:{
fileId:{
default:'',
type:String
}
},
data() {
return {
imgUrlShow:'',
fileUrlShow:'',
watching:false
};
},
computed:{
storageStore:() => useStorageStore(),
videoObj() {
return this.storageStore?.videoObj||{}
}
},
watch: {
imgId: {
fileId: {
handler(newval, oldval) {
if (newval && this.watching) {
this.getPreviewUrlBlob(newval);
@@ -33,14 +40,24 @@
},
methods: {
getPreviewUrlBlob(id) {
if (!id) {
this.fileUrlShow = ''
return
}
let _cache = this.videoObj[id] || ''
if(_cache){
this.fileUrlShow = _cache;
return
}
downloadFile(id).then(res=>{
this.imgUrlShow = res.tempFilePath
this.fileUrlShow = res.tempFilePath
this.storageStore.setStorage('video', id, this.fileUrlShow)
})
},
},
mounted() {
if (this.imgId) {
this.getPreviewUrlBlob(this.imgId);
if (this.fileId) {
this.getPreviewUrlBlob(this.fileId);
}
this.watching = true
},