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 265ecec..5e96f73 100644 --- a/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue +++ b/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue @@ -162,6 +162,7 @@ import PopoverMenuItem from '../../../components/PopoverMenuItem.vue' import QuestToPPTist from '@/views/classTask/newClassTaskAssign/questToPPTist/index.vue' import MaterialDialog from './MaterialDialog.vue' 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) @@ -199,8 +200,9 @@ const insertImageElement = (files: FileList) => { getImageDataURL(imageFile).then(dataURL => createImageElement(dataURL)) } -const onhtml2canvas = async (imgbs64: String) => { - createImageElement(imgbs64); +const onhtml2canvas = async (html: HTMLElement) => { + const ele = await toPng(html) + createImageElement(ele); } const shapePoolVisible = ref(false) diff --git a/src/renderer/src/views/classTask/newClassTaskAssign/myQuestion/index.vue b/src/renderer/src/views/classTask/newClassTaskAssign/myQuestion/index.vue index 255d0b4..54118ca 100644 --- a/src/renderer/src/views/classTask/newClassTaskAssign/myQuestion/index.vue +++ b/src/renderer/src/views/classTask/newClassTaskAssign/myQuestion/index.vue @@ -120,7 +120,6 @@ import { Search } from '@element-plus/icons-vue' import { onMounted, ref,watch, reactive, getCurrentInstance,nextTick } from 'vue' import { useRouter, useRoute } from 'vue-router' // import html2canvas from 'html2canvas'; -import { toPng } from 'html-to-image' // 引入html-to-image库 import { listEntpcoursework, listEntpcourseworkLocal } from '@/api/education/entpCourseWork' import { listEvaluationclue } from '@/api/classTask' @@ -460,10 +459,15 @@ const handleDelete = async(item, index) => { const captureScreenshot = (id) => { const targetElement = document.getElementById('screenshot-target-' + id); if (targetElement) { - toPng(targetElement).then(canvas => { - emit('addQuizImgBs64', canvas); - }); + emit('addQuizImgBs64', targetElement); } + // html2canvas(targetElement).then(canvas => { + // // 将canvas转换为图像URL + // const screenshotUrl = canvas.toDataURL('image/png'); + // // 在这里可以将截图保存到本地或上传到服务器 + // // console.log(screenshotUrl); + // emit('addQuizImgBs64', screenshotUrl); + // }); } // 防抖 diff --git a/src/renderer/src/views/classTask/newClassTaskAssign/searchQuestion/index.vue b/src/renderer/src/views/classTask/newClassTaskAssign/searchQuestion/index.vue index e0da12e..9cf6b7e 100644 --- a/src/renderer/src/views/classTask/newClassTaskAssign/searchQuestion/index.vue +++ b/src/renderer/src/views/classTask/newClassTaskAssign/searchQuestion/index.vue @@ -107,7 +107,6 @@