mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-07 21:46:12 +08:00
快捷命令服务改为内置 feature
This commit is contained in:
parent
1e3042d7a0
commit
1b40855578
@ -52,6 +52,14 @@
|
||||
"分享中心",
|
||||
"ShareCenter"
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "server",
|
||||
"explain": "配置快捷命令后台服务",
|
||||
"cmds": [
|
||||
"快捷命令服务配置",
|
||||
"quickcommandServer"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -83,8 +83,8 @@ export default defineComponent({
|
||||
this.runCronTask(featureCode, cronExp);
|
||||
});
|
||||
// 快捷命令服务
|
||||
if (this.nativeProfile.apiServerStatus && this.profile.apiServerEnable) {
|
||||
window.quickcommandHttpServer().run(this.profile.apiServerPort);
|
||||
if (this.nativeProfile.serverStatus && this.profile.apiServerEnable) {
|
||||
window.quickcommandHttpServer().run(this.nativeProfile.serverPort);
|
||||
console.log("Server Start...");
|
||||
}
|
||||
},
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 3.5 KiB |
@ -118,36 +118,57 @@
|
||||
<q-item-section side>
|
||||
<q-icon name="api" />
|
||||
</q-item-section>
|
||||
<q-input
|
||||
dense
|
||||
prefix="开启快捷命令服务"
|
||||
suffix="端口"
|
||||
outlined
|
||||
v-model="$root.profile.apiServerPort"
|
||||
input-class="text-center"
|
||||
style="width: 280px"
|
||||
type="text"
|
||||
<q-field dense outlined style="width: 280px">
|
||||
<template v-slot:control>
|
||||
<div
|
||||
class="self-center full-width no-outline"
|
||||
tabindex="0"
|
||||
>
|
||||
快捷命令服务
|
||||
</div>
|
||||
</template>
|
||||
<template v-slot:append>
|
||||
<q-toggle
|
||||
@click="toggleFeature('apiServer')"
|
||||
v-model="$root.profile.apiServerEnable"
|
||||
checked-icon="check"
|
||||
color="primary"
|
||||
<q-btn
|
||||
flat
|
||||
@click="$router.push('server')"
|
||||
icon="open_in_new"
|
||||
/>
|
||||
</template>
|
||||
<q-tooltip
|
||||
>启用后,在主输入框输入「快捷命令服务」可以进入配置一个后台服务<br />
|
||||
通过本地监听{{
|
||||
$root.profile.apiServerPort
|
||||
}}端口的形式,接收用户传送过来的参数,然后根据参数执行不同的操作
|
||||
>通过本地监听
|
||||
{{ $root.nativeProfile.serverPort }}
|
||||
端口的形式,接收用户传送过来的参数,然后根据参数执行不同的操作
|
||||
<br />
|
||||
本功能的意义在于,将 utools
|
||||
的接口暴露出来,可以通过命令行等外部途径 <br />
|
||||
直接启用 ubrowser 或者直接redirect 到相应的插件<br />
|
||||
需要配置插件跟随 utools 启动和保留后台
|
||||
需要配置插件跟随 utools 启动和保留后台<br />
|
||||
也可在主输入框通过关键字「快捷命令服务配置」进入
|
||||
</q-tooltip>
|
||||
</q-input>
|
||||
</q-field>
|
||||
</q-item>
|
||||
<q-item>
|
||||
<q-item-section side>
|
||||
<q-icon name="code" />
|
||||
</q-item-section>
|
||||
<q-field dense outlined style="width: 280px">
|
||||
<template v-slot:control>
|
||||
<div
|
||||
class="self-center full-width no-outline"
|
||||
tabindex="0"
|
||||
>
|
||||
运行代码
|
||||
</div>
|
||||
</template>
|
||||
<template v-slot:append>
|
||||
<q-btn
|
||||
flat
|
||||
@click="$router.push('code')"
|
||||
icon="open_in_new"
|
||||
/>
|
||||
</template>
|
||||
<q-tooltip
|
||||
>一个可以直接运行代码的代码编辑器<br />
|
||||
也可在主输入框输入关键字「RunCode」进入
|
||||
</q-tooltip>
|
||||
</q-field>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-menu>
|
||||
@ -384,6 +405,7 @@ export default {
|
||||
showAbout: false,
|
||||
showPanelConf: false,
|
||||
features: features,
|
||||
redirect: utools.redirect,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@ -457,7 +479,7 @@ export default {
|
||||
this.$root.utools.whole.setFeature(_.cloneDeep(this.features[type]));
|
||||
if (type === "apiServer" && !this.$root.profile.apiServerEnable) {
|
||||
window.quickcommandHttpServer().stop();
|
||||
this.$root.nativeProfile.apiServerStatus = false;
|
||||
this.$root.nativeProfile.serverStatus = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
@ -12,11 +12,10 @@ export default {
|
||||
quickUrlTag: "网址",
|
||||
pluNickNameEnable: false,
|
||||
pluNickNameTag: "别名",
|
||||
apiServerEnable: false,
|
||||
apiServerPort: 33442,
|
||||
},
|
||||
native: {
|
||||
crontabs: {},
|
||||
apiServerStatus: false
|
||||
serverPort: 33442,
|
||||
serverStatus: false
|
||||
}
|
||||
}
|
@ -42,13 +42,6 @@ const quickFeatures = {
|
||||
cmds: ["插件别名"],
|
||||
icon: require("../../assets/feature/plugin.png"),
|
||||
platform: ["win32", "darwin", "linux"],
|
||||
},
|
||||
apiServer: {
|
||||
code: "feature_apiServer",
|
||||
explain: "配置快捷命令后台服务",
|
||||
cmds: ["快捷命令服务配置", "quickcommandServer"],
|
||||
icon: require("../../assets/feature/api.png"),
|
||||
platform: ["win32", "darwin", "linux"],
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
<script>
|
||||
import PluginNickName from "components/quickFeatures/PluginNickName";
|
||||
import ApiServer from "components/quickFeatures/ApiServer";
|
||||
import FavFile from "components/quickFeatures/FavFile";
|
||||
import FavUrl from "components/quickFeatures/FavUrl";
|
||||
import { markRaw } from "vue";
|
||||
@ -12,7 +11,6 @@ import { markRaw } from "vue";
|
||||
export default {
|
||||
components: {
|
||||
pluNickName: markRaw(PluginNickName),
|
||||
apiServer: markRaw(ApiServer),
|
||||
favFile: markRaw(FavFile),
|
||||
favUrl: markRaw(FavUrl),
|
||||
},
|
@ -28,10 +28,19 @@
|
||||
height: bottomHeight + 'px',
|
||||
}"
|
||||
>
|
||||
<div class="q-gutter-xs">
|
||||
<div class="q-gutter-xs flex items-center full-height content-center">
|
||||
<q-badge color="primary" dense square>POST</q-badge
|
||||
><q-badge color="primary" dense square>GET</q-badge>
|
||||
<span> http://127.0.0.1:{{ $root.profile.apiServerPort }} </span>
|
||||
<span> http://127.0.0.1:</span>
|
||||
<q-input
|
||||
borderless
|
||||
dense
|
||||
v-model="$root.nativeProfile.serverPort"
|
||||
style="width: 40px"
|
||||
input-class="text-weight-bolder"
|
||||
@blur="restartServer"
|
||||
><q-tooltip>点击修改端口</q-tooltip></q-input
|
||||
>
|
||||
<span>的参数,均会作为本脚本里的变量 </span>
|
||||
</div>
|
||||
<q-btn-group unelevated>
|
||||
@ -51,7 +60,7 @@
|
||||
flat
|
||||
color="negative"
|
||||
icon="stop"
|
||||
v-if="$root.nativeProfile.apiServerStatus"
|
||||
v-if="$root.nativeProfile.serverStatus"
|
||||
@click="stopServer"
|
||||
label="停止服务"
|
||||
/>
|
||||
@ -97,16 +106,29 @@ export default {
|
||||
"FBI WARNING"
|
||||
)
|
||||
.then(() => {
|
||||
this.$root.nativeProfile.apiServerStatus = true;
|
||||
window.quickcommandHttpServer().run(this.$root.profile.apiServerPort);
|
||||
this.$root.nativeProfile.serverStatus = true;
|
||||
window
|
||||
.quickcommandHttpServer()
|
||||
.run(this.$root.nativeProfile.serverPort);
|
||||
quickcommand.showMessageBox("启动服务成功!");
|
||||
});
|
||||
},
|
||||
stopServer() {
|
||||
window.quickcommandHttpServer().stop();
|
||||
this.$root.nativeProfile.apiServerStatus = false;
|
||||
this.$root.nativeProfile.serverStatus = false;
|
||||
quickcommand.showMessageBox("关闭服务成功!");
|
||||
},
|
||||
restartServer() {
|
||||
if (!this.$root.nativeProfile.serverPort)
|
||||
this.$root.nativeProfile.serverPort = 33442;
|
||||
if ((this.$root.nativeProfile.serverStatus = true)) {
|
||||
window.quickcommandHttpServer().stop();
|
||||
window
|
||||
.quickcommandHttpServer()
|
||||
.run(this.$root.nativeProfile.serverPort);
|
||||
quickcommand.showMessageBox("服务已重启");
|
||||
}
|
||||
},
|
||||
saveCode() {
|
||||
clearTimeout(this.saveCodeTimer);
|
||||
this.saveCodeTimer = setTimeout(() => {
|
@ -49,7 +49,14 @@ const routes = [{
|
||||
{
|
||||
path: '/feature_:featuretype(\\w+)',
|
||||
name: 'feature',
|
||||
component: () => import('pages/quickFeaturesPage.vue')
|
||||
component: () =>
|
||||
import ('pages/FeaturesPage.vue')
|
||||
},
|
||||
{
|
||||
path: '/server',
|
||||
name: 'server',
|
||||
component: () =>
|
||||
import ('pages/ServerPage.vue')
|
||||
}
|
||||
]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user