mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-14 15:26:56 +08:00
增加失焦隐藏or不隐藏的小按钮
This commit is contained in:
parent
60b1138dd8
commit
747c5512a7
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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}` });
|
||||
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>
|
||||
|
@ -1,7 +1,11 @@
|
||||
<template>
|
||||
<div class="pg-settings">
|
||||
<div class="dev-detail">
|
||||
<a-menu v-model="currentSelect" style="width: 256px; height: 100%" mode="vertical">
|
||||
<a-menu
|
||||
v-model="currentSelect"
|
||||
style="width: 256px; height: 100%"
|
||||
mode="vertical"
|
||||
>
|
||||
<a-menu-item :key="0">
|
||||
偏好设置
|
||||
</a-menu-item>
|
||||
@ -15,36 +19,68 @@
|
||||
<div class="settings-detail">
|
||||
<div v-if="currentSelect[0] === 0">
|
||||
<div class="setting-item">
|
||||
<div class="title">快捷键(需要使用 option/ctrl/shift/command 键修饰)</div>
|
||||
<div class="title">
|
||||
快捷键(需要使用 option/ctrl/shift/command 键修饰)
|
||||
</div>
|
||||
<div class="settings-item-li">
|
||||
<div class="label">显示/隐藏快捷键</div>
|
||||
<div class="value" tabIndex=-1 @keyup="(e) => changeShortCut(e, 'showAndHidden')">{{ config.perf.shortCut.showAndHidden }}</div>
|
||||
<div
|
||||
class="value"
|
||||
tabIndex="-1"
|
||||
@keyup="(e) => changeShortCut(e, 'showAndHidden')"
|
||||
>
|
||||
{{ config.perf.shortCut.showAndHidden }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings-item-li">
|
||||
<div class="label">插件分离快捷键</div>
|
||||
<div class="value" tabIndex=-1 @keyup="(e) => changeShortCut(e, 'separate')">{{ config.perf.shortCut.separate }}</div>
|
||||
<div
|
||||
class="value"
|
||||
tabIndex="-1"
|
||||
@keyup="(e) => changeShortCut(e, 'separate')"
|
||||
>
|
||||
{{ config.perf.shortCut.separate }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings-item-li">
|
||||
<div class="label">返回主界面</div>
|
||||
<div class="value" tabIndex=-1 @keyup="(e) => changeShortCut(e, 'quit')">{{ config.perf.shortCut.quit }}</div>
|
||||
<div
|
||||
class="value"
|
||||
tabIndex="-1"
|
||||
@keyup="(e) => changeShortCut(e, 'quit')"
|
||||
>
|
||||
{{ config.perf.shortCut.quit }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<div class="title">通用</div>
|
||||
<div class="settings-item-li">
|
||||
<div class="label">开机启动</div>
|
||||
<a-switch v-model:checked="config.perf.common.start" checked-children="开" un-checked-children="关"></a-switch>
|
||||
<a-switch
|
||||
v-model:checked="config.perf.common.start"
|
||||
checked-children="开"
|
||||
un-checked-children="关"
|
||||
></a-switch>
|
||||
</div>
|
||||
<div class="settings-item-li">
|
||||
<div class="label">空格执行</div>
|
||||
<a-switch v-model:checked="config.perf.common.space" checked-children="开" un-checked-children="关"></a-switch>
|
||||
<a-switch
|
||||
v-model:checked="config.perf.common.space"
|
||||
checked-children="开"
|
||||
un-checked-children="关"
|
||||
></a-switch>
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<div class="title">本地搜索启动</div>
|
||||
<div class="settings-item-li">
|
||||
<div class="label">搜索启动应用&文件</div>
|
||||
<a-switch v-model:checked="config.perf.local.search" checked-children="开" un-checked-children="关"></a-switch>
|
||||
<a-switch
|
||||
v-model:checked="config.perf.local.search"
|
||||
checked-children="开"
|
||||
un-checked-children="关"
|
||||
></a-switch>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -57,20 +93,25 @@
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<div class="title">长按以下设置的毫秒响应</div>
|
||||
<a-slider :step="100" v-model:value="config.superPanel.mouseDownTime" :min="200" :max="1000" />
|
||||
<a-slider
|
||||
:step="100"
|
||||
v-model:value="config.superPanel.mouseDownTime"
|
||||
:min="200"
|
||||
:max="1000"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="currentSelect[0] === 2">
|
||||
<a-collapse>
|
||||
<a-collapse-panel key="1" header="说明及示例">
|
||||
<div>按下快捷键,自动搜索对应关键字,当关键字结果完全匹配,且结果唯一时,会直接指向该功能。</div>
|
||||
<div>
|
||||
按下快捷键,自动搜索对应关键字,当关键字结果完全匹配,且结果唯一时,会直接指向该功能。
|
||||
</div>
|
||||
<h3 style="margin-top: 10px;">示例</h3>
|
||||
<a-divider style="margin: 5px 0;" />
|
||||
<a-list item-layout="horizontal" :data-source="examples">
|
||||
<a-list-item slot="renderItem" slot-scope="item, index">
|
||||
<a-list-item-meta
|
||||
:description="item.desc"
|
||||
>
|
||||
<a-list-item-meta :description="item.desc">
|
||||
<div slot="title">{{ item.title }}</div>
|
||||
</a-list-item-meta>
|
||||
</a-list-item>
|
||||
@ -82,18 +123,20 @@
|
||||
<div>快捷键</div>
|
||||
<a-tooltip placement="top" trigger="click">
|
||||
<template slot="title">
|
||||
<span>先按功能键(Ctrl、Shift、Alt、Option、Command),再按其他普通键。或按 F1-F12 单键</span>
|
||||
<span
|
||||
>先按功能键(Ctrl、Shift、Alt、Option、Command),再按其他普通键。或按
|
||||
F1-F12 单键</span
|
||||
>
|
||||
</template>
|
||||
<div
|
||||
v-for="(item, index) in config.global"
|
||||
class="value"
|
||||
tabIndex=-1
|
||||
tabIndex="-1"
|
||||
@keyup="(e) => changeGlobalKey(e, index)"
|
||||
>
|
||||
{{ item.key }}
|
||||
</div>
|
||||
</a-tooltip>
|
||||
|
||||
</div>
|
||||
<div class="short-cut item">
|
||||
<div>功能关键字</div>
|
||||
@ -111,31 +154,30 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import keycodes from '../../../assets/keycode';
|
||||
import {ipcRenderer, remote} from 'electron';
|
||||
import keycodes from "../../../assets/keycode";
|
||||
import { ipcRenderer, remote } from "electron";
|
||||
|
||||
const opConfig = remote.getGlobal('opConfig');
|
||||
const opConfig = remote.getGlobal("opConfig");
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
currentSelect: [0],
|
||||
config: JSON.parse(JSON.stringify(opConfig.get())),
|
||||
config: { ...opConfig.get() },
|
||||
examples: [
|
||||
{
|
||||
title: '快捷键 「 Alt + W」 关键字 「 微信」',
|
||||
desc: '按下Alt + W 直接打开本地微信应用'
|
||||
title: "快捷键 「 Alt + W」 关键字 「 微信」",
|
||||
desc: "按下Alt + W 直接打开本地微信应用",
|
||||
},
|
||||
{
|
||||
title: '快捷键 「 Alt + Q」 关键字 「 取色」',
|
||||
desc: '按下Alt + Q 直接打开屏幕取色功能'
|
||||
}
|
||||
]
|
||||
}
|
||||
title: "快捷键 「 Alt + Q」 关键字 「 取色」",
|
||||
desc: "按下Alt + Q 直接打开屏幕取色功能",
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
changeShortCut(e, key) {
|
||||
@ -163,11 +205,10 @@ export default {
|
||||
},
|
||||
addConfig() {
|
||||
this.config.global.push({
|
||||
key: '',
|
||||
value: ''
|
||||
key: "",
|
||||
value: "",
|
||||
});
|
||||
},
|
||||
|
||||
changeGlobalKey(e, index) {
|
||||
let compose;
|
||||
if (e.altKey && e.keyCode !== 18) {
|
||||
@ -183,37 +224,37 @@ export default {
|
||||
compose = `Command+${keycodes[e.keyCode].toUpperCase()}`;
|
||||
}
|
||||
if (compose) {
|
||||
this.$set(this.config.global[index], 'key', compose);
|
||||
this.$set(this.config.global[index], "key", compose);
|
||||
}
|
||||
// f1 - f12
|
||||
if (e.keyCode >= 112 && e.keyCode <= 123) {
|
||||
compose = keycodes[e.keyCode].toUpperCase();
|
||||
}
|
||||
if (compose) {
|
||||
this.$set(this.config.global[index], 'key', compose);
|
||||
this.$set(this.config.global[index], "key", compose);
|
||||
}
|
||||
},
|
||||
changeGlobalValue(index, value) {
|
||||
this.$set(this.config.global[index], 'value', value);
|
||||
}
|
||||
this.$set(this.config.global[index], "value", value);
|
||||
},
|
||||
},
|
||||
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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">
|
||||
.pg-settings {
|
||||
height: calc(~'100vh - 110px');
|
||||
height: calc(~"100vh - 110px");
|
||||
overflow: auto;
|
||||
.dev-detail {
|
||||
height: 100%;
|
||||
@ -233,7 +274,7 @@ export default {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.title {
|
||||
color: #6C9FE2;
|
||||
color: #6c9fe2;
|
||||
font-size: 15px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
@ -251,7 +292,7 @@ export default {
|
||||
width: 300px;
|
||||
text-align: center;
|
||||
border: 1px solid #ddd;
|
||||
color: #6C9FE2;
|
||||
color: #6c9fe2;
|
||||
font-size: 14px;
|
||||
height: 24px;
|
||||
font-weight: lighter;
|
||||
@ -267,7 +308,6 @@ export default {
|
||||
font-size: 14px;
|
||||
.item {
|
||||
flex: 1;
|
||||
|
||||
}
|
||||
.short-cut {
|
||||
margin-left: 20px;
|
||||
@ -275,7 +315,7 @@ export default {
|
||||
.value {
|
||||
text-align: center;
|
||||
border: 1px solid #ddd;
|
||||
color: #6C9FE2;
|
||||
color: #6c9fe2;
|
||||
font-size: 14px;
|
||||
height: 24px;
|
||||
font-weight: lighter;
|
||||
@ -283,7 +323,7 @@ export default {
|
||||
}
|
||||
}
|
||||
.add-global {
|
||||
color: #6C9FE2;
|
||||
color: #6c9fe2;
|
||||
margin-top: 20px;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
|
Loading…
x
Reference in New Issue
Block a user