|
@@ -0,0 +1,37 @@
|
|
|
+const { app, BrowserWindow, screen } = require('electron')
|
|
|
+const path = require('path')
|
|
|
+
|
|
|
+const createWindow = () => {
|
|
|
+ // 获取主显示器的尺寸
|
|
|
+ const primaryDisplay = screen.getPrimaryDisplay()
|
|
|
+ const { width, height } = primaryDisplay.workAreaSize
|
|
|
+
|
|
|
+ const win = new BrowserWindow({
|
|
|
+ width: width,
|
|
|
+ height: height,
|
|
|
+ webPreferences: {
|
|
|
+ contextIsolation: true,
|
|
|
+ nodeIntegration: false
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // 将窗口位置设置为(0,0),确保它位于屏幕左上角
|
|
|
+ win.setPosition(0, 0)
|
|
|
+
|
|
|
+ win.loadFile(path.join(__dirname, '../dist/index.html'))
|
|
|
+}
|
|
|
+
|
|
|
+app.whenReady().then(() => {
|
|
|
+ createWindow()
|
|
|
+ app.on('activate', () => {
|
|
|
+ if (BrowserWindow.getAllWindows().length === 0) {
|
|
|
+ createWindow()
|
|
|
+ }
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+app.on('window-all-closed', () => {
|
|
|
+ if (process.platform !== 'darwin') {
|
|
|
+ app.quit()
|
|
|
+ }
|
|
|
+})
|