mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-25 03:49:26 +08:00
✨ 支持 setSubInput API
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
@openMenu="openMenu"
|
||||
@changeSelect="changeSelect"
|
||||
:searchValue="searchValue"
|
||||
:placeholder="placeholder"
|
||||
/>
|
||||
</div>
|
||||
<Result
|
||||
@@ -36,6 +37,7 @@ const {
|
||||
changeSelect,
|
||||
openPlugin,
|
||||
currentPlugin,
|
||||
placeholder,
|
||||
} = createPluginManager();
|
||||
|
||||
initPlugins();
|
||||
@@ -89,5 +91,4 @@ const openMenu = () => {
|
||||
width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
<a-input
|
||||
id="search"
|
||||
class="main-input"
|
||||
placeholder="Hi, Rubick2"
|
||||
@input="(e) => changeValue(e)"
|
||||
@keydown.down="() => emit('changeCurrent', 1)"
|
||||
@keydown.up="() => emit('changeCurrent', -1)"
|
||||
@keydown="checkNeedInit"
|
||||
:value="searchValue"
|
||||
:placeholder="placeholder || 'Hi, Rubick2'"
|
||||
>
|
||||
<template #suffix>
|
||||
<div @click="() => emit('openMenu')" class="suffix-tool" >
|
||||
@@ -31,6 +31,10 @@ const props = defineProps({
|
||||
type: [String, Number],
|
||||
default: "",
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
currentPlugin: {},
|
||||
});
|
||||
|
||||
|
||||
@@ -47,10 +47,11 @@ const createPluginManager = (): any => {
|
||||
// @ts-ignore
|
||||
// document.getElementById("search").value = "";
|
||||
// state.searchValue = "";
|
||||
setSearchValue("");
|
||||
}
|
||||
};
|
||||
|
||||
const { searchValue, onSearch } = searchManager();
|
||||
const { searchValue, onSearch, setSearchValue, placeholder } = searchManager();
|
||||
const { options } = optionsManager({
|
||||
searchValue,
|
||||
baseDir,
|
||||
@@ -91,6 +92,7 @@ const createPluginManager = (): any => {
|
||||
changeSelect,
|
||||
options,
|
||||
searchValue,
|
||||
placeholder,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,19 +1,34 @@
|
||||
import { reactive, toRefs } from "vue";
|
||||
import {ipcRenderer} from "electron";
|
||||
|
||||
const searchManager = () => {
|
||||
const state = reactive({
|
||||
searchValue: "",
|
||||
placeholder: "",
|
||||
});
|
||||
|
||||
// search Input operation
|
||||
const onSearch = (e) => {
|
||||
const value = e.target.value;
|
||||
state.searchValue = value;
|
||||
ipcRenderer.sendSync("msg-trigger", {
|
||||
type: "sendSubInputChangeEvent",
|
||||
data: value,
|
||||
});
|
||||
};
|
||||
|
||||
const setSearchValue = (value: string) => {
|
||||
state.searchValue = value;
|
||||
};
|
||||
|
||||
window.setSubInput = ({ placeholder }: { placeholder: string }) => {
|
||||
state.placeholder = placeholder;
|
||||
};
|
||||
|
||||
return {
|
||||
...toRefs(state),
|
||||
onSearch,
|
||||
setSearchValue,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
4
src/renderer/shims-vue.d.ts
vendored
4
src/renderer/shims-vue.d.ts
vendored
@@ -12,3 +12,7 @@ declare module 'main' {
|
||||
declare const __static: string
|
||||
|
||||
declare module 'lodash.throttle'
|
||||
|
||||
interface Window {
|
||||
setSubInput: ({ placeholder }: { placeholder: string }) => void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user