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
| const { ipcMain } = require("electron"); const { dialog } = require("electron"); const path = require("path");
ipcMain.on("savefile", (event, arg) => { dialog .showSaveDialog({ defaultPath: path.join( global.sharedObject.appBasePath, arg ? arg : "filename.txt" ), }) .then((result) => { if (!result.canceled) { const filePath = result.filePath; console.log("保存路径:", filePath); event.reply("savefile-result", filePath); } else { console.log("取消保存文件"); } }) .catch((err) => { console.log("保存文件出错:", err); }); });
|