支持文件检索呼起插件

This commit is contained in:
muwoo
2021-12-20 18:33:00 +08:00
parent ced8aa846b
commit ff118dfe2d
25 changed files with 351 additions and 70 deletions

View File

@@ -6,12 +6,12 @@
import { useRouter } from "vue-router";
const router = useRouter();
window.rubick.onPluginEnter(({ code }) => {
window.rubick.onPluginEnter(({ code, type, payload }) => {
const current = window.exports[code];
router.push({
name: current.mode,
params: {
code,
code, type, payload
},
});
});

View File

@@ -7,7 +7,7 @@
v-for="(item, index) in lists"
@click="select(item)"
>
<img class="icon" :src="item.icon" />
<img v-if="item.icon" class="icon" :src="item.icon" />
<div class="content">
<div class="title">{{ item.title }}</div>
<div class="desc">{{ decodeURIComponent(item.description) }}</div>
@@ -18,7 +18,7 @@
</template>
<script setup lang="ts">
import { useRoute } from "vue-router";
import { ref, onBeforeUnmount } from "vue";
import { ref, onBeforeUnmount, watch } from "vue";
const { ipcRenderer } = window.require("electron");
const route = useRoute();
@@ -27,14 +27,18 @@ const itemHeight = 60;
const itemMaxNum = 10;
const defaultHeight = 60;
const code = route.params.code;
const { code, type, payload } = route.params;
const current = window.exports[code];
window.rubick.setExpendHeight(defaultHeight);
const lists = ref([]);
watch([lists], () => {
const height = lists.value.length > itemMaxNum ? itemMaxNum * itemHeight : itemHeight * lists.value.length
window.rubick.setExpendHeight(defaultHeight + height);
});
current.args.enter &&
current.args.enter({ code: code, type: "", payload: [] }, (lists) => {
lists.value = lists;
current.args.enter({ code: code, type, payload }, (result) => {
lists.value = result;
});
const currentSelect = ref(0);
@@ -51,8 +55,6 @@ window.rubick.setSubInput(({ text }) => {
current.args.search &&
current.args.search({ code, type: "", payload: [] }, text, (result) => {
lists.value = result || [];
const height = lists.value.length > itemMaxNum ? itemMaxNum * itemHeight : itemHeight * lists.value.length
window.rubick.setExpendHeight(defaultHeight + height);
});
}, "搜索");