feat(M1): FR-F3/F7/F8/F11/F12 文件树操作补齐——文件夹悬停加新建文档/新建文件夹/导入文件夹按钮(F3); 行内重命名 onBlur 改为提交(F7); 删除改 shell.trashItem 移入回收站(F8); fileImportFolder IPC+对话框导入文件夹(F11); 导入结果 showAlert 弹窗列失败项(F12); dialog-store 加 alert 模式; filetree-ops E2E 3 项
This commit is contained in:
@@ -26,10 +26,19 @@ export function registerIpc(vault: VaultService) {
|
||||
fs2().rename(p.from, p.toName));
|
||||
ipcMain.handle(IPC.fileMove, async (_e, p: { src: string; destDir: string }) =>
|
||||
fs2().move(p.src, p.destDir));
|
||||
ipcMain.handle(IPC.fileDelete, async (_e, p: { path: string; recursive: boolean }) =>
|
||||
fs2().delete(p.path, p.recursive));
|
||||
// FR-F8:删除优先移入回收站(shell.trashItem),失败回退永久删除
|
||||
ipcMain.handle(IPC.fileDelete, async (_e, p: { path: string; recursive: boolean }) => {
|
||||
const abs = nodePath.join(fs2().getRoot(), p.path);
|
||||
try {
|
||||
await shell.trashItem(abs);
|
||||
} catch (e) {
|
||||
// 回退:回收站不可用时永久删除
|
||||
console.error('trashItem failed, fallback to permanent delete:', e);
|
||||
await fs2().delete(p.path, p.recursive);
|
||||
}
|
||||
});
|
||||
// FR-F11:导入——sources 为空时弹系统对话框(支持文件夹导入)
|
||||
ipcMain.handle(IPC.fileImport, async (_e, p: { sources: string[]; destDir: string }) => {
|
||||
// 若 sources 为空,弹出系统选择对话框
|
||||
let sources = p.sources;
|
||||
if (sources.length === 0) {
|
||||
const r = await dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'], filters: [{ name: 'Markdown', extensions: ['md'] }] });
|
||||
@@ -39,6 +48,13 @@ export function registerIpc(vault: VaultService) {
|
||||
return fs2().importFiles(sources, p.destDir);
|
||||
});
|
||||
|
||||
// FR-F11:导入文件夹——选择外部文件夹递归复制进库
|
||||
ipcMain.handle(IPC.fileImportFolder, async (_e, p: { destDir: string }) => {
|
||||
const r = await dialog.showOpenDialog({ properties: ['openDirectory'] });
|
||||
if (r.canceled || r.filePaths.length === 0) return { ok: [], failed: [] };
|
||||
return fs2().importFiles(r.filePaths, p.destDir);
|
||||
});
|
||||
|
||||
// FR-E6:图片入库
|
||||
ipcMain.handle(IPC.assetPickImage, async () => vault.pickImage());
|
||||
ipcMain.handle(IPC.assetWrite, async (_e, p: { name: string; dataBase64: string }) =>
|
||||
|
||||
Reference in New Issue
Block a user