mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-26 04:19:27 +08:00
chore: API改为类,成员函数变量增加static关键字 & yarn lint
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
<template>
|
||||
<div v-if="commonConst.windows() || commonConst.linux()" class="drag-bar"></div>
|
||||
<div :class="!commonConst.windows() && !commonConst.linux() && 'drag'" id="components-layout">
|
||||
<div
|
||||
v-if="commonConst.windows() || commonConst.linux()"
|
||||
class="drag-bar"
|
||||
></div>
|
||||
<div
|
||||
:class="!commonConst.windows() && !commonConst.linux() && 'drag'"
|
||||
id="components-layout"
|
||||
>
|
||||
<div class="rubick-select">
|
||||
<Search
|
||||
:currentPlugin="currentPlugin"
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
<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="sort(options)">
|
||||
<template #renderItem="{ item, index }">
|
||||
<a-list-item
|
||||
@@ -11,10 +19,7 @@
|
||||
<span v-html="renderTitle(item.name)"></span>
|
||||
</template>
|
||||
<template #avatar>
|
||||
<a-avatar
|
||||
style="border-radius: 0"
|
||||
:src="item.icon"
|
||||
/>
|
||||
<a-avatar style="border-radius: 0" :src="item.icon" />
|
||||
</template>
|
||||
</a-list-item-meta>
|
||||
</a-list-item>
|
||||
@@ -62,7 +67,10 @@ const renderTitle = (title) => {
|
||||
|
||||
const renderDesc = (desc) => {
|
||||
if (desc.length > 80) {
|
||||
return `${desc.substr(0, 63)}...${desc.substr(desc.length - 14, desc.length)}`
|
||||
return `${desc.substr(0, 63)}...${desc.substr(
|
||||
desc.length - 14,
|
||||
desc.length
|
||||
)}`;
|
||||
}
|
||||
return desc;
|
||||
};
|
||||
@@ -79,7 +87,6 @@ const sort = (options) => {
|
||||
}
|
||||
return options;
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
<template>
|
||||
<div class="rubick-select">
|
||||
<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"
|
||||
>
|
||||
<img :src="getIcon()" />
|
||||
<div class="ellipse">{{ clipboardFile[0].name }}</div>
|
||||
<a-tag color="#aaa" v-if="clipboardFile.length > 1">{{ clipboardFile.length }}</a-tag>
|
||||
<a-tag color="#aaa" v-if="clipboardFile.length > 1">{{
|
||||
clipboardFile.length
|
||||
}}</a-tag>
|
||||
</div>
|
||||
<a-input
|
||||
id="search"
|
||||
@@ -15,7 +19,7 @@
|
||||
@input="(e) => changeValue(e)"
|
||||
@keydown.down="(e) => keydownEvent(e, 'down')"
|
||||
@keydown.up="(e) => keydownEvent(e, 'up')"
|
||||
@keydown="e => checkNeedInit(e)"
|
||||
@keydown="(e) => checkNeedInit(e)"
|
||||
:value="searchValue"
|
||||
:placeholder="placeholder || 'Hi, Rubick2'"
|
||||
@keypress.enter="(e) => keydownEvent(e, 'enter')"
|
||||
@@ -25,7 +29,10 @@
|
||||
<template #suffix>
|
||||
<div class="suffix-tool">
|
||||
<MoreOutlined @click="showSeparate()" class="icon-more" />
|
||||
<div v-if="currentPlugin && currentPlugin.logo" style="position: relative">
|
||||
<div
|
||||
v-if="currentPlugin && currentPlugin.logo"
|
||||
style="position: relative"
|
||||
>
|
||||
<a-spin v-show="pluginLoading" class="loading">
|
||||
<template #indicator>
|
||||
<LoadingOutlined style="font-size: 42px" />
|
||||
@@ -96,7 +103,7 @@ const keydownEvent = (e, key: string) => {
|
||||
modifiers,
|
||||
},
|
||||
});
|
||||
const runPluginDisable = e.target.value === "" || props.currentPlugin.name
|
||||
const runPluginDisable = e.target.value === "" || props.currentPlugin.name;
|
||||
switch (key) {
|
||||
case "up":
|
||||
emit("changeCurrent", -1);
|
||||
@@ -192,7 +199,9 @@ 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")
|
||||
return props.clipboardFile[0].isFile
|
||||
? require("../assets/file.png")
|
||||
: require("../assets/folder.png");
|
||||
};
|
||||
|
||||
const newWindow = () => {
|
||||
|
||||
@@ -4,12 +4,7 @@ import path from "path";
|
||||
import pluginClickEvent from "./pluginClickEvent";
|
||||
import { ref } from "vue";
|
||||
|
||||
export default ({
|
||||
currentPlugin,
|
||||
optionsRef,
|
||||
openPlugin,
|
||||
setOptionsRef,
|
||||
}) => {
|
||||
export default ({ currentPlugin, optionsRef, openPlugin, setOptionsRef }) => {
|
||||
const clipboardFile: any = ref([]);
|
||||
const searchFocus = () => {
|
||||
const config = remote.getGlobal("OP_CONFIG").get();
|
||||
@@ -30,7 +25,7 @@ export default ({
|
||||
icon: require("../assets/link.png"),
|
||||
desc: "复制路径到剪切板",
|
||||
click: () => {
|
||||
clipboard.writeText(fileList.map(file => file.path).join(","));
|
||||
clipboard.writeText(fileList.map((file) => file.path).join(","));
|
||||
ipcRenderer.send("msg-trigger", { type: "hideMainWindow" });
|
||||
},
|
||||
},
|
||||
@@ -54,7 +49,11 @@ export default ({
|
||||
const ext = path.extname(fileList[0].path);
|
||||
fe.cmds.forEach((cmd) => {
|
||||
const regImg = /\.(png|jpg|gif|jpeg|webp)$/;
|
||||
if (cmd.type === "img" && regImg.test(ext) && fileList.length === 1) {
|
||||
if (
|
||||
cmd.type === "img" &&
|
||||
regImg.test(ext) &&
|
||||
fileList.length === 1
|
||||
) {
|
||||
options.push({
|
||||
name: cmd.label,
|
||||
value: "plugin",
|
||||
@@ -69,7 +68,9 @@ export default ({
|
||||
ext: {
|
||||
code: fe.code,
|
||||
type: cmd.type || "text",
|
||||
payload: nativeImage.createFromPath(fileList[0].path).toDataURL(),
|
||||
payload: nativeImage
|
||||
.createFromPath(fileList[0].path)
|
||||
.toDataURL(),
|
||||
},
|
||||
openPlugin,
|
||||
});
|
||||
@@ -140,7 +141,7 @@ export default ({
|
||||
isDirectory: false,
|
||||
path: null,
|
||||
dataUrl,
|
||||
}
|
||||
},
|
||||
];
|
||||
const localPlugins = remote.getGlobal("LOCAL_PLUGINS").getLocalPlugins();
|
||||
const options: any = [];
|
||||
|
||||
@@ -11,7 +11,7 @@ import { PLUGIN_INSTALL_DIR as baseDir } from "@/common/constans/renderer";
|
||||
|
||||
const createPluginManager = (): any => {
|
||||
const pluginInstance = new PluginHandler({
|
||||
baseDir
|
||||
baseDir,
|
||||
});
|
||||
|
||||
const state: any = reactive({
|
||||
@@ -19,7 +19,7 @@ const createPluginManager = (): any => {
|
||||
plugins: [],
|
||||
localPlugins: [],
|
||||
currentPlugin: {},
|
||||
pluginLoading: false
|
||||
pluginLoading: false,
|
||||
});
|
||||
|
||||
const appList = ref([]);
|
||||
@@ -28,12 +28,12 @@ const createPluginManager = (): any => {
|
||||
appList.value = await appSearch(nativeImage);
|
||||
};
|
||||
|
||||
const loadPlugin = plugin => {
|
||||
const loadPlugin = (plugin) => {
|
||||
state.pluginLoading = true;
|
||||
state.currentPlugin = plugin;
|
||||
};
|
||||
|
||||
const openPlugin = plugin => {
|
||||
const openPlugin = (plugin) => {
|
||||
if (plugin.pluginType === "ui" || plugin.pluginType === "system") {
|
||||
if (state.currentPlugin && state.currentPlugin.name === plugin.name) {
|
||||
return;
|
||||
@@ -47,10 +47,10 @@ const createPluginManager = (): any => {
|
||||
ext: plugin.ext || {
|
||||
code: plugin.feature.code,
|
||||
type: plugin.cmd.type || "text",
|
||||
payload: null
|
||||
}
|
||||
payload: null,
|
||||
},
|
||||
})
|
||||
)
|
||||
),
|
||||
});
|
||||
setSearchValue("");
|
||||
}
|
||||
@@ -66,12 +66,12 @@ const createPluginManager = (): any => {
|
||||
searchFocus,
|
||||
clipboardFile,
|
||||
clearClipboardFile,
|
||||
readClipboardContent
|
||||
readClipboardContent,
|
||||
} = optionsManager({
|
||||
searchValue,
|
||||
appList,
|
||||
openPlugin,
|
||||
currentPlugin: toRefs(state).currentPlugin
|
||||
currentPlugin: toRefs(state).currentPlugin,
|
||||
});
|
||||
// plugin operation
|
||||
const getPluginInfo = async ({ pluginName, pluginPath }) => {
|
||||
@@ -84,11 +84,11 @@ const createPluginManager = (): any => {
|
||||
icon: pluginInfo.logo,
|
||||
indexPath: commonConst.dev()
|
||||
? "http://localhost:8081/#/"
|
||||
: `file://${path.join(pluginPath, "../", pluginInfo.main)}`
|
||||
: `file://${path.join(pluginPath, "../", pluginInfo.main)}`,
|
||||
};
|
||||
};
|
||||
|
||||
const changeSelect = select => {
|
||||
const changeSelect = (select) => {
|
||||
state.currentPlugin = select;
|
||||
};
|
||||
|
||||
@@ -99,8 +99,8 @@ const createPluginManager = (): any => {
|
||||
const removePlugin = (plugin: any) => {
|
||||
// todo
|
||||
};
|
||||
|
||||
window.loadPlugin = plugin => loadPlugin(plugin);
|
||||
|
||||
window.loadPlugin = (plugin) => loadPlugin(plugin);
|
||||
|
||||
window.updatePlugin = ({ currentPlugin }: any) => {
|
||||
state.currentPlugin = currentPlugin;
|
||||
@@ -137,7 +137,7 @@ const createPluginManager = (): any => {
|
||||
searchFocus,
|
||||
clipboardFile,
|
||||
clearClipboardFile,
|
||||
readClipboardContent
|
||||
readClipboardContent,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -4,18 +4,10 @@ import { toRaw } from "vue";
|
||||
import commonConst from "@/common/utils/commonConst";
|
||||
|
||||
export default function pluginClickEvent({ plugin, fe, cmd, ext, openPlugin }) {
|
||||
const pluginPath = path.resolve(
|
||||
baseDir,
|
||||
"node_modules",
|
||||
plugin.name
|
||||
);
|
||||
const pluginPath = path.resolve(baseDir, "node_modules", plugin.name);
|
||||
const pluginDist = {
|
||||
...toRaw(plugin),
|
||||
indexPath: `file://${path.join(
|
||||
pluginPath,
|
||||
"./",
|
||||
plugin.main || ""
|
||||
)}`,
|
||||
indexPath: `file://${path.join(pluginPath, "./", plugin.main || "")}`,
|
||||
cmd: cmd.label || cmd,
|
||||
feature: fe,
|
||||
ext,
|
||||
|
||||
Reference in New Issue
Block a user