mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 22:51:25 +08:00
自动重载
This commit is contained in:
parent
661c6b3711
commit
8cd035c020
@ -6,8 +6,10 @@
|
||||
ref="editor"
|
||||
@typing="
|
||||
(val) => {
|
||||
if ($profile.quickFeatures.apiServer.cmd !== val) {
|
||||
$profile.quickFeatures.apiServer.cmd = val;
|
||||
serverStatus && (needRestart = true);
|
||||
}
|
||||
restartServer();
|
||||
}
|
||||
"
|
||||
:style="{
|
||||
@ -36,13 +38,13 @@
|
||||
<span>的参数,均会作为本脚本里的变量 </span>
|
||||
</div>
|
||||
<q-btn-group unelevated>
|
||||
<q-btn flat color="primary" icon="help" />
|
||||
<q-btn flat color="primary" icon="help" @click="showHelp" />
|
||||
<q-separator inset vertical />
|
||||
<q-btn
|
||||
flat
|
||||
color="negative"
|
||||
icon="stop"
|
||||
v-if="serverStatus && !needRestart"
|
||||
v-if="serverStatus && !restartTimer"
|
||||
@click="stopServer"
|
||||
label="停止服务"
|
||||
/>
|
||||
@ -50,9 +52,9 @@
|
||||
flat
|
||||
color="warning"
|
||||
icon="restart_alt"
|
||||
v-else-if="serverStatus && needRestart"
|
||||
v-else-if="serverStatus && !!restartTimer"
|
||||
@click="restartServer"
|
||||
label="重启服务"
|
||||
label="正在重载"
|
||||
/>
|
||||
<q-btn
|
||||
flat
|
||||
@ -77,13 +79,13 @@ export default {
|
||||
return {
|
||||
bottomHeight: 40,
|
||||
serverStatus: this.$profile.quickFeatures.apiServer.serverStatus,
|
||||
needRestart: null,
|
||||
restartTimer: null,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.$refs.editor.setEditorValue(this.$profile.quickFeatures.apiServer.cmd);
|
||||
this.$refs.editor.setEditorLanguage("javascript");
|
||||
this.needRestart = false;
|
||||
this.restartTimer = null;
|
||||
},
|
||||
methods: {
|
||||
enableServer() {
|
||||
@ -112,6 +114,9 @@ export default {
|
||||
quickcommand.showMessageBox("关闭服务成功!");
|
||||
},
|
||||
restartServer() {
|
||||
if (!this.serverStatus) return;
|
||||
clearTimeout(this.restartTimer);
|
||||
this.restartTimer = setTimeout(() => {
|
||||
window.quickcommandHttpServer().stop();
|
||||
window
|
||||
.quickcommandHttpServer()
|
||||
@ -119,8 +124,16 @@ export default {
|
||||
this.$profile.quickFeatures.apiServer.cmd,
|
||||
this.$profile.quickFeatures.apiServer.port
|
||||
);
|
||||
this.needRestart = false;
|
||||
quickcommand.showMessageBox("重启服务成功!");
|
||||
this.restartTimer = null;
|
||||
}, 1000);
|
||||
},
|
||||
showHelp() {
|
||||
utools.ubrowser
|
||||
.goto("https://www.yuque.com/fofolee-awga0/cpbg1m/bg31vl#GNjEg")
|
||||
.run({
|
||||
width: 1380,
|
||||
height: 750,
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user