fix: 桌面导出改用 IPC 直写(另存为对话框),设置页显示版本号

This commit is contained in:
root
2026-10-16 13:07:38 +08:00
parent 599aa09ab8
commit f0d30e2c29
11 changed files with 66 additions and 33 deletions
+15 -1
View File
@@ -1,5 +1,6 @@
const { app, BrowserWindow, Menu, shell, dialog } = require('electron')
const { app, BrowserWindow, Menu, shell, dialog, ipcMain } = require('electron')
const path = require('path')
const fs = require('fs')
const DEV_URL = process.env.VITE_DEV_SERVER_URL || ''
@@ -16,6 +17,7 @@ function createWindow() {
webPreferences: {
contextIsolation: true,
nodeIntegration: false,
preload: path.join(__dirname, 'preload.cjs'),
spellcheck: false
}
})
@@ -45,6 +47,18 @@ function createWindow() {
}
}
// 导出文件:渲染进程请求主进程保存(标准另存为对话框 + 直接写盘)
ipcMain.handle('export-file', async (event, payload) => {
const win = BrowserWindow.fromWebContents(event.sender)
const result = await dialog.showSaveDialog(win, {
title: '保存文件',
defaultPath: path.join(app.getPath('downloads'), payload.filename)
})
if (result.canceled || !result.filePath) return { saved: false, path: '' }
fs.writeFileSync(result.filePath, payload.content, 'utf-8')
return { saved: true, path: result.filePath }
})
app.whenReady().then(() => {
createWindow()
app.on('activate', () => {