快捷命令服务改为内置 feature

This commit is contained in:
fofolee 2022-05-08 23:30:07 +08:00
parent 1e3042d7a0
commit 1b40855578
9 changed files with 105 additions and 56 deletions

View File

@ -52,6 +52,14 @@
"分享中心",
"ShareCenter"
]
},
{
"code": "server",
"explain": "配置快捷命令后台服务",
"cmds": [
"快捷命令服务配置",
"quickcommandServer"
]
}
]
}

View File

@ -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

View File

@ -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;
}
},
},

View File

@ -12,11 +12,10 @@ export default {
quickUrlTag: "网址",
pluNickNameEnable: false,
pluNickNameTag: "别名",
apiServerEnable: false,
apiServerPort: 33442,
},
native: {
crontabs: {},
apiServerStatus: false
serverPort: 33442,
serverStatus: false
}
}

View File

@ -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"],
}
}

View File

@ -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),
},

View File

@ -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(() => {

View File

@ -2,54 +2,61 @@ const routes = [{
path: '/configuration',
name: 'configuration',
component: () =>
import('pages/ConfigurationPage.vue')
import ('pages/ConfigurationPage.vue')
},
{
path: '/code',
name: 'code',
component: () =>
import('pages/RunCodePage.vue')
import ('pages/RunCodePage.vue')
},
{
path: '/newcommand',
name: 'newcommand',
component: () =>
import('pages/ConfigurationPage.vue')
import ('pages/ConfigurationPage.vue')
},
{
path: '/:type(default|files|img|key|regex|window|professional)_:uid(\\w+)',
name: 'command',
component: () =>
import('pages/CommandPage.vue')
import ('pages/CommandPage.vue')
},
{
path: '/panel_:tags(\\w+)',
name: 'panel',
component: () =>
import('pages/ConfigurationPage.vue')
import ('pages/ConfigurationPage.vue')
},
{
path: '/needupdate',
name: 'needupdate',
props: true,
component: () =>
import('pages/updateWarningPage.vue')
import ('pages/updateWarningPage.vue')
},
{
path: '/',
name: 'loading',
component: () =>
import('pages/LoadingPage.vue')
import ('pages/LoadingPage.vue')
}, {
path: '/share',
name: 'share',
component: () =>
import('pages/ShareCenterPage.vue')
import ('pages/ShareCenterPage.vue')
},
{
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')
}
]