diff --git a/src/main/index.js b/src/main/index.js index 03fe72a..56a0833 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: { @@ -84,30 +84,20 @@ function createWork(data) { nodeIntegration: true } }) - - workWindow.webContents.session.cookies.set( - { - url: 'https://file.ysaix.com:7868', - name: 'Admin-Token', - value: data - }, - function (error) { - if (error) { - console.error('Set cookie failed:', error) - } else { - console.log('Cookie set successfully.') - } - } - ) - workWindow.loadURL( - 'https://file.ysaix.com:7868/teaching/classtaskassign?titleName=%E4%BD%9C%E4%B8%9A%E5%B8%83%E7%BD%AE' - ) - - workWindow.once('ready-to-show', () => { - workWindow.show() + let cookieDetails = {...data.cookieData} + openWindow.webContents.session.cookies.set(cookieDetails).then(()=>{ + console.log('Cookie set successfully.') + }).catch(err =>{ + console.error('Set cookie failed:', error) }) - workWindow.on('closed', () => { - workWindow = null + + openWindow.loadURL(data.fullPath) + + openWindow.once('ready-to-show', () => { + openWindow.show() + }) + openWindow.on('closed', () => { + openWindow = null }) } @@ -165,7 +155,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 0038f3b..9a04fdc 100644 --- a/src/renderer/src/views/prepare/index.vue +++ b/src/renderer/src/views/prepare/index.vue @@ -37,7 +37,7 @@