edti 插入素材

This commit is contained in:
lyc 2024-12-13 09:47:15 +08:00
parent eaa14b1666
commit a379176496
3 changed files with 12 additions and 13 deletions

View File

@ -19,8 +19,8 @@
import { ref, reactive, onMounted, computed } from 'vue'; import { ref, reactive, onMounted, computed } from 'vue';
import { sessionStore } from '@/utils/store' import { sessionStore } from '@/utils/store'
import { getSmarttalkPage } from '@/api/file' import { getSmarttalkPage } from '@/api/file'
import { getFileSuffix, urlToBase64 } from '@/utils/ruoyi.js'
import * as commUtils from '@/utils/comm.js' import * as commUtils from '@/utils/comm.js'
import { getFileSuffix } from '@/utils/ruoyi.js'
const emit = defineEmits(['insertMaterial', 'close']) const emit = defineEmits(['insertMaterial', 'close'])
@ -63,12 +63,9 @@ const fileUrl = computed(() => (item) =>{
// //
const onInsert = async (item) =>{ const onInsert = async (item) =>{
const res = await fetch(item.fileFullPath)
const bolb = commUtils.base64ToBlob(item.fileFullPath) const bolb = await res.blob()
const file = commUtils.blobToFile(bolb, item.fileShowName)
const file = commutils.blobToFile(bolb, item.fileShowName)
if(videoSuffix.indexOf(getFileSuffix(item.fileShowName)) != -1){ if(videoSuffix.indexOf(getFileSuffix(item.fileShowName)) != -1){
emit('insertMaterial',{ type: 'video', file }) emit('insertMaterial',{ type: 'video', file })

View File

@ -292,8 +292,9 @@ const insertMaterial = (item: MaterialParams) =>{
else{ else{
createImageElement(data) createImageElement(data)
} }
materiaVisible.value = false
}) })
materiaVisible.value = false
} }
// //

View File

@ -482,10 +482,7 @@ export default {
// //
async saveImage(resultIndex, index, url, resultItem) { async saveImage(resultIndex, index, url, resultItem) {
if(this.hasPPt){
this.$emit('insertImg', url)
return
}
this.buttonStates[resultIndex][index].disabled = true; this.buttonStates[resultIndex][index].disabled = true;
this.buttonStates[resultIndex][index].text = "正在保存..."; this.buttonStates[resultIndex][index].text = "正在保存...";
const numberIndex = url.indexOf('filename='); const numberIndex = url.indexOf('filename=');
@ -495,6 +492,7 @@ export default {
try { try {
const blob = await this.getImageBlob(`https://ai.ysaix.com:7853/view?filename=${finalPath}&type=temp`); const blob = await this.getImageBlob(`https://ai.ysaix.com:7853/view?filename=${finalPath}&type=temp`);
const hash = CryptoJS.MD5(blob).toString(); const hash = CryptoJS.MD5(blob).toString();
const formData = new FormData(); const formData = new FormData();
@ -502,7 +500,10 @@ export default {
let file = new File([blob], `${resultItem}.png`, { let file = new File([blob], `${resultItem}.png`, {
type: 'image/png' type: 'image/png'
}) })
if(this.hasPPt){
this.$emit('insertImg', file)
return
}
// //
formData.append('md5', hash); formData.append('md5', hash);
formData.append('file', file); formData.append('file', file);