Compare commits
No commits in common. "5f05ad8bea3b1170fe70477f8cc5805febdfe80e" and "d72d0ae956605bc44069680a03ed2c7e6a7376b7" have entirely different histories.
5f05ad8bea
...
d72d0ae956
|
@ -1,4 +1,4 @@
|
||||||
import { app, shell, BrowserWindow, ipcMain, session } from 'electron'
|
import { app, shell, BrowserWindow, ipcMain } from 'electron'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
||||||
import icon from '../../resources/icon.png?asset'
|
import icon from '../../resources/icon.png?asset'
|
||||||
|
@ -9,8 +9,8 @@ File({ app, shell, BrowserWindow, ipcMain })
|
||||||
let mainWindow, loginWindow
|
let mainWindow, loginWindow
|
||||||
|
|
||||||
//登录窗口
|
//登录窗口
|
||||||
function createLoginWindow() {
|
function createLoginWindow(){
|
||||||
if (loginWindow) return
|
if(loginWindow) return
|
||||||
loginWindow = new BrowserWindow({
|
loginWindow = new BrowserWindow({
|
||||||
width: 888,
|
width: 888,
|
||||||
height: 520,
|
height: 520,
|
||||||
|
@ -23,6 +23,7 @@ function createLoginWindow() {
|
||||||
sandbox: false,
|
sandbox: false,
|
||||||
nodeIntegration: true
|
nodeIntegration: true
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
const loginURL = is.dev ? `http://localhost:5173/#/login` : `file://${__dirname}/index.html/login`
|
const loginURL = is.dev ? `http://localhost:5173/#/login` : `file://${__dirname}/index.html/login`
|
||||||
loginWindow.loadURL(loginURL)
|
loginWindow.loadURL(loginURL)
|
||||||
|
@ -67,52 +68,8 @@ function createMainWindow() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 作业窗口相关-开发中
|
|
||||||
let workWindow
|
|
||||||
function createWork(data) {
|
|
||||||
if (workWindow) return
|
|
||||||
workWindow = new BrowserWindow({
|
|
||||||
width: 650,
|
|
||||||
height: 500,
|
|
||||||
show: false,
|
|
||||||
frame: true,
|
|
||||||
|
|
||||||
autoHideMenuBar: true,
|
|
||||||
...(process.platform === 'linux' ? { icon } : {}),
|
|
||||||
webPreferences: {
|
|
||||||
sandbox: false,
|
|
||||||
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()
|
|
||||||
})
|
|
||||||
workWindow.on('closed', () => {
|
|
||||||
workWindow = null
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 初始化完成
|
// 初始化完成
|
||||||
app.on('ready', () => {
|
app.on('ready',()=>{
|
||||||
// 设置应用程序用户模型标识符
|
// 设置应用程序用户模型标识符
|
||||||
electronApp.setAppUserModelId('com.electron')
|
electronApp.setAppUserModelId('com.electron')
|
||||||
|
|
||||||
|
@ -129,12 +86,12 @@ app.on('ready', () => {
|
||||||
if (mainWindow) {
|
if (mainWindow) {
|
||||||
mainWindow.minimize()
|
mainWindow.minimize()
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
ipcMain.on('maximize-window', () => {
|
ipcMain.on('maximize-window', () => {
|
||||||
mainWindow.isMaximized() ? mainWindow.unmaximize() : mainWindow.maximize()
|
mainWindow.isMaximized() ? mainWindow.unmaximize() : mainWindow.maximize();
|
||||||
})
|
});
|
||||||
|
|
||||||
ipcMain.on('close-window', () => {
|
ipcMain.on('close-window', () => {
|
||||||
if (loginWindow) {
|
if (loginWindow) {
|
||||||
loginWindow.destroy()
|
loginWindow.destroy()
|
||||||
|
@ -142,14 +99,15 @@ app.on('ready', () => {
|
||||||
if (mainWindow) {
|
if (mainWindow) {
|
||||||
mainWindow.destroy()
|
mainWindow.destroy()
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
// 打开主窗口
|
// 打开主窗口
|
||||||
ipcMain.on('openMainWindow', () => {
|
ipcMain.on('openMainWindow', () => {
|
||||||
if (!mainWindow) {
|
if (!mainWindow) {
|
||||||
createMainWindow()
|
createMainWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
loginWindow.destroy()
|
loginWindow.destroy()
|
||||||
loginWindow = null
|
loginWindow = null
|
||||||
})
|
})
|
||||||
|
@ -163,17 +121,15 @@ app.on('ready', () => {
|
||||||
loginWindow.focus()
|
loginWindow.focus()
|
||||||
})
|
})
|
||||||
|
|
||||||
//打开作业窗口
|
|
||||||
ipcMain.on('openWork', (e, data) => {
|
|
||||||
createWork(data)
|
|
||||||
})
|
|
||||||
|
|
||||||
createLoginWindow()
|
createLoginWindow()
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
if (BrowserWindow.getAllWindows().length === 0) createLoginWindow()
|
if (BrowserWindow.getAllWindows().length === 0) createLoginWindow()
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Quit when all windows are closed, except on macOS. There, it's common
|
// Quit when all windows are closed, except on macOS. There, it's common
|
||||||
// for applications and their menu bar to stay active until the user quits
|
// for applications and their menu bar to stay active until the user quits
|
||||||
// explicitly with Cmd + Q.
|
// explicitly with Cmd + Q.
|
||||||
|
|
Loading…
Reference in New Issue