From 892b4ee3b00f49040c2ab5ee9a03742ed63c9e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E4=BA=86=E4=B8=AA=E7=99=BD?= <543593352@qq.com> Date: Thu, 12 Dec 2024 15:26:14 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E6=95=99=E7=A8=8B=E5=88=86=E6=9E=90?= =?UTF-8?q?=EF=BC=9Apdf=E9=A1=B5=E9=9D=A2=E5=B1=95=E7=A4=BA=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/public/pdfjs-dist/web/viewer.mjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/renderer/public/pdfjs-dist/web/viewer.mjs b/src/renderer/public/pdfjs-dist/web/viewer.mjs index 0ae4fbc..08b3d5d 100644 --- a/src/renderer/public/pdfjs-dist/web/viewer.mjs +++ b/src/renderer/public/pdfjs-dist/web/viewer.mjs @@ -13097,15 +13097,15 @@ const PDFViewerApplication = { } if (isValidSpreadMode(spread)) { //默认双页 - // this.pdfViewer.spreadMode = spread; - this.pdfViewer.spreadMode = 1; + this.pdfViewer.spreadMode = spread; + // this.pdfViewer.spreadMode = 1; } }; this.isInitialViewSet = true; this.pdfSidebar?.setInitialView(sidebarView); //默认双页 - // setViewerModes(scrollMode, spreadMode); - setViewerModes(scrollMode, 1); + setViewerModes(scrollMode, spreadMode); + // setViewerModes(scrollMode, 1); if (this.initialBookmark) { setRotation(this.initialRotation); delete this.initialRotation; From 19ef95447c7d332a73da56c4a1441a1bfeb2ab3f Mon Sep 17 00:00:00 2001 From: cys <372127021@qq.com> Date: Thu, 12 Dec 2024 16:04:43 +0800 Subject: [PATCH 2/9] 1 --- src/renderer/src/utils/comm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/src/utils/comm.js b/src/renderer/src/utils/comm.js index fc3b89e..35d87f6 100644 --- a/src/renderer/src/utils/comm.js +++ b/src/renderer/src/utils/comm.js @@ -395,6 +395,6 @@ export const dataSetJson = { "课标-高中-英语": "e889fcac9fd011efb22a0242ac140006", "课标-高中-数学": "e03aa4fe9fd011ef91270242ac140006", "课标-高中-地理": "270516829fd111efb13c0242ac140006", - "课标-高中-政治": "a7df2b01aafd11ef8bb40242ac140002", + "课标-高中-政治": "a2f0b247b85d11ef84290242ac140005", "鉴权": "ragflow-IwMDI1MGU2YTU3NjExZWZiNWEzMDI0Mm" } \ No newline at end of file From 590b318757976faee608d3a8483f6ed7fa878c6e Mon Sep 17 00:00:00 2001 From: zhangxuelin <959231531@qq.com> Date: Thu, 12 Dec 2024 16:12:32 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/plugins/imChat/msgEnum.js | 2 + .../src/views/classTask/teachClassTask.vue | 75 ++++++++++++------- 2 files changed, 50 insertions(+), 27 deletions(-) diff --git a/src/renderer/src/plugins/imChat/msgEnum.js b/src/renderer/src/plugins/imChat/msgEnum.js index d685406..d5c72a3 100644 --- a/src/renderer/src/plugins/imChat/msgEnum.js +++ b/src/renderer/src/plugins/imChat/msgEnum.js @@ -82,6 +82,8 @@ export class MsgEnum { MSG_classcourseopen : 'classcourseopen', /** @desc: 学生的测练结果反馈 */ MSG_classquizfeedback : 'classquizfeedback', + /** @desc: 学生提交作业 */ + MSG_finishHomework : 'finishHomework', /** @desc: 老师端:接收到学生反馈消息-课堂测练中的其他任务 */ MSG_classtaskfeedback : 'classtaskfeedback', /** @desc: 老师端:学生反馈的消息,具体要看其中的feedbackkey,类别较繁杂 */ diff --git a/src/renderer/src/views/classTask/teachClassTask.vue b/src/renderer/src/views/classTask/teachClassTask.vue index b75c739..d0be63a 100644 --- a/src/renderer/src/views/classTask/teachClassTask.vue +++ b/src/renderer/src/views/classTask/teachClassTask.vue @@ -162,9 +162,10 @@ import ItemDialogScore from '@/views/classTask/container/classTask/item-dialog-s import quizStats from '@/views/classTask/container/quizStats.vue' import ClassOverview from '@/views/classTask/container/classOverview.vue' import {sessionStore} from '@/utils/store' -import Chat from '@/utils/chat' // im 登录初始化 - - +// import Chat from '@/utils/chat' // im 登录初始化 +import MsgEnum from '@/plugins/imChat/msgEnum' // im 消息枚举 +import ChatWs from '@/plugins/socket' // 聊天socket +if (!ChatWs.ws) ChatWs.init() const { proxy } = getCurrentInstance() const emit = defineEmits(['cle-click']) const props = defineProps({ @@ -715,25 +716,35 @@ const closeDialog = () => { const msgHandle = (msg) => { const { type, data } = msg switch(type) { - case 'TIMAddRecvNewMsgCallback': // 收到新消息 data=[] - { - (data||[]).forEach(o => { - const msgArr = o?.message_elem_array||[] - msgArr.forEach(info => { - const msgType = info?.elem_type // 消息类型 TIMElemType - const msgData = !!info.text_elem_content ? JSON.parse(info.text_elem_content)||'' : '' - // 处理学生端反馈得消息 - //console.log('msgData->', msgData); - if (msgData.msgKey == "finishHomework"){ - // 刷新 - const data = JSON.parse(localStorage.getItem('teachClassWorkItem')); - //console.log('data->', data); - openDialog(data, false); - } - }) - }) - } - break + case MsgEnum.HEADS.MSG_closed: // 下课: + window.close() // 关闭窗口 + break + case MsgEnum.HEADS.MSG_finishHomework: // 跟新作业: + const data = JSON.parse(localStorage.getItem('teachClassWorkItem')); + openDialog(data, false); + break + case MsgEnum.HEADS.MSG_slideFlapping: // 切换页面 + window.close() // 关闭窗口 + break + // case 'TIMAddRecvNewMsgCallback': // 收到新消息 data=[] + // { + // (data||[]).forEach(o => { + // const msgArr = o?.message_elem_array||[] + // msgArr.forEach(info => { + // const msgType = info?.elem_type // 消息类型 TIMElemType + // const msgData = !!info.text_elem_content ? JSON.parse(info.text_elem_content)||'' : '' + // // 处理学生端反馈得消息 + // //console.log('msgData->', msgData); + // if (msgData.msgKey == "finishHomework"){ + // // 刷新 + // const data = JSON.parse(localStorage.getItem('teachClassWorkItem')); + // //console.log('data->', data); + // openDialog(data, false); + // } + // }) + // }) + // } + // break } } @@ -750,11 +761,21 @@ onMounted(() => { isReloadTimer(); // im监听消息 - if (!Chat.imChat) { - Chat.init(true, true, msgHandle); - } else { - Chat.listenMsg(msgHandle); - } + if (ChatWs.ws) { + ChatWs.watch((msg, e) => { + try { + msgHandle(JSON.parse(msg)) + } catch (error) { + console.error('socket 解析异常 ', error, e) + msgHandle(msg) + } + }) + } + // if (!Chat.imChat) { + // Chat.init(true, true, msgHandle); + // } else { + // Chat.listenMsg(msgHandle); + // } }) const isReloadTimer = () =>{ clearInterval(reloadTimer.value) // 关闭定时器 From 851a39897b48b958f1a24f65d18791d5dc58ead3 Mon Sep 17 00:00:00 2001 From: zhangxuelin <959231531@qq.com> Date: Thu, 12 Dec 2024 16:15:16 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/classTask/teachClassTask.vue | 62 ++++++++++--------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/src/renderer/src/views/classTask/teachClassTask.vue b/src/renderer/src/views/classTask/teachClassTask.vue index d0be63a..3f593ea 100644 --- a/src/renderer/src/views/classTask/teachClassTask.vue +++ b/src/renderer/src/views/classTask/teachClassTask.vue @@ -714,37 +714,39 @@ const closeDialog = () => { // im监听消息回调 const msgHandle = (msg) => { - const { type, data } = msg - switch(type) { - case MsgEnum.HEADS.MSG_closed: // 下课: + if (typeof msg === 'object'){ + const { head, content, ...other } = msg + switch(head) { + case MsgEnum.HEADS.MSG_closed: // 下课: + window.close() // 关闭窗口 + break + case MsgEnum.HEADS.MSG_finishHomework: // 跟新作业: + const data = JSON.parse(localStorage.getItem('teachClassWorkItem')); + openDialog(data, false); + break + case MsgEnum.HEADS.MSG_slideFlapping: // 切换页面 window.close() // 关闭窗口 - break - case MsgEnum.HEADS.MSG_finishHomework: // 跟新作业: - const data = JSON.parse(localStorage.getItem('teachClassWorkItem')); - openDialog(data, false); - break - case MsgEnum.HEADS.MSG_slideFlapping: // 切换页面 - window.close() // 关闭窗口 - break - // case 'TIMAddRecvNewMsgCallback': // 收到新消息 data=[] - // { - // (data||[]).forEach(o => { - // const msgArr = o?.message_elem_array||[] - // msgArr.forEach(info => { - // const msgType = info?.elem_type // 消息类型 TIMElemType - // const msgData = !!info.text_elem_content ? JSON.parse(info.text_elem_content)||'' : '' - // // 处理学生端反馈得消息 - // //console.log('msgData->', msgData); - // if (msgData.msgKey == "finishHomework"){ - // // 刷新 - // const data = JSON.parse(localStorage.getItem('teachClassWorkItem')); - // //console.log('data->', data); - // openDialog(data, false); - // } - // }) - // }) - // } - // break + break + // case 'TIMAddRecvNewMsgCallback': // 收到新消息 data=[] + // { + // (data||[]).forEach(o => { + // const msgArr = o?.message_elem_array||[] + // msgArr.forEach(info => { + // const msgType = info?.elem_type // 消息类型 TIMElemType + // const msgData = !!info.text_elem_content ? JSON.parse(info.text_elem_content)||'' : '' + // // 处理学生端反馈得消息 + // //console.log('msgData->', msgData); + // if (msgData.msgKey == "finishHomework"){ + // // 刷新 + // const data = JSON.parse(localStorage.getItem('teachClassWorkItem')); + // //console.log('data->', data); + // openDialog(data, false); + // } + // }) + // }) + // } + // break + } } } From 5771533039856b5560a0b0d24fb7cd467e378867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E4=BA=86=E4=B8=AA=E7=99=BD?= <543593352@qq.com> Date: Thu, 12 Dec 2024 16:23:28 +0800 Subject: [PATCH 5/9] =?UTF-8?q?ppts:=20=E6=8F=92=E5=85=A5=E8=AF=95?= =?UTF-8?q?=E9=A2=98=20=E5=9B=BE=E7=89=87=E8=B7=AF=E5=BE=84=E5=AD=98?= =?UTF-8?q?=E5=82=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/Editor/CanvasTool/index.vue | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) 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 879865f..18ac469 100644 --- a/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue +++ b/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue @@ -114,7 +114,7 @@ /> - + { // }) } +/** +* base64转图片File +* @param {String} base64 图片base64 +* @param {String} fileName 图片名称| 默认 → myimg +* @returns File 返回转换后的file数据类型 +*/ +const base64ToFile = (base64: string, fileName = '试题图片') => { + // 将base64按照 , 进行分割 将前缀 与后续内容分隔开 + let data = base64.split(','), + // 利用正则表达式 从前缀中获取图片的类型信息(image/png、image/jpeg、image/webp等) + type = data[0].match(/:(.*?);/)[1], + // 从图片的类型信息中 获取具体的文件格式后缀(png、jpeg、webp) + suffix = type.split('/')[1], + // 使用atob()对base64数据进行解码 结果是一个文件数据流 以字符串的格式输出 + bstr = window.atob(data[1]), + // 获取解码结果字符串的长度 + n = bstr.length, + // 根据解码结果字符串的长度创建一个等长的整形数字数组 + // 但在创建时 所有元素初始值都为 0 + u8arr = new Uint8Array(n) + + // 将整形数组的每个元素填充为解码结果字符串对应位置字符的UTF-16 编码单元 + while (n--) { + // charCodeAt():获取给定索引处字符对应的 UTF-16 代码单元 + u8arr[n] = bstr.charCodeAt(n) + } + // 利用构造函数创建File文件对象 + // new File(bits, name, options) + const file = new File([u8arr], `${fileName}.${suffix}`, { + type: type + }) + // 返回file + return file +} + + const onhtml2canvas = async (html: HTMLElement) => { - const ele = await toPng(html); - createImageElement(ele); + const base64Dta = await toPng(html); + const toFile = base64ToFile(base64Dta) + // 上传图片转为线上地址 + PPTApi.toRousrceUrl(toFile).then(data=>{ + createImageElement(data) + }) + // createImageElement(ele); } const shapePoolVisible = ref(false) From 363b284b7c7d2d4565b028bbbc69c99661ad3b26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E4=BA=86=E4=B8=AA=E7=99=BD?= <543593352@qq.com> Date: Thu, 12 Dec 2024 16:34:47 +0800 Subject: [PATCH 6/9] 1 --- .../src/views/Editor/CanvasTool/index.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 18ac469..896f6cf 100644 --- a/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue +++ b/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue @@ -208,6 +208,18 @@ const insertImageElement = (files: FileList) => { // }) } +//获取当前的时间 +const getTime=()=>{ + const now = new Date(); + const year = now.getFullYear(); + const month = ('0' + (now.getMonth() + 1)).slice(-2); + const day = ('0' + now.getDate()).slice(-2); + const hours = ('0' + now.getHours()).slice(-2); + const minutes = ('0' + now.getMinutes()).slice(-2); + const seconds = ('0' + now.getSeconds()).slice(-2); + return `${year}-${month}-${day}_${hours}:${minutes}:${seconds}`; +}; + /** * base64转图片File * @param {String} base64 图片base64 @@ -234,9 +246,10 @@ const base64ToFile = (base64: string, fileName = '试题图片') => { // charCodeAt():获取给定索引处字符对应的 UTF-16 代码单元 u8arr[n] = bstr.charCodeAt(n) } + const filename = fileName+getTime() // 利用构造函数创建File文件对象 // new File(bits, name, options) - const file = new File([u8arr], `${fileName}.${suffix}`, { + const file = new File([u8arr], `${filename}.${suffix}`, { type: type }) // 返回file From c7ebc6de6598458477fe40ea23733b330d2a17c0 Mon Sep 17 00:00:00 2001 From: zhangxuelin <959231531@qq.com> Date: Thu, 12 Dec 2024 16:37:51 +0800 Subject: [PATCH 7/9] 1 --- src/renderer/src/views/classTask/teachClassTask.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/src/views/classTask/teachClassTask.vue b/src/renderer/src/views/classTask/teachClassTask.vue index 3f593ea..2ce9561 100644 --- a/src/renderer/src/views/classTask/teachClassTask.vue +++ b/src/renderer/src/views/classTask/teachClassTask.vue @@ -719,7 +719,7 @@ const msgHandle = (msg) => { switch(head) { case MsgEnum.HEADS.MSG_closed: // 下课: window.close() // 关闭窗口 - break + break case MsgEnum.HEADS.MSG_finishHomework: // 跟新作业: const data = JSON.parse(localStorage.getItem('teachClassWorkItem')); openDialog(data, false); From 7861727e92f61e0a264ae1d049a5d6db073fe61f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9D=A8?= <666> Date: Thu, 12 Dec 2024 16:39:01 +0800 Subject: [PATCH 8/9] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9pptlist?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E7=9A=84bug=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/AixPPTist/src/api/index.ts | 5 +---- .../views/Editor/Toolbar/ElementStylePanel/Active/index.vue | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/renderer/src/AixPPTist/src/api/index.ts b/src/renderer/src/AixPPTist/src/api/index.ts index f54a141..611efb6 100644 --- a/src/renderer/src/AixPPTist/src/api/index.ts +++ b/src/renderer/src/AixPPTist/src/api/index.ts @@ -73,7 +73,6 @@ export class PPTApi { // 活动列表处理 const workList = (res.rows || []).map(o => o.activityContent) const workItem = [...res.rows] - // 加入活动后刷新ppt数据内容,不跟换为第一页 // slidesStore.updateSlideIndex(0) // 下标0 为第一页 slidesStore.setSlides(slides) // 写入数据 // 写入作业列表数据 @@ -110,11 +109,9 @@ export class PPTApi { const rid = await API_entpcoursefile.addEntpcoursefileReturnId(params) if (!!rid) { data.id = rid - params.id = rid - params.activityContent = null - slidesStore.addWorkItem(params) slidesStore.updateSlide(data) // msgUtils.msgSuccess('新增成功') + PPTApi.getSlideList(resource.id) this.isUpdate = false // 新增后会触发监听,不再更新数据 resolve(true) } else msgUtils.msgError('新增失败');resolve(false) diff --git a/src/renderer/src/AixPPTist/src/views/Editor/Toolbar/ElementStylePanel/Active/index.vue b/src/renderer/src/AixPPTist/src/views/Editor/Toolbar/ElementStylePanel/Active/index.vue index d55e688..cddd334 100644 --- a/src/renderer/src/AixPPTist/src/views/Editor/Toolbar/ElementStylePanel/Active/index.vue +++ b/src/renderer/src/AixPPTist/src/views/Editor/Toolbar/ElementStylePanel/Active/index.vue @@ -305,10 +305,10 @@ const upDateData = async () => { // await PPTApi.updateSlide(paramData.value) loadingActive.value = true await updateEntpcoursefileNew(paramData.value) - const res = await homeworklist({ ids: paramData.value.activityContent, pageSize: 100 }) - await formatClassWorkFile(res.rows) const resource = sessionStore.get('curr.resource') await PPTApi.getSlideList(resource.id) + const res = await homeworklist({ ids: paramData.value.activityContent, pageSize: 100 }) + await formatClassWorkFile(res.rows) } // 判断是否做操作 const objectsAreEqual = (obj1: Record, obj2: Record) => { From 308465adb4d18998f831ab924db34b2213f6afbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E4=BA=86=E4=B8=AA=E7=99=BD?= <543593352@qq.com> Date: Thu, 12 Dec 2024 16:44:03 +0800 Subject: [PATCH 9/9] =?UTF-8?q?ppts=EF=BC=9A=2064=E8=BD=ACfile=20=E6=8F=90?= =?UTF-8?q?=E5=8F=96=E5=88=B0utils=20image=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/AixPPTist/src/utils/image.ts | 51 ++++++++++++++++++ .../src/views/Editor/CanvasTool/index.vue | 52 +------------------ 2 files changed, 53 insertions(+), 50 deletions(-) diff --git a/src/renderer/src/AixPPTist/src/utils/image.ts b/src/renderer/src/AixPPTist/src/utils/image.ts index 306ddbc..1336095 100644 --- a/src/renderer/src/AixPPTist/src/utils/image.ts +++ b/src/renderer/src/AixPPTist/src/utils/image.ts @@ -72,4 +72,55 @@ export const isSVGString = (text: string): boolean => { export const svg2File = (svg: string): File => { const blob = new Blob([svg], { type: 'image/svg+xml' }) return new File([blob], `${Date.now()}.svg`, { type: 'image/svg+xml' }) +} + +/** + * 获取当前的时间 + * @returns + */ +export const getTime=()=>{ + const now = new Date(); + const year = now.getFullYear(); + const month = ('0' + (now.getMonth() + 1)).slice(-2); + const day = ('0' + now.getDate()).slice(-2); + const hours = ('0' + now.getHours()).slice(-2); + const minutes = ('0' + now.getMinutes()).slice(-2); + const seconds = ('0' + now.getSeconds()).slice(-2); + return `${year}-${month}-${day}_${hours}:${minutes}:${seconds}`; +}; + +/** +* base64转图片File +* @param {String} base64 图片base64 +* @param {String} fileName 图片名称| 默认 → myimg +* @returns File 返回转换后的file数据类型 +*/ +export const base64ToFile = (base64: string, fileName = '试题图片') => { + // 将base64按照 , 进行分割 将前缀 与后续内容分隔开 + let data = base64.split(','), + // 利用正则表达式 从前缀中获取图片的类型信息(image/png、image/jpeg、image/webp等) + type = data[0].match(/:(.*?);/)[1], + // 从图片的类型信息中 获取具体的文件格式后缀(png、jpeg、webp) + suffix = type.split('/')[1], + // 使用atob()对base64数据进行解码 结果是一个文件数据流 以字符串的格式输出 + bstr = window.atob(data[1]), + // 获取解码结果字符串的长度 + n = bstr.length, + // 根据解码结果字符串的长度创建一个等长的整形数字数组 + // 但在创建时 所有元素初始值都为 0 + u8arr = new Uint8Array(n) + + // 将整形数组的每个元素填充为解码结果字符串对应位置字符的UTF-16 编码单元 + while (n--) { + // charCodeAt():获取给定索引处字符对应的 UTF-16 代码单元 + u8arr[n] = bstr.charCodeAt(n) + } + const filename = fileName+getTime() + // 利用构造函数创建File文件对象 + // new File(bits, name, options) + const file = new File([u8arr], `${filename}.${suffix}`, { + type: type + }) + // 返回file + return file } \ No newline at end of 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 896f6cf..909f7fe 100644 --- a/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue +++ b/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue @@ -141,7 +141,7 @@ import { ref } from 'vue' import { storeToRefs } from 'pinia' import { useMainStore, useSnapshotStore } from '../../../store' -import { getImageDataURL } from '../../../utils/image' +import { getImageDataURL, base64ToFile } from '../../../utils/image' import type { ShapePoolItem } from '../../../configs/shapes' import type { LinePoolItem } from '../../../configs/lines' import useScaleCanvas from '../../../hooks/useScaleCanvas' @@ -208,57 +208,9 @@ const insertImageElement = (files: FileList) => { // }) } -//获取当前的时间 -const getTime=()=>{ - const now = new Date(); - const year = now.getFullYear(); - const month = ('0' + (now.getMonth() + 1)).slice(-2); - const day = ('0' + now.getDate()).slice(-2); - const hours = ('0' + now.getHours()).slice(-2); - const minutes = ('0' + now.getMinutes()).slice(-2); - const seconds = ('0' + now.getSeconds()).slice(-2); - return `${year}-${month}-${day}_${hours}:${minutes}:${seconds}`; -}; - -/** -* base64转图片File -* @param {String} base64 图片base64 -* @param {String} fileName 图片名称| 默认 → myimg -* @returns File 返回转换后的file数据类型 -*/ -const base64ToFile = (base64: string, fileName = '试题图片') => { - // 将base64按照 , 进行分割 将前缀 与后续内容分隔开 - let data = base64.split(','), - // 利用正则表达式 从前缀中获取图片的类型信息(image/png、image/jpeg、image/webp等) - type = data[0].match(/:(.*?);/)[1], - // 从图片的类型信息中 获取具体的文件格式后缀(png、jpeg、webp) - suffix = type.split('/')[1], - // 使用atob()对base64数据进行解码 结果是一个文件数据流 以字符串的格式输出 - bstr = window.atob(data[1]), - // 获取解码结果字符串的长度 - n = bstr.length, - // 根据解码结果字符串的长度创建一个等长的整形数字数组 - // 但在创建时 所有元素初始值都为 0 - u8arr = new Uint8Array(n) - - // 将整形数组的每个元素填充为解码结果字符串对应位置字符的UTF-16 编码单元 - while (n--) { - // charCodeAt():获取给定索引处字符对应的 UTF-16 代码单元 - u8arr[n] = bstr.charCodeAt(n) - } - const filename = fileName+getTime() - // 利用构造函数创建File文件对象 - // new File(bits, name, options) - const file = new File([u8arr], `${filename}.${suffix}`, { - type: type - }) - // 返回file - return file -} - - const onhtml2canvas = async (html: HTMLElement) => { const base64Dta = await toPng(html); + // base64转图片File const toFile = base64ToFile(base64Dta) // 上传图片转为线上地址 PPTApi.toRousrceUrl(toFile).then(data=>{