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() .quickcommandHttpServer()
.run( .run(
this.profile.quickFeatures.apiServer.cmd, this.profile.quickFeatures.apiServer.cmd,
this.profile.quickFeatures.apiServer.port this.profile.apiServerPort
); );
console.log("Server Start..."); console.log("Server Start...");
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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