新增base64图片直接导出
This commit is contained in:
parent
57d0885df7
commit
fabffc2363
|
@ -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) {
|
function exportFile(list, callback) {
|
||||||
let win = BrowserWindow.getFocusedWindow()
|
let win = BrowserWindow.getFocusedWindow()
|
||||||
|
|
|
@ -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) => {
|
export const creatPPT = (name, uploadData) => {
|
||||||
JSON.parse(JSON.stringify(uploadData))
|
JSON.parse(JSON.stringify(uploadData))
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
Loading…
Reference in New Issue