-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_step5.cjs
More file actions
50 lines (41 loc) · 1.4 KB
/
test_step5.cjs
File metadata and controls
50 lines (41 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const { app, BrowserWindow } = require('electron');
const log = require('electron-log'); // 新增: 导入 electron-log
class WindowManager {
constructor() {
this.mainWindow = null;
}
async createMainWindow() {
const preloadPath = '/Users/gzp/Github/anime1-desktop-electron/dist-electron/preload/index.cjs';
console.log('[WM] Step 5: With electron-log import');
this.mainWindow = new BrowserWindow({
width: 1200,
height: 800,
title: 'Anime1 Desktop',
titleBarStyle: process.platform === 'darwin' ? 'hiddenInset' : 'default',
show: false,
webPreferences: {
preload: preloadPath,
contextIsolation: true,
nodeIntegration: false,
sandbox: false,
allowRunningInsecureContent: true
}
});
this.mainWindow.webContents.openDevTools();
this.mainWindow.webContents.on('preload-error', (event, preloadPath, error) => {
console.error('[WM] Preload error:', preloadPath, error);
});
this.mainWindow.loadURL('http://localhost:5173/');
this.mainWindow.once('ready-to-show', () => {
this.mainWindow.show();
console.log('[WM] Window shown');
});
this.mainWindow.webContents.on('console-message', (e) => {
console.log('[Console]', e.message);
});
}
}
app.whenReady().then(async () => {
const wm = new WindowManager();
await wm.createMainWindow();
});