add live update 5 seconds after last change
This commit is contained in:
parent
7489fd0aaf
commit
9f6389845a
|
@ -53,7 +53,8 @@ export default class Editor extends Module {
|
||||||
mode: 'scss',
|
mode: 'scss',
|
||||||
content: userscss,
|
content: userscss,
|
||||||
savedContent: userscss,
|
savedContent: userscss,
|
||||||
hoisted: true
|
hoisted: true,
|
||||||
|
liveUpdate: true
|
||||||
});
|
});
|
||||||
|
|
||||||
event.reply(constructFiles);
|
event.reply(constructFiles);
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
:saveFile="saveFile"
|
:saveFile="saveFile"
|
||||||
:newSnippet="newSnippet"
|
:newSnippet="newSnippet"
|
||||||
:saveSnippet="saveSnippet"
|
:saveSnippet="saveSnippet"
|
||||||
:injectStyle="injectStyle"/>
|
:injectStyle="injectStyle"
|
||||||
|
:toggleLiveUpdate="toggleLiveUpdate"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -71,6 +72,7 @@
|
||||||
this.snippets = await ClientIPC.send('bd-editor-getSnippets');
|
this.snippets = await ClientIPC.send('bd-editor-getSnippets');
|
||||||
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
this.liveUpdateInternal = setInterval(this.liveUpdate, 1000);
|
||||||
})();
|
})();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -82,6 +84,13 @@
|
||||||
updateContent(item, content) {
|
updateContent(item, content) {
|
||||||
item.content = content;
|
item.content = content;
|
||||||
item.saved = item.content === item.savedContent;
|
item.saved = item.content === item.savedContent;
|
||||||
|
|
||||||
|
if (this.liveUpdateTimeout) clearTimeout(this.liveUpdateTimeout);
|
||||||
|
if (item.liveUpdateEnabled) {
|
||||||
|
this.liveUpdateTimeout = setTimeout(() => {
|
||||||
|
this.injectStyle(item);
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async runScript(script) {
|
async runScript(script) {
|
||||||
|
@ -138,10 +147,16 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
async injectStyle(item) {
|
async injectStyle(item) {
|
||||||
|
if (item.content === '') return;
|
||||||
const result = await ClientIPC.send('bd-editor-injectStyle', { id: item.name.split('.')[0], style: item.content, mode: item.mode });
|
const result = await ClientIPC.send('bd-editor-injectStyle', { id: item.name.split('.')[0], style: item.content, mode: item.mode });
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toggleLiveUpdate(item) {
|
||||||
|
item.liveUpdateEnabled = !item.liveUpdateEnabled;
|
||||||
|
return item;
|
||||||
|
},
|
||||||
|
|
||||||
toggleaot() {
|
toggleaot() {
|
||||||
this.alwaysOnTop = !this.alwaysOnTop;
|
this.alwaysOnTop = !this.alwaysOnTop;
|
||||||
remote.getCurrentWindow().setAlwaysOnTop(this.alwaysOnTop);
|
remote.getCurrentWindow().setAlwaysOnTop(this.alwaysOnTop);
|
||||||
|
|
Loading…
Reference in New Issue