mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-13 06:54:05 +08:00
commit
735a450260
@ -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",
|
||||
@ -19,11 +19,11 @@
|
||||
"ant-design-vue": "^2.2.8",
|
||||
"core-js": "^3.6.5",
|
||||
"cross-spawn": "^7.0.3",
|
||||
"electron-clipboard-ex": "^1.3.3",
|
||||
"extract-file-icon": "^0.3.2",
|
||||
"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",
|
||||
|
@ -17,8 +17,9 @@ export default function getCopyFiles(): Array<any> | null {
|
||||
return null;
|
||||
}
|
||||
} else if (commonConst.windows()) {
|
||||
const filePath = clipboard.readBuffer('FileNameW').toString('ucs2').replace(RegExp(String.fromCharCode(0), 'g'), '');
|
||||
fileInfo = [filePath];
|
||||
/* eslint-disable */
|
||||
const clipboardEx = require("electron-clipboard-ex");
|
||||
fileInfo = clipboardEx.readFilePaths();
|
||||
// todo
|
||||
} else {
|
||||
if (!commonConst.linux()) return null;
|
||||
|
@ -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 插件名称
|
||||
|
@ -34,7 +34,6 @@ export default () => {
|
||||
// Load the index.html when not in development
|
||||
win.loadURL("app://./index.html");
|
||||
}
|
||||
|
||||
protocol.interceptFileProtocol("image", (req, callback) => {
|
||||
const url = req.url.substr(8);
|
||||
callback(decodeURI(url));
|
||||
|
@ -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">
|
||||
|
@ -3,7 +3,8 @@
|
||||
<div class="select-tag" v-show="currentPlugin.cmd">{{ currentPlugin.cmd }}</div>
|
||||
<div :class="clipboardFile[0].name ? 'clipboard-tag' : 'clipboard-img'" v-if="!!clipboardFile.length">
|
||||
<img :src="getIcon()" />
|
||||
{{ clipboardFile[0].name }}
|
||||
<div class="ellipse">{{ clipboardFile[0].name }}</div>
|
||||
<a-tag color="#aaa" v-if="clipboardFile.length > 1">{{ clipboardFile.length }}</a-tag>
|
||||
</div>
|
||||
<a-input
|
||||
id="search"
|
||||
@ -177,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", {
|
||||
@ -197,6 +198,12 @@ const newWindow = () => {
|
||||
left: 0;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
.ellipse {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-width: 200px;
|
||||
}
|
||||
.select-tag {
|
||||
white-space: pre;
|
||||
user-select: none;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createApp } from "vue";
|
||||
import { Button, List, Spin, Input, Avatar } from "ant-design-vue";
|
||||
import { Button, List, Spin, Input, Avatar, Tag } from "ant-design-vue";
|
||||
import App from "./App.vue";
|
||||
|
||||
createApp(App)
|
||||
@ -8,4 +8,5 @@ createApp(App)
|
||||
.use(Spin)
|
||||
.use(Input)
|
||||
.use(Avatar)
|
||||
.use(Tag)
|
||||
.mount("#app");
|
||||
|
@ -120,8 +120,8 @@ export default ({
|
||||
clearClipboardFile();
|
||||
window.setSubInputValue({ value: contentText });
|
||||
}
|
||||
clipboard.clear();
|
||||
}
|
||||
clipboard.clear();
|
||||
};
|
||||
|
||||
const clearClipboardFile = () => {
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user