diff --git a/src/main/file.js b/src/main/file.js index a957b42..b370b38 100644 --- a/src/main/file.js +++ b/src/main/file.js @@ -452,6 +452,27 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) { }) }) + ipcMain.on('export-img64-file', function (event, {base64, name}) { + name = name || '思维导图' + const parts = base64.split(';base64,'); + const contentType = parts[0].split(':')[1]; + const extension = contentType.split('/')[1]; + const data = Buffer.from(parts[1], 'base64'); + + dialog.showSaveDialog({ + title: '保存图片', + defaultPath: path.join(app.getPath('downloads'), `${name}.${extension}`), + filters: [ + { name: 'Image Files', extensions: [extension] } + ] + }).then(result => { + if (!result.canceled) { + fs.writeFileSync(result.filePath, data); + event.reply('export-img64-file-reply') + } + }); + }) + /*导出文件*/ function exportFile(list, callback) { let win = BrowserWindow.getFocusedWindow() diff --git a/src/renderer/src/utils/talkFile/index.js b/src/renderer/src/utils/talkFile/index.js index 495e1cd..3807a1e 100644 --- a/src/renderer/src/utils/talkFile/index.js +++ b/src/renderer/src/utils/talkFile/index.js @@ -87,6 +87,15 @@ export const exportFile = async (list) => { }) } +export const exportImg64File = async (base64, name) => { + return new Promise((resolve, reject) => { + ipcRenderer.send('export-img64-file', {base64,name}) + ipcRenderer.once('export-img64-file-reply', (e) => { + resolve() + }) + }) +} + export const creatPPT = (name, uploadData) => { JSON.parse(JSON.stringify(uploadData)) return new Promise((resolve, reject) => {