앱을 종료할 때 - 전체 화면 모드 상태 여부, 화면 크기, 화면 위치 정보를 저장

This commit is contained in:
2026-05-18 09:39:19 +09:00
parent 3d0943b6fe
commit d74c2e055d
4 changed files with 82 additions and 23 deletions
+5 -19
View File
@@ -1,16 +1,8 @@
const { ipcMain, dialog, app, shell } = require('electron');
const { ipcMain, dialog, shell } = require('electron');
const path = require('path');
const fs = require('fs');
const os = require('os');
const configPath = path.join(app.getPath('userData'), 'config.json');
function readConfig() {
try { return JSON.parse(fs.readFileSync(configPath, 'utf8')); } catch { return {}; }
}
function writeConfig(data) {
try { fs.writeFileSync(configPath, JSON.stringify(data, null, 2)); } catch {}
}
const { readConfig, updateConfig } = require('../config');
function register(mainWindow) {
ipcMain.handle('select-folder', async () => {
@@ -33,9 +25,7 @@ function register(mainWindow) {
});
ipcMain.handle('set-last-folder', (_e, folderPath) => {
const cfg = readConfig();
cfg.lastFolder = folderPath;
writeConfig(cfg);
updateConfig(cfg => { cfg.lastFolder = folderPath; });
});
ipcMain.handle('list-directories', (_e, folderPath) => {
@@ -64,9 +54,7 @@ function register(mainWindow) {
});
ipcMain.handle('set-preview-on', (_e, on) => {
const cfg = readConfig();
cfg.previewOn = on;
writeConfig(cfg);
updateConfig(cfg => { cfg.previewOn = on; });
});
ipcMain.handle('get-sidebar-width', () => {
@@ -75,9 +63,7 @@ function register(mainWindow) {
});
ipcMain.handle('set-sidebar-width', (_e, width) => {
const cfg = readConfig();
cfg.sidebarWidth = width;
writeConfig(cfg);
updateConfig(cfg => { cfg.sidebarWidth = width; });
});
}