-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
68 lines (59 loc) · 1.82 KB
/
main.js
File metadata and controls
68 lines (59 loc) · 1.82 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// 이거 import로 바꿔도 됨?
// const { app, BrowserWindow, ipcMain } = require('electron');
const { app, BrowserWindow } = require('electron');
const path = require('path');
// const fs = require('fs');
// 임시
const remoteMain = require('@electron/remote/main');
remoteMain.initialize();
// 지정된 크기, 설정으로 window를 생성하고 index.html을 로드
function createWindow() {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
// 이게 뭔데
// preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true,
contextIsolation: false,
// contextIsolation: true, // contextIsolation 활성화
// enableRemoteModule: false, // 필요 시 추가
// nodeIntegration: true,
},
});
remoteMain.enable(mainWindow.webContents);
mainWindow.loadFile('renderer/index.html');
}
// 앱이 준비되면 window를 생성
app.whenReady().then(() => {
createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
// ?
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
// ipcMain이 뭔데요
// ipcMain.handle('readdir', async (event, dirPath) => {
// try {
// return await fs.promises.readdir(dirPath);
// } catch (error) {
// console.error('Error reading directory', error); // 디버깅용 로그
// throw error;
// }
// });
// ipcMain.handle('rename', async (event, oldPath, newPath) => {
// try {
// await fs.promises.rename(oldPath, newPath);
// console.log(`Successfully renamed ${oldPath} to ${newPath}`); // 디버깅용 로그
// } catch (error) {
// console.error(`Error renaming file ${oldPath} to ${newPath}`, error); // 디버깅용 로그
// throw error;
// }
// });