增加失焦隐藏or不隐藏的小按钮

This commit is contained in:
tcsnzh
2021-10-04 19:14:16 +08:00
parent 60b1138dd8
commit 747c5512a7
4 changed files with 225 additions and 150 deletions

View File

@@ -59,6 +59,14 @@
</div>
</div>
</a-input>
<span class="button-hide-on-blur" @click="changeHideOnBlur">
<a-icon
type="pushpin"
:style="{
color: config.perf.common.hideOnBlur ? 'grey' : '#ea68a2',
}"
></a-icon>
</span>
<div v-show="showOptions" class="options">
<a-list item-layout="horizontal" :data-source="options">
<a-list-item
@@ -135,11 +143,10 @@ export default {
return {
query: this.$route.query,
searchFn: null,
config: opConfig.get(),
config: { ...opConfig.get() },
currentSelect: 0,
};
},
created() {
window.setPluginInfo = (pluginInfo) => {
this.commonUpdate({
@@ -147,7 +154,6 @@ export default {
});
};
},
mounted() {
ipcRenderer.on("init-rubick", this.closeTag);
ipcRenderer.on("new-window", this.newWindow);
@@ -319,10 +325,14 @@ export default {
}
},
changePath({ key }) {
this.$router.push({ path: `/home/${key}` });
this.commonUpdate({
current: [key],
});
const path = `/home/${key}`;
// 避免重复点击导致跳转相同路由而爆红
if (this.$router.history.current.fullPath != path) {
this.$router.push({ path });
this.commonUpdate({
current: [key],
});
}
},
closeTag(v) {
this.commonUpdate({
@@ -396,6 +406,11 @@ export default {
ipcRenderer.send("window-move");
}
},
changeHideOnBlur(e) {
let cfg = { ...this.config };
cfg.perf.common.hideOnBlur = !cfg.perf.common.hideOnBlur;
this.config = cfg;
},
},
computed: {
...mapState("main", [
@@ -410,7 +425,7 @@ export default {
"pluginLoading",
]),
showOptions() {
// 有选项值,且不在显示主页
// 有选项值,且不在显示主页。(即出现下方选项框)
if (this.options.length && !this.showMain) {
return true;
}
@@ -419,6 +434,17 @@ export default {
return this.pluginInfo.searchType ? "subWindow" : "";
},
},
watch: {
config: {
deep: true,
handler() {
opConfig.set("perf", this.config.perf);
opConfig.set("superPanel", this.config.superPanel);
opConfig.set("global", this.config.global);
ipcRenderer.send("re-register");
},
},
},
};
</script>
<style lang="less">
@@ -538,4 +564,9 @@ export default {
left: 0;
}
}
.button-hide-on-blur {
padding: 0px 3px 0px 0px;
// 小按钮只会在碰到1/3处时被认为点击。
height: 33%;
}
</style>