🐛 #80 修复 win depd bug

This commit is contained in:
muwoo 2022-01-13 18:38:44 +08:00
parent e5ff219685
commit 1e73ab5ee6
5 changed files with 35 additions and 38 deletions

View File

@ -1,6 +1,6 @@
{
"name": "rubick",
"version": "2.0.1-beta.15",
"version": "2.0.1-beta.16",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
@ -24,7 +24,6 @@
"fix-path": "^3.0.0",
"get-mac-apps": "^1.0.2",
"got": "^11.8.3",
"libnpmsearch": "^3.1.2",
"lodash.throttle": "^4.1.1",
"pouchdb": "^7.2.2",
"vue": "^3.0.0",

View File

@ -3,7 +3,6 @@ import {
AdapterInfo,
} from "@/core/plugin-handler/types";
import fs from "fs-extra";
import search, { Result } from "libnpmsearch";
import path from "path";
import got from "got";
import fixPath from "fix-path";
@ -90,30 +89,6 @@ class AdapterHandler {
await this.execCommand(installCmd, adapters);
}
/**
* npm
* streamFunc
* @param {string} adapter
* @param {(data: Result) => void} [streamFunc]
* @memberof AdapterHandler
*/
async search(adapter: string, streamFunc?: (data: Result) => void) {
return await new Promise<Result[]>((resolve, reject) => {
const result: Result[] = [];
const stream = search.stream(adapter);
stream.on("data", (data: Result) => {
result.push(data);
if (streamFunc !== undefined) streamFunc(data);
});
stream.on("end", () => {
resolve(result);
});
stream.on("error", (e: any) => {
reject(e);
});
});
}
/**
*
* @param {...string[]} adapters

View File

@ -1,6 +1,6 @@
<template>
<div v-show="!!options.length && (searchValue || !!clipboardFile.length) && !currentPlugin.name" class="options" ref="scrollDom">
<a-list item-layout="horizontal" :dataSource="options">
<a-list item-layout="horizontal" :dataSource="sort(options)">
<template #renderItem="{ item, index }">
<a-list-item
@click="() => item.click()"
@ -66,6 +66,20 @@ const renderDesc = (desc) => {
}
return desc;
};
const sort = (options) => {
for (let i = 0; i < options.length; i++) {
for (let j = i + 1; j < options.length; j++) {
if (options[j].zIndex > options[i].zIndex) {
let temp = options[i];
options[i] = options[j];
options[j] = temp;
}
}
}
return options;
};
</script>
<style lang="less">

View File

@ -178,7 +178,7 @@ const changeHideOnBlur = () => {
const getIcon = () => {
if (props.clipboardFile[0].dataUrl) return props.clipboardFile[0].dataUrl;
return props.clipboardFile[0].isFile ? require("../assets/file.png") : require("../assets/folder.png")
}
};
const newWindow = () => {
ipcRenderer.send("msg-trigger", {

View File

@ -54,6 +54,7 @@ const optionsManager = ({
icon: plugin.logo,
desc: fe.explain,
type: plugin.pluginType,
zIndex: cmd.label ? 0 : 1, // 排序权重
click: () => {
pluginClickEvent({
plugin,
@ -61,10 +62,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,
});
@ -101,14 +102,17 @@ const optionsManager = ({
}
})
.map((plugin) => {
plugin.click = () => {
openPlugin(plugin);
return {
...plugin,
zIndex: 1,
click: () => {
openPlugin(plugin);
},
};
return plugin;
}),
];
return options;
}
};
watch(searchValue, () => search(searchValue.value));
// search Input operation
@ -126,7 +130,12 @@ const optionsManager = ({
optionsRef.value = options;
};
const { searchFocus, clipboardFile, clearClipboardFile, readClipboardContent } = useFocus({
const {
searchFocus,
clipboardFile,
clearClipboardFile,
readClipboardContent,
} = useFocus({
currentPlugin,
optionsRef,
openPlugin,