mirror of
https://github.com/LifeArchiveProject/WeChatDataAnalysis.git
synced 2026-02-19 14:20:51 +08:00
improvement(chat): 优化导出筛选与目录选择体验
This commit is contained in:
@@ -611,6 +611,25 @@ function registerWindowIpc() {
|
||||
return getCloseBehavior();
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle("dialog:chooseDirectory", async (_event, options) => {
|
||||
try {
|
||||
const result = await dialog.showOpenDialog({
|
||||
title: String(options?.title || "选择文件夹"),
|
||||
properties: ["openDirectory", "createDirectory"],
|
||||
});
|
||||
return {
|
||||
canceled: !!result?.canceled,
|
||||
filePaths: Array.isArray(result?.filePaths) ? result.filePaths : [],
|
||||
};
|
||||
} catch (err) {
|
||||
logMain(`[main] dialog:chooseDirectory failed: ${err?.message || err}`);
|
||||
return {
|
||||
canceled: true,
|
||||
filePaths: [],
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
|
||||
@@ -11,4 +11,6 @@ contextBridge.exposeInMainWorld("wechatDesktop", {
|
||||
|
||||
getCloseBehavior: () => ipcRenderer.invoke("app:getCloseBehavior"),
|
||||
setCloseBehavior: (behavior) => ipcRenderer.invoke("app:setCloseBehavior", String(behavior || "")),
|
||||
|
||||
chooseDirectory: (options = {}) => ipcRenderer.invoke("dialog:chooseDirectory", options),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user