Commit 530e2bc6 by linjinhong

fix:添加默认路径为桌面JomallProductionAssistant-DTF

parent 0bc94680
...@@ -494,23 +494,18 @@ async function createWindow() { ...@@ -494,23 +494,18 @@ async function createWindow() {
}); });
ipcMain.on("get-install-path", event => { ipcMain.on("get-install-path", event => {
let psScriptPath; // 固定桌面路径,不再区分开发环境
if (process.env.NODE_ENV === "development") { const desktopPath = app.getPath("desktop");
psScriptPath = __dirname; const dtfDir = path.join(desktopPath, "JomallProductionAssistant-DTF");
} else {
psScriptPath = path.dirname(app.getPath("exe"));
}
const dtfDir = path.join(psScriptPath, "DTF");
try { try {
// 2. 确保目录存在:不存在则递归创建,已存在则直接跳过,不会报错 // 递归创建文件夹,不存在自动生成,存在不报错
fs.mkdirSync(dtfDir, { recursive: true }); fs.mkdirSync(dtfDir, { recursive: true });
// 3. 返回 DTF 目录路径
event.returnValue = dtfDir; event.returnValue = dtfDir;
} catch (err) { } catch (err) {
console.error("创建 DTF 文件夹失败:", err); console.error("创建 DTF 桌面文件夹失败:", err);
// 创建失败时兜底返回安装根目录,避免渲染进程拿不到值报错 // 兜底返回桌面,防止空值
event.returnValue = psScriptPath; event.returnValue = desktopPath;
} }
}); });
......
...@@ -141,12 +141,10 @@ export default { ...@@ -141,12 +141,10 @@ export default {
methods: { methods: {
async loadLocalConfig() { async loadLocalConfig() {
console.log(getDTFSetting()); console.log(getDTFSetting());
setDTFSetting({ downloadDir: "" });
try { try {
if (!getDTFSetting().downloadDir) { if (!getDTFSetting().downloadDir) {
const path = ipcRenderer.sendSync("get-install-path"); const path = ipcRenderer.sendSync("get-install-path");
console.log(111111);
setDTFSetting({ downloadDir: path }); setDTFSetting({ downloadDir: path });
} }
} catch (error) { } catch (error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment