mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-25 03:49:26 +08:00
🐛 #77, 修复偏好设置不生效问题
This commit is contained in:
@@ -169,7 +169,7 @@ const showSeparate = () => {
|
||||
const changeHideOnBlur = () => {
|
||||
let cfg = { ...config.value };
|
||||
cfg.perf.common.hideOnBlur = !cfg.perf.common.hideOnBlur;
|
||||
opConfig.set("perf", cfg.perf);
|
||||
opConfig.set(cfg.perf);
|
||||
config.value = cfg;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ref, watch } from "vue";
|
||||
import throttle from "lodash.throttle";
|
||||
import { remote } from "electron";
|
||||
import { remote, ipcRenderer } from "electron";
|
||||
import pluginClickEvent from "./pluginClickEvent";
|
||||
import useFocus from "./clipboardWatch";
|
||||
|
||||
@@ -10,12 +10,12 @@ function formatReg(regStr) {
|
||||
return new RegExp(pattern, flags);
|
||||
}
|
||||
|
||||
function searchKeyValues(lists, value) {
|
||||
function searchKeyValues(lists, value, strict = false) {
|
||||
return lists.filter((item) => {
|
||||
if (typeof item === "string") {
|
||||
return item.toLowerCase().indexOf(value.toLowerCase()) >= 0;
|
||||
}
|
||||
if (item.type === "regex") {
|
||||
if (item.type === "regex" && !strict) {
|
||||
return formatReg(item.match).test(value);
|
||||
}
|
||||
return false;
|
||||
@@ -30,15 +30,13 @@ const optionsManager = ({
|
||||
}) => {
|
||||
const optionsRef = ref([]);
|
||||
|
||||
watch(searchValue, () => search(searchValue.value));
|
||||
// search Input operation
|
||||
const search = throttle((value) => {
|
||||
if (currentPlugin.value.name) return;
|
||||
if (clipboardFile.value.length) return;
|
||||
if (!value) {
|
||||
optionsRef.value = [];
|
||||
return;
|
||||
}
|
||||
// 全局快捷键
|
||||
ipcRenderer.on("global-short-key", (e, msg) => {
|
||||
const options = getOptionsFromSearchValue(msg, true);
|
||||
options[0].click();
|
||||
});
|
||||
|
||||
const getOptionsFromSearchValue = (value, strict = false) => {
|
||||
const localPlugins = remote.getGlobal("LOCAL_PLUGINS").getLocalPlugins();
|
||||
let options: any = [];
|
||||
// todo 先搜索 plugin
|
||||
@@ -47,7 +45,7 @@ const optionsManager = ({
|
||||
// 系统插件无 features 的情况,不需要再搜索
|
||||
if (!feature) return;
|
||||
feature.forEach((fe) => {
|
||||
const cmds = searchKeyValues(fe.cmds, value);
|
||||
const cmds = searchKeyValues(fe.cmds, value, strict);
|
||||
options = [
|
||||
...options,
|
||||
...cmds.map((cmd) => ({
|
||||
@@ -63,10 +61,10 @@ const optionsManager = ({
|
||||
cmd,
|
||||
ext: cmd.type
|
||||
? {
|
||||
code: fe.code,
|
||||
type: cmd.type || "text",
|
||||
payload: searchValue.value,
|
||||
}
|
||||
code: fe.code,
|
||||
type: cmd.type || "text",
|
||||
payload: searchValue.value,
|
||||
}
|
||||
: null,
|
||||
openPlugin,
|
||||
});
|
||||
@@ -109,7 +107,19 @@ const optionsManager = ({
|
||||
return plugin;
|
||||
}),
|
||||
];
|
||||
optionsRef.value = options;
|
||||
return options;
|
||||
}
|
||||
|
||||
watch(searchValue, () => search(searchValue.value));
|
||||
// search Input operation
|
||||
const search = throttle((value) => {
|
||||
if (currentPlugin.value.name) return;
|
||||
if (clipboardFile.value.length) return;
|
||||
if (!value) {
|
||||
optionsRef.value = [];
|
||||
return;
|
||||
}
|
||||
optionsRef.value = getOptionsFromSearchValue(value);
|
||||
}, 500);
|
||||
|
||||
const setOptionsRef = (options) => {
|
||||
|
||||
Reference in New Issue
Block a user