create-electron-base 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import { app,
|
|
1
|
+
import { app, ipcMain } from 'electron'
|
|
2
2
|
import { join } from 'node:path'
|
|
3
|
-
import { bootstrap, createWindow, logger } from '@thirty-coder/electron-base-kit'
|
|
3
|
+
import { bootstrap, createWindow, getWindow, logger } from '@thirty-coder/electron-base-kit'
|
|
4
4
|
import type { AppConfig } from '@thirty-coder/electron-base-kit'
|
|
5
5
|
import config from '../app.config.json'
|
|
6
6
|
import { prefs } from './modules/preferences'
|
|
7
7
|
|
|
8
|
-
let mainWindow: BrowserWindow | null = null
|
|
9
|
-
|
|
10
8
|
function openMainWindow() {
|
|
11
|
-
|
|
9
|
+
createWindow({
|
|
12
10
|
preload: join(__dirname, '../preload/preload.js'),
|
|
13
11
|
renderer: join(__dirname, '../renderer/index.html'),
|
|
14
12
|
})
|
|
15
|
-
|
|
16
|
-
mainWindow.on('closed', () => {
|
|
17
|
-
mainWindow = null
|
|
18
|
-
})
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
app.whenReady().then(() => {
|
|
22
|
-
|
|
16
|
+
// 返回 false 表示已有实例在跑,本进程正在退出
|
|
17
|
+
if (!bootstrap(config as AppConfig)) return
|
|
23
18
|
|
|
24
19
|
// 日志写到 <userData>/logs/<日期>.log,按模块分来源用 logger.child('window')
|
|
25
20
|
logger.info('应用启动', { version: app.getVersion() })
|
|
@@ -32,7 +27,7 @@ app.whenReady().then(() => {
|
|
|
32
27
|
openMainWindow()
|
|
33
28
|
|
|
34
29
|
app.on('activate', () => {
|
|
35
|
-
if (
|
|
30
|
+
if (!getWindow('main')) openMainWindow()
|
|
36
31
|
})
|
|
37
32
|
})
|
|
38
33
|
|