From a8f9c828d775223806e5c3b8b32e24344bb2521f Mon Sep 17 00:00:00 2001 From: zhangxuelin <959231531@qq.com> Date: Thu, 8 Aug 2024 14:27:22 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/views/classBegins/index.vue | 3 ++- src/renderer/src/views/prepare/index.vue | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/views/classBegins/index.vue b/src/renderer/src/views/classBegins/index.vue index 188c790..6d4c402 100644 --- a/src/renderer/src/views/classBegins/index.vue +++ b/src/renderer/src/views/classBegins/index.vue @@ -107,7 +107,8 @@ const switchPageMode = () => { } onMounted(async () => { toolState.isPdfWin=true - console.log(toolState.showBoardAll,"c初始") + console.log(route.query.path,"c初始") + pdfObj.pdfUrl = route.query.path textbookId.value = route.query.textbookId pdfObj.bookId=textbookId.value getBookMarkById(textbookId.value).then(res=>{ diff --git a/src/renderer/src/views/prepare/index.vue b/src/renderer/src/views/prepare/index.vue index 3aad3db..6ba4d24 100644 --- a/src/renderer/src/views/prepare/index.vue +++ b/src/renderer/src/views/prepare/index.vue @@ -537,10 +537,10 @@ export default { async navtoPdf() { const toolStore = useToolState() if (toolStore.isPdfWin) return this.$message.error('您当前已打开课本,请勿重复操作') - // let path = await this.getBookPathFromServer() - // console.log(path) + let path = await this.getBookPathFromServer() + console.log(path) // console.log(this.uploadData.textbookId) - createWindow('open-PDF', { url: '/classBegins/index?textbookId='+this.uploadData.textbookId }) + createWindow('open-PDF', { url: '/classBegins/index?textbookId='+this.uploadData.textbookId+'&path='+ path }) }, // 上课-工具类悬浮 openLesson() { From e1e9f171e0c63d501364103f64a0d9124620abbe Mon Sep 17 00:00:00 2001 From: zhangxuelin <959231531@qq.com> Date: Thu, 8 Aug 2024 16:50:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=9C=AC=E5=9C=B0pdf?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/components/pdf/index.vue | 1 + src/renderer/src/views/classBegins/index.vue | 6 +++--- src/renderer/src/views/prepare/index.vue | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/components/pdf/index.vue b/src/renderer/src/components/pdf/index.vue index 5c7cf13..1447c37 100644 --- a/src/renderer/src/components/pdf/index.vue +++ b/src/renderer/src/components/pdf/index.vue @@ -274,6 +274,7 @@ const initPdfone = async () => { } onMounted(async () => { try { + console.log(props.pdfObj.pdfUrl) // 创建canvas转化成图片 const pdf = await pdfjsLib.getDocument(props.pdfObj.pdfUrl).promise numPagesTotal.value = pdf.numPages diff --git a/src/renderer/src/views/classBegins/index.vue b/src/renderer/src/views/classBegins/index.vue index 6d4c402..5fc078a 100644 --- a/src/renderer/src/views/classBegins/index.vue +++ b/src/renderer/src/views/classBegins/index.vue @@ -50,7 +50,8 @@ const isOnLoadShow = ref(false) //加载完毕显示 // 传过去的参数 const pdfObj = reactive({ numberOfPdf: 2, //显示几页 - pdfUrl: getStaticUrl('aaa.pdf', 'user', 'selfFile', true), + // pdfUrl: getStaticUrl('aaa.pdf', 'user', 'selfFile', true),//本地 + pdfUrl: null, allPageData:[], bookId:null, numPages: 1 //当前页数 @@ -107,8 +108,7 @@ const switchPageMode = () => { } onMounted(async () => { toolState.isPdfWin=true - console.log(route.query.path,"c初始") - pdfObj.pdfUrl = route.query.path + pdfObj.pdfUrl = getStaticUrl(route.query.path, 'user', 'selfFile', true) textbookId.value = route.query.textbookId pdfObj.bookId=textbookId.value getBookMarkById(textbookId.value).then(res=>{ diff --git a/src/renderer/src/views/prepare/index.vue b/src/renderer/src/views/prepare/index.vue index 6ba4d24..1385e10 100644 --- a/src/renderer/src/views/prepare/index.vue +++ b/src/renderer/src/views/prepare/index.vue @@ -538,7 +538,7 @@ export default { const toolStore = useToolState() if (toolStore.isPdfWin) return this.$message.error('您当前已打开课本,请勿重复操作') let path = await this.getBookPathFromServer() - console.log(path) + path=path.replace(/^.*[\\\/]/, ''); // console.log(this.uploadData.textbookId) createWindow('open-PDF', { url: '/classBegins/index?textbookId='+this.uploadData.textbookId+'&path='+ path }) }, From 964e99c186120793c7bae3f68a2209fdba668909 Mon Sep 17 00:00:00 2001 From: zhangxuelin <959231531@qq.com> Date: Thu, 8 Aug 2024 17:02:18 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=B8=8D=E6=89=93=E5=BC=80=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=A0=8F=E4=B8=8D=E5=85=81=E8=AE=B8=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/components/pdf/index.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/pdf/index.vue b/src/renderer/src/components/pdf/index.vue index 1447c37..c686d14 100644 --- a/src/renderer/src/components/pdf/index.vue +++ b/src/renderer/src/components/pdf/index.vue @@ -120,6 +120,13 @@ const renderPage = async (canvasobj) => { } // 保存数据 const savaDataStore = () => { + if(!toolState.isToolWin){ + toolState.isPdfWin=false + toolState.showBoardAll=true //恢复默认值 + ipcRenderer.invoke('tool-sphere:reset') //重置tool状态 + ipcRenderer.send('open-PDF:minimize') + return + } imgarr.value.forEach((a) => { if (a.index == 0) { a.JSONdata = canvasFabricVue.value.canvas.toJSON() @@ -170,7 +177,8 @@ const initPdf = async (type = 'default') => { a.JSONdata = canvas1FabricVue.value.canvas.toJSON() } }) - if (type != 'default') { + // 判断是否翻页以及工具窗口是否打开 满足 翻页+打开工具才能保存数据 + if (type != 'default' && toolState.isToolWin) { const nameMap = new Map(canvsStore.pageArr.map((item) => [item.page, item.id])) // 创建一个用于存储所有异步操作的数组 let promises = [] @@ -274,7 +282,6 @@ const initPdfone = async () => { } onMounted(async () => { try { - console.log(props.pdfObj.pdfUrl) // 创建canvas转化成图片 const pdf = await pdfjsLib.getDocument(props.pdfObj.pdfUrl).promise numPagesTotal.value = pdf.numPages