From e6da6ef65f86c09a1d310da32caecd7924a2081e Mon Sep 17 00:00:00 2001 From: lyc Date: Wed, 24 Jul 2024 14:03:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=BC=80=E5=A4=96=E9=83=A8=E9=93=BE?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/index.js | 51 +++++++++++-------- .../src/components/select-subject/index.vue | 12 +++-- src/renderer/src/utils/config.js | 9 ---- src/renderer/src/utils/linkConfig.js | 40 +++++++++++++++ src/renderer/src/views/login/index.vue | 6 +-- src/renderer/src/views/prepare/index.vue | 32 ++++++------ 6 files changed, 93 insertions(+), 57 deletions(-) delete mode 100644 src/renderer/src/utils/config.js create mode 100644 src/renderer/src/utils/linkConfig.js diff --git a/src/main/index.js b/src/main/index.js index 2fce314..92cbb87 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -4,8 +4,10 @@ import { electronApp, optimizer, is } from '@electron-toolkit/utils' import icon from '../../resources/icon.png?asset' import File from './file' -File({ app, shell, BrowserWindow, ipcMain }) +// const handleUpdate = require("./handleUpdate"); +File({ app, shell, BrowserWindow, ipcMain }) +process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true' let mainWindow, loginWindow //登录窗口 @@ -24,9 +26,13 @@ function createLoginWindow() { nodeIntegration: true } }) - const loginURL = is.dev ? `http://localhost:5173/#/login` : `file://${__dirname}/index.html/login` + // handleUpdate(loginWindow,ipcMain) + const loginURL = is.dev ? `http://localhost:5173/#/login` : join(__dirname, '../renderer/index.html') loginWindow.loadURL(loginURL) + + + loginWindow.webContents.openDevTools() loginWindow.once('ready-to-show', () => { loginWindow.show() }) @@ -61,17 +67,18 @@ function createMainWindow() { mainWindow.webContents.openDevTools() if (is.dev && process.env['ELECTRON_RENDERER_URL']) { - mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL']) + mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL'] ) } else { mainWindow.loadFile(join(__dirname, '../renderer/index.html')) } } + // 作业窗口相关-开发中 -let openWindow -function createOpenWin(data) { - if (openWindow) return - openWindow = new BrowserWindow({ +let linkWindow +async function createLinkWin(data) { + if (linkWindow) return + linkWindow = new BrowserWindow({ width: 650, height: 500, show: false, @@ -81,26 +88,26 @@ function createOpenWin(data) { ...(process.platform === 'linux' ? { icon } : {}), webPreferences: { sandbox: false, - nodeIntegration: true + nodeIntegration: true, + worldSafeExecuteJavaScript: true, + contextIsolation: true } }) let cookieDetails = { ...data.cookieData } - console.log(cookieDetails) - openWindow.webContents.session.cookies.set(cookieDetails, (error) => { - if (error) { - console.error('设置cookie出错:', error) - } else { - console.log('设置cookie成功') - } + await linkWindow.webContents.session.cookies.set(cookieDetails).then(()=>{ + console.log('Cookie is successful'); + }).catch( error =>{ + console.error('Cookie is error', error); }) - openWindow.loadURL(data.fullPath) + linkWindow.loadURL(data.fullPath) - openWindow.once('ready-to-show', () => { - openWindow.show() + linkWindow.once('ready-to-show', () => { + linkWindow.show() + linkWindow.maximize() }) - openWindow.on('closed', () => { - openWindow = null + linkWindow.on('closed', () => { + linkWindow = null }) } @@ -158,8 +165,8 @@ app.on('ready', () => { }) //打开作业窗口 - ipcMain.on('openWork', (e, data) => { - createOpenWin(data) + ipcMain.on('openWindow', (e, data) => { + createLinkWin(data) }) createLoginWindow() diff --git a/src/renderer/src/components/select-subject/index.vue b/src/renderer/src/components/select-subject/index.vue index d70c423..649337a 100644 --- a/src/renderer/src/components/select-subject/index.vue +++ b/src/renderer/src/components/select-subject/index.vue @@ -79,10 +79,6 @@ const subjectList = ref([]) const allSubject = ref([]) const dialogVisible = ref(false) -watch(() => props.modelValue, (newVal) => { - dialogVisible.value = newVal -}) - //切换年级 const changeGrade = ()=>{ // 切换年级 过滤出对应学科数据 @@ -120,8 +116,13 @@ const editUserInfo = async () =>{ emit('onSuccess') } +watch(() => props.modelValue, (newVal) => { + dialogVisible.value = newVal + if(newVal){ + getSubject() + } +}) -onMounted(getSubject) diff --git a/src/renderer/src/views/prepare/index.vue b/src/renderer/src/views/prepare/index.vue index 9a04fdc..7d1954f 100644 --- a/src/renderer/src/views/prepare/index.vue +++ b/src/renderer/src/views/prepare/index.vue @@ -7,9 +7,9 @@
- 教材研读 - 电子课本 - 高考研读 + 课标研读 + 电子课本 + 高考研读 教学大模型
@@ -37,7 +37,7 @@
- 布置作业 + 布置作业 上传资料 新建课件
@@ -73,8 +73,8 @@ import { toTimeText } from '@/utils/date' import { ElMessage } from 'element-plus' import { parseCataByNode, creatPPT, asyncLocalFile } from '@/utils/talkFile' import FileOperBatch from '@/views/prepare/container/file-oper-batch.vue' -import useUserStore from '@/store/modules/user' -import { homeWorkConfig } from '@/utils/config' + +import outLink from '@/utils/linkConfig' const { ipcRenderer } = window.electron || {} export default { @@ -102,7 +102,6 @@ export default { }, // 当前教材封面图 curBookImg: '', - userStore: '' } }, computed: { @@ -118,7 +117,7 @@ export default { this.callback(param) }) this.lastAsyncAllTime = localStorage.getItem('lastAsyncAllTime') - this.userStore = useUserStore() + }, mounted() { }, @@ -251,15 +250,14 @@ export default { this.uploadData.textbookId = data.textBook.curBookId this.asyncAllFile() }, - // 布置组后也 - handleHomeWork(){ - ipcRenderer.send('openWork',{ - fullPath: homeWorkConfig.fullPath, - cookieData: { - url: homeWorkConfig.host, - name: homeWorkConfig.name, - value: this.userStore.token - } + // 打开外部链接 + handleOutLink(key){ + // key 对应的 linkConfig.js 外部链接配置 + let configObj = outLink[key] + // 通知主进程 + ipcRenderer.send('openWindow', { + fullPath: configObj.fullPath, + cookieData: {...(configObj.data)} }) }, }