API 部分迁移完成

This commit is contained in:
muwoo
2021-12-08 13:45:40 +08:00
parent a9827c6db1
commit 951f21f5fa
17 changed files with 818 additions and 39 deletions

View File

@@ -22,7 +22,7 @@
<script setup lang="ts">
import { watch, ref, nextTick, toRaw } from "vue";
import { ipcRenderer } from "electron";
import { ipcRenderer, remote } from "electron";
import Result from "./components/result.vue";
import Search from "./components/search.vue";
import getWindowHeight from "../common/utils/getWindowHeight";
@@ -51,6 +51,7 @@ getPluginInfo({
pluginPath: `${__static}/feature/package.json`,
}).then((res) => {
menuPluginInfo.value = res;
remote.getGlobal("LOCAL_PLUGINS").addPlugin(res);
});
watch([searchValue], () => {

View File

@@ -80,6 +80,10 @@ const createPluginManager = (): any => {
const removePlugin = (plugin: any) => {
// todo
};
window.updatePlugin = ({ currentPlugin }: any) => {
state.currentPlugin = currentPlugin;
remote.getGlobal("LOCAL_PLUGINS").updatePlugin(currentPlugin);
};
return {
...toRefs(state),

View File

@@ -1,5 +1,5 @@
import { reactive, toRefs } from "vue";
import {ipcRenderer} from "electron";
import { ipcRenderer, remote } from "electron";
const searchManager = () => {
const state = reactive({
@@ -24,6 +24,12 @@ const searchManager = () => {
window.setSubInput = ({ placeholder }: { placeholder: string }) => {
state.placeholder = placeholder;
};
window.removeSubInput = () => {
state.placeholder = "";
};
window.setSubInputValue = ({ value }: { value: string }) => {
state.searchValue = value;
};
return {
...toRefs(state),

View File

@@ -15,4 +15,7 @@ declare module 'lodash.throttle'
interface Window {
setSubInput: ({ placeholder }: { placeholder: string }) => void;
setSubInputValue: ({ value }: { value: string }) => void;
removeSubInput: () => void;
updatePlugin: (plugin: any) => void;
}