清理:移除未使用的 openFiles IPC、优化 setModified 避免每次按键重建标签 DOM

This commit is contained in:
thzxx
2026-05-18 13:31:14 +08:00
parent 78f787a2db
commit 5ff89edd2b
3 changed files with 7 additions and 28 deletions
+3 -24
View File
@@ -84,9 +84,9 @@ function stopWatching() {
}
}
async function showOpenDialog(multi) {
async function showOpenDialog() {
const result = await dialog.showOpenDialog(mainWindow, {
properties: multi ? ['openFile', 'multiSelections'] : ['openFile'],
properties: ['openFile'],
filters: [
{ name: 'Markdown 文件', extensions: ['md', 'markdown', 'txt'] },
{ name: '所有文件', extensions: ['*'] }
@@ -131,7 +131,7 @@ function switchActiveFile(filePath) {
// Open single file via dialog
ipcMain.handle('dialog:openFile', async () => {
try {
const files = await showOpenDialog(false);
const files = await showOpenDialog();
if (files && files.length > 0) {
const content = readFileContent(files[0]);
activeFilePath = files[0];
@@ -145,27 +145,6 @@ ipcMain.handle('dialog:openFile', async () => {
}
});
// Open multiple files via dialog
ipcMain.handle('dialog:openFiles', async () => {
try {
const files = await showOpenDialog(true);
if (files && files.length > 0) {
const results = [];
for (const fp of files) {
try {
const content = readFileContent(fp);
results.push({ filePath: fp, content });
} catch (err) {
results.push({ filePath: fp, error: err.message });
}
}
return results;
}
return null;
} catch (err) {
return { error: err.message };
}
});
ipcMain.handle('file:read', async (event, filePath) => {
try {