profile 全局配置变量扁平化

This commit is contained in:
fofolee 2022-05-06 22:52:42 +08:00
parent dab334c471
commit 73e342c8c3
7 changed files with 28 additions and 47 deletions

View File

@ -86,7 +86,7 @@ export default defineComponent({
.quickcommandHttpServer()
.run(
this.profile.quickFeatures.apiServer.cmd,
this.profile.quickFeatures.apiServer.port
this.profile.apiServerPort
);
console.log("Server Start...");
}

View File

@ -36,20 +36,20 @@
input-class="text-center"
style="width: 280px"
autofocus
v-model="$root.profile.quickFeatures.favFile.tag"
v-model="$root.profile.quickFileTag"
type="text"
>
<template v-slot:append>
<q-toggle
@click="toggleFeature('favFile')"
v-model="$root.profile.quickFeatures.favFile.enable"
v-model="$root.profile.quickFileEnable"
checked-icon="check"
color="primary"
/>
</template>
<q-tooltip
>启用后选中文件可以通过超级面板快速将文件收藏到{{
$root.profile.quickFeatures.favFile.tag
$root.profile.quickFileTag
}}标签
</q-tooltip>
</q-input>
@ -65,20 +65,20 @@
outlined
input-class="text-center"
style="width: 280px"
v-model="$root.profile.quickFeatures.favUrl.tag"
v-model="$root.profile.quickUrlTag"
type="text"
>
<template v-slot:append>
<q-toggle
@click="toggleFeature('favUrl')"
v-model="$root.profile.quickFeatures.favUrl.enable"
v-model="$root.profile.quickUrlEnable"
checked-icon="check"
color="primary"
/>
</template>
<q-tooltip
>启用后在浏览器界面可以通过超级面板快速将网址收藏到{{
$root.profile.quickFeatures.favUrl.tag
$root.profile.quickUrlTag
}}标签
</q-tooltip>
</q-input>
@ -95,13 +95,13 @@
input-class="text-center"
style="width: 280px"
autofocus
v-model="$root.profile.quickFeatures.pluNickName.tag"
v-model="$root.profile.pluNickNameTag"
type="text"
>
<template v-slot:append>
<q-toggle
@click="toggleFeature('pluNickName')"
v-model="$root.profile.quickFeatures.pluNickName.enable"
v-model="$root.profile.pluNickNameEnable"
checked-icon="check"
color="primary"
/>
@ -109,7 +109,7 @@
<q-tooltip
>启用后在主输入框输入插件别名可以快速设置插件别名<br />
并将所有设置的别名保存至{{
$root.profile.quickFeatures.pluNickName.tag
$root.profile.pluNickNameTag
}}标签
</q-tooltip>
</q-input>
@ -123,7 +123,7 @@
prefix="开启快捷命令服务"
suffix="端口"
outlined
v-model="$root.profile.quickFeatures.apiServer.port"
v-model="$root.profile.apiServerPort"
input-class="text-center"
style="width: 280px"
type="text"
@ -131,7 +131,7 @@
<template v-slot:append>
<q-toggle
@click="toggleFeature('apiServer')"
v-model="$root.profile.quickFeatures.apiServer.enable"
v-model="$root.profile.apiServerEnable"
checked-icon="check"
color="primary"
/>
@ -139,7 +139,7 @@
<q-tooltip
>启用后在主输入框输入快捷命令服务可以进入配置一个后台服务<br />
通过本地监听{{
$root.profile.quickFeatures.apiServer.port
$root.profile.apiServerPort
}}端口的形式接收用户传送过来的参数然后根据参数执行不同的操作
<br />
本功能的意义在于 utools
@ -455,10 +455,7 @@ export default {
toggleFeature(type) {
this.$root.utools.whole.removeFeature(this.features[type].code) ||
this.$root.utools.whole.setFeature(_.cloneDeep(this.features[type]));
if (
type === "apiServer" &&
!this.$root.profile.quickFeatures.apiServer.enable
) {
if (type === "apiServer" && !this.$root.profile.apiServerEnable) {
window.quickcommandHttpServer().stop();
this.$root.profile.quickFeatures.apiServer.serverStatus = false;
}

View File

@ -31,9 +31,7 @@
<div class="q-gutter-xs">
<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.quickFeatures.apiServer.port }}
</span>
<span> http://127.0.0.1:{{ $root.profile.apiServerPort }} </span>
<span>的参数均会作为本脚本里的变量 </span>
</div>
<q-btn-group unelevated>
@ -101,9 +99,7 @@ export default {
)
.then(() => {
this.$root.profile.quickFeatures.apiServer.serverStatus = true;
window
.quickcommandHttpServer()
.run(this.$root.profile.quickFeatures.apiServer.port);
window.quickcommandHttpServer().run(this.$root.profile.apiServerPort);
quickcommand.showMessageBox("启动服务成功!");
});
},

View File

@ -21,7 +21,7 @@ export default {
program: "quickcommand",
cmd: `open(\"${file.path.replace(/\\/g, "\\\\")}\")`,
output: "ignore",
tags: [this.$root.profile.quickFeatures.favFile.tag],
tags: [this.$root.profile.quickFileTag],
};
this.importCommand(command);
});

View File

@ -47,7 +47,7 @@ export default {
program: "quickcommand",
cmd: `visit(\"${url}\")\n`,
output: "ignore",
tags: [this.$root.profile.quickFeatures.favUrl.tag],
tags: [this.$root.profile.quickUrlTag],
};
try {
let res = await quickcommand.downloadFile(iconUrl, iconPath);

View File

@ -127,7 +127,7 @@ export default {
program: "quickcommand",
cmd: `utools.redirect("${this.feature.cmd}");utools.showMainWindow()`,
output: "ignore",
tags: [this.$root.profile.quickFeatures.pluNickName.tag],
tags: [this.$root.profile.pluNickNameTag],
};
this.importCommand(command);
this.nickName = [];

View File

@ -5,24 +5,12 @@ export default {
backgroundImg: null,
autofocusSearch: false,
denseTagBar: false,
crontabs: {},
quickFeatures: {
favFile: {
enable: false,
tag: "文件"
},
favUrl: {
enable: false,
tag: "网址"
},
pluNickName: {
enable: false,
tag: "别名"
},
apiServer: {
enable: false,
port: 33442,
serverStatus: false
}
}
quickFileEnable: false,
quickFileTag: "文件",
quickUrlEnable: false,
quickUrlTag: "网址",
pluNickNameEnable: false,
pluNickNameTag: "别名",
apiServerEnable: false,
apiServerPort: 33442,
}