From 1004567103ec86b9ff9ede705feb107e787375e0 Mon Sep 17 00:00:00 2001 From: zhangxuelin <959231531@qq.com> Date: Fri, 26 Jul 2024 13:57:04 +0800 Subject: [PATCH] =?UTF-8?q?pdf=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/utils/tool.js | 21 ++++++++++++++++++++ src/renderer/src/views/classBegins/index.vue | 8 ++++++-- src/renderer/src/views/prepare/index.vue | 9 +++++++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/utils/tool.js b/src/renderer/src/utils/tool.js index 55070f4..69a267a 100644 --- a/src/renderer/src/utils/tool.js +++ b/src/renderer/src/utils/tool.js @@ -3,6 +3,8 @@ */ // const { ipcRenderer } = window.electron || {} // import { ipcRenderer } from 'electron' // 渲染器里面可以使用ipcRenderer + + // const path = require('path') const Remote = require('@electron/remote') @@ -61,6 +63,21 @@ export const createWindow = async (type, data) => { eventHandles(type, win) // 事件监听处理 return win } + case 'open-PDF': { //课本展示-pdf + const option = data.option||{} + const defOption = { + frame: false, // 要创建无边框窗口 + resizable: true, // 禁止窗口大小缩放 + alwaysOnTop: false, // 窗口是否总是显示在其他窗口之前 + } + data.option = {...defOption, ...option} + const win = await toolWindow(data) + + win.show() + win.setFullScreen(true) // 设置窗口为全屏 + eventHandles(type, win) // 事件监听处理 + break + } default: break } @@ -140,6 +157,10 @@ const eventHandles = (type, win) => { } publicMethods(on) // 加载公共方法 break} + case 'open-PDF': { + // 最小化窗口 + Remote.ipcMain.once('open-PDF:minimize', () => {win.minimize()}) + break} default: break } diff --git a/src/renderer/src/views/classBegins/index.vue b/src/renderer/src/views/classBegins/index.vue index 26e226d..59a844f 100644 --- a/src/renderer/src/views/classBegins/index.vue +++ b/src/renderer/src/views/classBegins/index.vue @@ -26,6 +26,7 @@ 下一页 + 最小化 @@ -35,7 +36,7 @@ import { ref, onMounted, watch, reactive } from 'vue' import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf' pdfjsLib.GlobalWorkerOptions.workerSrc = '/lib/build/pdf.worker.mjs' import pdfCanvas from '@/components/pdf/index.vue' - +const { ipcRenderer } = require('electron') // 传过去的参数 const pdfObj = reactive({ numberOfPdf: 2, //显示几页 @@ -58,7 +59,10 @@ const navtopage = (type) => { if (pdfObj.numPages > numPagesTotal.value) return pdfCanvaslist.value.initPdf() } - +// 最小化窗口 +const minimize = () => { + ipcRenderer.send('open-PDF:minimize') +} const handleUpdate = (data) => { numPagesTotal.value = data if (numPagesTotal.value == 1) { diff --git a/src/renderer/src/views/prepare/index.vue b/src/renderer/src/views/prepare/index.vue index 9ae9fef..7119f9a 100644 --- a/src/renderer/src/views/prepare/index.vue +++ b/src/renderer/src/views/prepare/index.vue @@ -8,7 +8,7 @@
课标研读 - 电子课本 + 电子课本 高考研读 教学大模型
@@ -74,7 +74,7 @@ import { ElMessage } from 'element-plus' import { parseCataByNode, creatPPT, asyncLocalFile } from '@/utils/talkFile' import FileOperBatch from '@/views/prepare/container/file-oper-batch.vue' import outLink from '@/utils/linkConfig' - +import { createWindow } from '@/utils/tool' const { ipcRenderer } = window.electron || {} export default { @@ -260,6 +260,11 @@ export default { cookieData: {...(configObj.data)} }) }, + navtoPdf() { + const params = { url: '/classBegins/index' } + createWindow('open-PDF', params) + + } } }