diff --git a/src/main/common/common.js b/src/main/common/common.js index 9a96fd2..64c8cdd 100644 --- a/src/main/common/common.js +++ b/src/main/common/common.js @@ -1,6 +1,7 @@ -import {app} from 'electron'; -import './config'; -import Listener from './listener'; +import { app } from "electron"; +import "./config"; +import Listener from "./listener"; +import { remote } from "electron"; export default function init(mainWindow) { const listener = new Listener(); @@ -16,11 +17,11 @@ export default function init(mainWindow) { } }); - // 打包后,失焦隐藏 - mainWindow.on('blur', () => { - app.isPackaged && mainWindow.hide(); + // 判断失焦是否隐藏 + mainWindow.on("blur", () => { + const config = { ...opConfig.get() }; + if (config.perf.common.hideOnBlur) { + mainWindow.hide(); + } }); - } - - diff --git a/src/main/common/config.js b/src/main/common/config.js index 0ff3c4e..99b190e 100644 --- a/src/main/common/config.js +++ b/src/main/common/config.js @@ -2,6 +2,7 @@ import path from "path"; import fs from "fs"; import { getLocalDataFile } from "./utils"; import os from "os"; +import { app } from "electron"; const configPath = path.join(getLocalDataFile(), "./rubick-config.json"); @@ -16,6 +17,8 @@ const defaultConfigForAnyPlatform = { common: { start: true, space: true, + // 是否失焦隐藏。默认在dev环境不隐藏,在打包后隐藏。 + hideOnBlur: app.isPackaged, }, local: { search: true, diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 8920358..7707e65 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -59,6 +59,14 @@ + + +
{ 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"); + }, + }, + }, }; diff --git a/src/renderer/pages/search/subpages/settings.vue b/src/renderer/pages/search/subpages/settings.vue index 0a2fc79..c19aaba 100644 --- a/src/renderer/pages/search/subpages/settings.vue +++ b/src/renderer/pages/search/subpages/settings.vue @@ -1,7 +1,11 @@