From d91f08d398f823d8390bccf6c574e426e46fc7ba Mon Sep 17 00:00:00 2001 From: lyc Date: Tue, 23 Jul 2024 13:46:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=B8=83=E7=BD=AE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/index.js | 35 ++++++++++-------------- src/renderer/src/utils/config.js | 9 ++++++ src/renderer/src/views/prepare/index.vue | 22 +++++++++++++-- 3 files changed, 42 insertions(+), 24 deletions(-) create mode 100644 src/renderer/src/utils/config.js diff --git a/src/main/index.js b/src/main/index.js index 03fe72a..c3e9cd0 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -41,7 +41,7 @@ function createMainWindow() { width: 1200, height: 700, show: false, - frame: false, + frame: false,// 无边框 autoHideMenuBar: true, ...(process.platform === 'linux' ? { icon } : {}), webPreferences: { @@ -68,15 +68,15 @@ function createMainWindow() { } // 作业窗口相关-开发中 -let workWindow -function createWork(data) { - if (workWindow) return - workWindow = new BrowserWindow({ +let openWindow +function createOpenWin(data) { + if (openWindow) return + openWindow = new BrowserWindow({ width: 650, height: 500, show: false, frame: true, - + maximizable: true, autoHideMenuBar: true, ...(process.platform === 'linux' ? { icon } : {}), webPreferences: { @@ -85,13 +85,8 @@ function createWork(data) { } }) - workWindow.webContents.session.cookies.set( - { - url: 'https://file.ysaix.com:7868', - name: 'Admin-Token', - value: data - }, - function (error) { + openWindow.webContents.session.cookies.set({...data.cookieData}, + (error)=> { if (error) { console.error('Set cookie failed:', error) } else { @@ -99,15 +94,13 @@ function createWork(data) { } } ) - workWindow.loadURL( - 'https://file.ysaix.com:7868/teaching/classtaskassign?titleName=%E4%BD%9C%E4%B8%9A%E5%B8%83%E7%BD%AE' - ) + openWindow.loadURL(data.fullPath) - workWindow.once('ready-to-show', () => { - workWindow.show() + openWindow.once('ready-to-show', () => { + openWindow.show() }) - workWindow.on('closed', () => { - workWindow = null + openWindow.on('closed', () => { + openWindow = null }) } @@ -165,7 +158,7 @@ app.on('ready', () => { //打开作业窗口 ipcMain.on('openWork', (e, data) => { - createWork(data) + createOpenWin(data) }) createLoginWindow() diff --git a/src/renderer/src/utils/config.js b/src/renderer/src/utils/config.js new file mode 100644 index 0000000..947dd1b --- /dev/null +++ b/src/renderer/src/utils/config.js @@ -0,0 +1,9 @@ + +// 作业 +export const homeWorkConfig = { + // host 设置token 等 + host: 'https://file.ysaix.com:7868', + name: 'Admin-Token', + // 完整路径 + fullPath: 'https://file.ysaix.com:7868/teaching/classtaskassign?titleName=%E4%BD%9C%E4%B8%9A%E5%B8%83%E7%BD%AE' +} \ No newline at end of file diff --git a/src/renderer/src/views/prepare/index.vue b/src/renderer/src/views/prepare/index.vue index 52de477..57274f8 100644 --- a/src/renderer/src/views/prepare/index.vue +++ b/src/renderer/src/views/prepare/index.vue @@ -37,7 +37,7 @@
- 布置作业 + 布置作业 上传资料 新建课件
@@ -73,7 +73,10 @@ import { toTimeText } from '@/utils/date' import { ElMessage } from 'element-plus' import { isHaveLocalFile, parseCataByNode, creatPPT } from '@/utils/talkFile' import FileOperBatch from '@/views/prepare/container/file-oper-batch.vue' +import useUserStore from '@/store/modules/user' +import { homeWorkConfig } from '@/utils/config' const { ipcRenderer } = window.electron || {} + export default { name: 'Prepare', components: { ChooseTextbook, Refresh, uploadDialog, FileListItem, FileOperBatch, MoveFile }, @@ -98,7 +101,8 @@ export default { fileRoot: '备课' }, // 当前教材封面图 - curBookImg: '' + curBookImg: '', + userStore: '' } }, computed: { @@ -114,6 +118,7 @@ export default { this.callback(param) }) this.lastAsyncAllTime = localStorage.getItem('lastAsyncAllTime') + this.userStore = useUserStore() }, mounted() { // const destination = '0901高一【数学(人教A版)】集合的概念-PPT课件.pptx' @@ -279,7 +284,18 @@ export default { console.log(res) this.isLoading = false }) - } + }, + // 布置组后也 + handleHomeWork(){ + ipcRenderer.send('openWork',{ + fullPath: homeWorkConfig.fullPath, + cookieData: { + url: homeWorkConfig.host, + name: homeWorkConfig.name, + value: this.userStore.token + } + }) + }, } } From 5712e77a293b94ae83c1d81385cc9fd215ccee54 Mon Sep 17 00:00:00 2001 From: lyc Date: Tue, 23 Jul 2024 14:08:00 +0800 Subject: [PATCH 2/2] openwindow --- src/main/index.js | 17 +++++++---------- src/renderer/src/views/prepare/index.vue | 1 - 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index c3e9cd0..56a0833 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -84,16 +84,13 @@ function createOpenWin(data) { nodeIntegration: true } }) - - openWindow.webContents.session.cookies.set({...data.cookieData}, - (error)=> { - if (error) { - console.error('Set cookie failed:', error) - } else { - console.log('Cookie set successfully.') - } - } - ) + let cookieDetails = {...data.cookieData} + openWindow.webContents.session.cookies.set(cookieDetails).then(()=>{ + console.log('Cookie set successfully.') + }).catch(err =>{ + console.error('Set cookie failed:', error) + }) + openWindow.loadURL(data.fullPath) openWindow.once('ready-to-show', () => { diff --git a/src/renderer/src/views/prepare/index.vue b/src/renderer/src/views/prepare/index.vue index 4644524..6ce62f1 100644 --- a/src/renderer/src/views/prepare/index.vue +++ b/src/renderer/src/views/prepare/index.vue @@ -276,7 +276,6 @@ export default { nodeClick(data) { if (this.currentNode.id === data.node.id) return this.curBookImg = data.textBook.curBookImg - console.log(data.textBook) this.checkFileList = [] let cata = parseCataByNode(data.node) this.currentNode = data.node