get files/snippets from core

This commit is contained in:
Jiiks 2019-02-24 18:39:28 +02:00
parent 691c9f378a
commit 3fc1adc503
2 changed files with 34 additions and 12 deletions

View File

@ -101,6 +101,18 @@ class Comms {
const result = await this.sendToDiscord('bd-runEditorScript', script);
event.reply(result);
});
BDIpc.on('bd-editor-getFiles', async (event) => {
event.reply([
{ type: 'file', name: 'custom.scss', content: '', savedContent: '', mode: 'scss', saved: true }
]);
});
BDIpc.on('bd-editor-getSnippets', async (event) => {
event.reply([
{ type: 'snippet', name: 'test.js', content: '', savedContent: '', mode: 'javascript', saved: true }
]);
});
}
async send(channel, message) {

View File

@ -12,16 +12,17 @@
<button title="Close CSS Editor" @click="close">X</button>
</div>
</div>
<BDEdit
:files="files"
:snippets="snippets"
:updateContent="updateContent"
:runScript="runScript"
:newFile="newFile"
:saveFile="saveFile"
:newSnippet="newSnippet"
:saveSnippet="saveSnippet"
/>
<div id="spinner" v-if="loading">
<div class="valign">Loading Please Wait...</div>
</div>
<BDEdit v-else :files="files"
:snippets="snippets"
:updateContent="updateContent"
:runScript="runScript"
:newFile="newFile"
:saveFile="saveFile"
:newSnippet="newSnippet"
:saveSnippet="saveSnippet" />
</div>
</template>
@ -51,7 +52,7 @@
export default {
data() {
return {
files: [{ type: 'file', name: 'custom.scss', content: 'asd', savedContent: 'asd', mode: 'scss', saved: true }],
files: [],
snippets: [],
loading: true,
alwaysOnTop: false,
@ -64,9 +65,17 @@
ClientIPC.on('bd-editor-addSnippet', (_, snippet) => this.addSnippet(snippet));
},
mounted() {
(async () => {
this.files = await ClientIPC.send('bd-editor-getFiles');
this.snippets = await ClientIPC.send('bd-editor-getSnippets');
this.loading = false;
})();
},
methods: {
addFile(file) { this.files.push(file) },
addFile(file) {
this.files.push(file);
},
addSnippet(snippet) { this.snippets.push(file) },
updateContent(item, content) {
@ -124,6 +133,7 @@
this.alwaysOnTop = !this.alwaysOnTop;
remote.getCurrentWindow().setAlwaysOnTop(this.alwaysOnTop);
},
close() {
window.close();
}