新增base64图片直接导出

This commit is contained in:
朱浩 2025-01-21 12:49:41 +08:00
parent 57d0885df7
commit fabffc2363
2 changed files with 30 additions and 0 deletions

View File

@ -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()

View File

@ -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) => {