add editor file writing
This commit is contained in:
parent
5454950838
commit
cf1da34e16
|
@ -12,7 +12,7 @@ import path from 'path';
|
||||||
import { BrowserWindow } from 'electron';
|
import { BrowserWindow } from 'electron';
|
||||||
|
|
||||||
import Module from './modulebase';
|
import Module from './modulebase';
|
||||||
import { WindowUtils } from './utils';
|
import { WindowUtils, FileUtils } from './utils';
|
||||||
import BDIpc from './bdipc';
|
import BDIpc from './bdipc';
|
||||||
|
|
||||||
export default class Editor extends Module {
|
export default class Editor extends Module {
|
||||||
|
@ -46,11 +46,16 @@ export default class Editor extends Module {
|
||||||
});
|
});
|
||||||
|
|
||||||
BDIpc.on('editor-saveFile', async (event, file) => {
|
BDIpc.on('editor-saveFile', async (event, file) => {
|
||||||
console.log(file);
|
try {
|
||||||
event.reply('ok');
|
await FileUtils.writeFile(path.resolve(this.bd.config.getPath('data'), file.name), file.content);
|
||||||
|
event.reply('ok');
|
||||||
|
} catch (err) {
|
||||||
|
event.reply({ err });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
BDIpc.on('editor-saveSnippet', async (event, snippet) => {
|
BDIpc.on('editor-saveSnippet', async (event, snippet) => {
|
||||||
|
// TODO not sure how to store snippets yet
|
||||||
console.log(snippet);
|
console.log(snippet);
|
||||||
event.reply('ok');
|
event.reply('ok');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue