mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-16 00:16:58 +08:00
commit
735a450260
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rubick",
|
"name": "rubick",
|
||||||
"version": "2.0.1-beta.15",
|
"version": "2.0.1-beta.16",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
@ -19,11 +19,11 @@
|
|||||||
"ant-design-vue": "^2.2.8",
|
"ant-design-vue": "^2.2.8",
|
||||||
"core-js": "^3.6.5",
|
"core-js": "^3.6.5",
|
||||||
"cross-spawn": "^7.0.3",
|
"cross-spawn": "^7.0.3",
|
||||||
|
"electron-clipboard-ex": "^1.3.3",
|
||||||
"extract-file-icon": "^0.3.2",
|
"extract-file-icon": "^0.3.2",
|
||||||
"fix-path": "^3.0.0",
|
"fix-path": "^3.0.0",
|
||||||
"get-mac-apps": "^1.0.2",
|
"get-mac-apps": "^1.0.2",
|
||||||
"got": "^11.8.3",
|
"got": "^11.8.3",
|
||||||
"libnpmsearch": "^3.1.2",
|
|
||||||
"lodash.throttle": "^4.1.1",
|
"lodash.throttle": "^4.1.1",
|
||||||
"pouchdb": "^7.2.2",
|
"pouchdb": "^7.2.2",
|
||||||
"vue": "^3.0.0",
|
"vue": "^3.0.0",
|
||||||
|
@ -17,8 +17,9 @@ export default function getCopyFiles(): Array<any> | null {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else if (commonConst.windows()) {
|
} else if (commonConst.windows()) {
|
||||||
const filePath = clipboard.readBuffer('FileNameW').toString('ucs2').replace(RegExp(String.fromCharCode(0), 'g'), '');
|
/* eslint-disable */
|
||||||
fileInfo = [filePath];
|
const clipboardEx = require("electron-clipboard-ex");
|
||||||
|
fileInfo = clipboardEx.readFilePaths();
|
||||||
// todo
|
// todo
|
||||||
} else {
|
} else {
|
||||||
if (!commonConst.linux()) return null;
|
if (!commonConst.linux()) return null;
|
||||||
|
@ -3,7 +3,6 @@ import {
|
|||||||
AdapterInfo,
|
AdapterInfo,
|
||||||
} from "@/core/plugin-handler/types";
|
} from "@/core/plugin-handler/types";
|
||||||
import fs from "fs-extra";
|
import fs from "fs-extra";
|
||||||
import search, { Result } from "libnpmsearch";
|
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import got from "got";
|
import got from "got";
|
||||||
import fixPath from "fix-path";
|
import fixPath from "fix-path";
|
||||||
@ -90,30 +89,6 @@ class AdapterHandler {
|
|||||||
await this.execCommand(installCmd, adapters);
|
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 插件名称
|
* @param {...string[]} adapters 插件名称
|
||||||
|
@ -34,7 +34,6 @@ export default () => {
|
|||||||
// Load the index.html when not in development
|
// Load the index.html when not in development
|
||||||
win.loadURL("app://./index.html");
|
win.loadURL("app://./index.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
protocol.interceptFileProtocol("image", (req, callback) => {
|
protocol.interceptFileProtocol("image", (req, callback) => {
|
||||||
const url = req.url.substr(8);
|
const url = req.url.substr(8);
|
||||||
callback(decodeURI(url));
|
callback(decodeURI(url));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-show="!!options.length && (searchValue || !!clipboardFile.length) && !currentPlugin.name" class="options" ref="scrollDom">
|
<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 }">
|
<template #renderItem="{ item, index }">
|
||||||
<a-list-item
|
<a-list-item
|
||||||
@click="() => item.click()"
|
@click="() => item.click()"
|
||||||
@ -66,6 +66,20 @@ const renderDesc = (desc) => {
|
|||||||
}
|
}
|
||||||
return 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>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
<div class="select-tag" v-show="currentPlugin.cmd">{{ currentPlugin.cmd }}</div>
|
<div class="select-tag" v-show="currentPlugin.cmd">{{ currentPlugin.cmd }}</div>
|
||||||
<div :class="clipboardFile[0].name ? 'clipboard-tag' : 'clipboard-img'" v-if="!!clipboardFile.length">
|
<div :class="clipboardFile[0].name ? 'clipboard-tag' : 'clipboard-img'" v-if="!!clipboardFile.length">
|
||||||
<img :src="getIcon()" />
|
<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>
|
</div>
|
||||||
<a-input
|
<a-input
|
||||||
id="search"
|
id="search"
|
||||||
@ -177,7 +178,7 @@ const changeHideOnBlur = () => {
|
|||||||
const getIcon = () => {
|
const getIcon = () => {
|
||||||
if (props.clipboardFile[0].dataUrl) return props.clipboardFile[0].dataUrl;
|
if (props.clipboardFile[0].dataUrl) return props.clipboardFile[0].dataUrl;
|
||||||
return props.clipboardFile[0].isFile ? require("../assets/file.png") : require("../assets/folder.png")
|
return props.clipboardFile[0].isFile ? require("../assets/file.png") : require("../assets/folder.png")
|
||||||
}
|
};
|
||||||
|
|
||||||
const newWindow = () => {
|
const newWindow = () => {
|
||||||
ipcRenderer.send("msg-trigger", {
|
ipcRenderer.send("msg-trigger", {
|
||||||
@ -197,6 +198,12 @@ const newWindow = () => {
|
|||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
.ellipse {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
max-width: 200px;
|
||||||
|
}
|
||||||
.select-tag {
|
.select-tag {
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { createApp } from "vue";
|
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";
|
import App from "./App.vue";
|
||||||
|
|
||||||
createApp(App)
|
createApp(App)
|
||||||
@ -8,4 +8,5 @@ createApp(App)
|
|||||||
.use(Spin)
|
.use(Spin)
|
||||||
.use(Input)
|
.use(Input)
|
||||||
.use(Avatar)
|
.use(Avatar)
|
||||||
|
.use(Tag)
|
||||||
.mount("#app");
|
.mount("#app");
|
||||||
|
@ -120,8 +120,8 @@ export default ({
|
|||||||
clearClipboardFile();
|
clearClipboardFile();
|
||||||
window.setSubInputValue({ value: contentText });
|
window.setSubInputValue({ value: contentText });
|
||||||
}
|
}
|
||||||
}
|
|
||||||
clipboard.clear();
|
clipboard.clear();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearClipboardFile = () => {
|
const clearClipboardFile = () => {
|
||||||
|
@ -54,6 +54,7 @@ const optionsManager = ({
|
|||||||
icon: plugin.logo,
|
icon: plugin.logo,
|
||||||
desc: fe.explain,
|
desc: fe.explain,
|
||||||
type: plugin.pluginType,
|
type: plugin.pluginType,
|
||||||
|
zIndex: cmd.label ? 0 : 1, // 排序权重
|
||||||
click: () => {
|
click: () => {
|
||||||
pluginClickEvent({
|
pluginClickEvent({
|
||||||
plugin,
|
plugin,
|
||||||
@ -101,14 +102,17 @@ const optionsManager = ({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map((plugin) => {
|
.map((plugin) => {
|
||||||
plugin.click = () => {
|
return {
|
||||||
|
...plugin,
|
||||||
|
zIndex: 1,
|
||||||
|
click: () => {
|
||||||
openPlugin(plugin);
|
openPlugin(plugin);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
return plugin;
|
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
return options;
|
return options;
|
||||||
}
|
};
|
||||||
|
|
||||||
watch(searchValue, () => search(searchValue.value));
|
watch(searchValue, () => search(searchValue.value));
|
||||||
// search Input operation
|
// search Input operation
|
||||||
@ -126,7 +130,12 @@ const optionsManager = ({
|
|||||||
optionsRef.value = options;
|
optionsRef.value = options;
|
||||||
};
|
};
|
||||||
|
|
||||||
const { searchFocus, clipboardFile, clearClipboardFile, readClipboardContent } = useFocus({
|
const {
|
||||||
|
searchFocus,
|
||||||
|
clipboardFile,
|
||||||
|
clearClipboardFile,
|
||||||
|
readClipboardContent,
|
||||||
|
} = useFocus({
|
||||||
currentPlugin,
|
currentPlugin,
|
||||||
optionsRef,
|
optionsRef,
|
||||||
openPlugin,
|
openPlugin,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user