diff --git a/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/MaterialDialog.vue b/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/MaterialDialog.vue index 9ad6322..26c852e 100644 --- a/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/MaterialDialog.vue +++ b/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/MaterialDialog.vue @@ -19,7 +19,8 @@ import { ref, reactive, onMounted, computed } from 'vue'; import { sessionStore } from '@/utils/store' import { getSmarttalkPage } from '@/api/file' -import { getFileSuffix, urlToBase64 } from '@/utils/ruoyi.js' +import * as commUtils from '@/utils/comm.js' +import { getFileSuffix } from '@/utils/ruoyi.js' const emit = defineEmits(['insertMaterial', 'close']) @@ -62,12 +63,15 @@ const fileUrl = computed(() => (item) =>{ // 插入 const onInsert = async (item) =>{ + const res = await fetch(item.fileFullPath) + const bolb = await res.blob() + const file = commUtils.blobToFile(bolb, item.fileShowName) + if(videoSuffix.indexOf(getFileSuffix(item.fileShowName)) != -1){ - emit('insertMaterial',{ type: 'video', data: item.fileFullPath }) + emit('insertMaterial',{ type: 'video', file }) } else{ - const base64 = await urlToBase64(item.fileFullPath) - emit('insertMaterial',{ type: 'img', data: base64 }) + emit('insertMaterial',{ type: 'img', file }) } } diff --git a/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue b/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue index 909f7fe..ad51dd9 100644 --- a/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue +++ b/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue @@ -132,7 +132,7 @@ - + @@ -165,6 +165,7 @@ import { PPTApi } from '../../../api' import TextCreateImg from '@/components/ai-kolors/index.vue' import { toPng } from 'html-to-image' // 引入html-to-image库 + const mainStore = useMainStore() const { creatingElement, creatingCustomShape, showSelectPanel, showSearchPanel, showNotesPanel } = storeToRefs(mainStore) const { canUndo, canRedo } = storeToRefs(useSnapshotStore()) @@ -280,21 +281,31 @@ const toggleNotesPanel = () => { // 插入素材 interface MaterialParams { type: string, - data: string + file: any } const insertMaterial = (item: MaterialParams) =>{ - const { type, data } = item - if(type == 'video'){ - createVideoElement(data) - } - else{ - createImageElement(data) - } - materiaVisible.value = false + const { type, file } = item + PPTApi.toRousrceUrl(file).then(data=>{ + if(type == 'video'){ + createVideoElement(data) + } + else{ + createImageElement(data) + } + materiaVisible.value = false + }) + } // 文生图 const imgVisible = ref(false) +const insertImg = async (file: any) =>{ + PPTApi.toRousrceUrl(file).then(data=>{ + createImageElement(data) + imgVisible.value = false + }) +} +