pptList试题转图片优化

This commit is contained in:
“zouyf” 2024-12-10 10:12:47 +08:00
parent d90b7c695a
commit 2360d95f1c
2 changed files with 16 additions and 10 deletions

View File

@ -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, toJpeg } from 'html-to-image' // html-to-image
const mainStore = useMainStore()
const { creatingElement, creatingCustomShape, showSelectPanel, showSearchPanel, showNotesPanel } = storeToRefs(mainStore)
@ -199,8 +200,10 @@ const insertImageElement = (files: FileList) => {
getImageDataURL(imageFile).then(dataURL => createImageElement(dataURL))
}
const onhtml2canvas = (imgbs64: string) => {
createImageElement(imgbs64)
const onhtml2canvas = async (html: HTMLElement) => {
//createImageElement(imgbs64);
const ele = await toPng(html)
createImageElement(ele);
}
const shapePoolVisible = ref(false)

View File

@ -105,7 +105,7 @@
</template>
<script setup>
import { Search } from '@element-plus/icons-vue'
import html2canvas from 'html2canvas';
//import html2canvas from 'html2canvas';
import { onMounted, ref,watch, reactive, getCurrentInstance,nextTick } from 'vue'
import {listEntpcoursework, listEntpcourseworkNew, getEntpcoursework} from '@/api/education/entpCourseWork'
@ -439,13 +439,16 @@ const getPaginationList = ( page, limit ) => {
*/
const captureScreenshot = (id) => {
const targetElement = document.getElementById('screenshot-target-' + id);
html2canvas(targetElement).then(canvas => {
// canvasURL
const screenshotUrl = canvas.toDataURL('image/png');
//
// console.log(screenshotUrl);
emit('addQuizImgBs64', screenshotUrl);
});
if (targetElement) {
emit('addQuizImgBs64', targetElement);
}
// html2canvas(targetElement).then(canvas => {
// // canvasURL
// const screenshotUrl = canvas.toDataURL('image/png');
// //
// // console.log(screenshotUrl);
// emit('addQuizImgBs64', screenshotUrl);
// });
}