Compare commits

...

10 Commits

Author SHA1 Message Date
木偶
d3cbae7223 Update package.json 2022-08-08 18:01:42 +08:00
muwoo
f33941446d Merge remote-tracking branch 'origin/master' 2022-08-08 17:04:51 +08:00
muwoo
976075d1c6 🚑 修复 [#107] 2022-08-08 17:04:30 +08:00
muwoo
5b6995febe 🚑 修复 [#107] 2022-08-08 17:04:10 +08:00
muwoo
8acaff15f2 fix: #91 修复win下 ctrl+d 热键冲突问题 2022-06-29 16:55:22 +08:00
Layyback
b43c2c0091 🚑 reset the default database path 2022-06-01 00:25:45 +08:00
璃白
900a568ddf Merge pull request #110 from rubickCenter/feature/cherry-pick
🔨 cherry pick
2022-05-29 14:21:02 +08:00
layyback
8d3d55bdd8 🔨 cherry pick 2022-05-29 14:14:24 +08:00
muwoo
310dba0aa3 支持新的api 2022-05-09 11:21:03 +08:00
muwoo
343079d24f 支持新的api 2022-05-09 11:04:23 +08:00
20 changed files with 21439 additions and 88 deletions

1
.npmrc Normal file
View File

@@ -0,0 +1 @@
electron_mirror=https://npm.taobao.org/mirrors/electron/

View File

@@ -171,6 +171,6 @@ $ npm link
$ npm publish
```
然后再给 [rubick-database/plugins/total-plugins.json](https://gitee.com/monkeyWang/rubick-database/blob/master/plugins/total-plugins.json) 仓库提个 `pull request`, 把你的 `package.json` 信息加入 `json` 文件内,等我们 merge 了您的提交,插件将会自动上架。
然后再给 [rubick-database/plugins/total-plugins.json](https://gitcode.net/rubickcenter/rubick-database/-/blob/master/plugins/total-plugins.json) 仓库提个 `pull request`, 把你的 `package.json` 信息加入 `json` 文件内,等我们 merge 了您的提交,插件将会自动上架。

View File

@@ -54,7 +54,7 @@ macos 选择 `pkg` 文件windows 选择 `exe` 文件。
::: tip
如果把插件发布到公网 `npm` 如果不符合您的公司安全要求,`rubick` 支持内网私有源和私有插件库,如果您需要内网部署使用,可以自行配置以下规则。
:::
`rubick` 依赖 `npm` 仓库做插件管理,依赖 `gitee` 做插件数据存储所以如果要进行内网部署主要需要替换这2个设置。详细设置
`rubick` 依赖 `npm` 仓库做插件管理,依赖 `gitcode` 做插件数据存储所以如果要进行内网部署主要需要替换这2个设置。详细设置
`插件市场 -> 设置 -> 内网部署设置`
![image.png](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/1319b177fb544017ae10b4a703e8efa6~tplv-k3u1fbpfcp-watermark.image?)
@@ -62,9 +62,9 @@ macos 选择 `pkg` 文件windows 选择 `exe` 文件。
#### 1. 替换 npm 源
插件发布到私有 `npm` 源即可。
#### 2. 替换 `gitee` 源为内网 `gitlab`: database url
#### 2. 替换 `gitcode` 源为内网 `gitlab`: database url
* clone 下载 rubick 插件库:[https://gitee.com/monkeyWang/rubick-database](https://gitee.com/monkeyWang/rubick-database)
* clone 下载 rubick 插件库:[https://gitcode.net/rubickcenter/rubick-database](https://gitcode.net/rubickcenter/rubick-database)
* 提交仓库到私有 `gitlab` 库。
替换格式:`https://gitlab.xxx.com/api/v4/projects/{projectId}/repository/files/` 。因为接口为 `gitlab openAPI`,所以需要填写仓库 `access_token`

View File

@@ -1,6 +1,6 @@
import axios from "axios";
let baseURL = "https://gitee.com/monkeyWang/rubick-database/raw/master";
let baseURL = "https://gitcode.net/rubickcenter/rubick-database/-/raw/master";
let access_token = "";
try {
@@ -12,7 +12,7 @@ try {
}
const instance = axios.create({
baseURL: baseURL || "https://gitee.com/monkeyWang/rubick-database/raw/master",
baseURL: baseURL || "https://gitcode.net/rubickcenter/rubick-database/-/raw/master",
});
export default {

View File

@@ -1,7 +1,11 @@
<template>
<div class="installed">
<div v-if="!localPlugins.length">
<a-result status="404" title="暂无任何插件" sub-title="去插件市场选择安装合适的插件吧" />
<a-result
status="404"
title="暂无任何插件"
sub-title="去插件市场选择安装合适的插件吧"
/>
</div>
<div class="container" v-else>
<div class="installed-list">
@@ -44,8 +48,7 @@
@click="deletePlugin(pluginDetail)"
>
移除
</a-button
>
</a-button>
</div>
</div>
<a-tabs default-active-key="1">
@@ -61,6 +64,14 @@
:key="cmd"
v-for="cmd in item.cmds"
@close="removeFeature(cmd)"
@click="
!cmd.label &&
openPlugin({
code: item.code,
cmd
})
"
:class="{ executable: !cmd.label }"
:color="!cmd.label && '#87d068'"
>
{{ cmd.label || cmd }}
@@ -74,7 +85,6 @@
</a-tabs>
</div>
</div>
</div>
</template>
@@ -83,6 +93,7 @@ import { useStore } from "vuex";
import { computed, ref } from "vue";
import path from "path";
import MarkdownIt from "markdown-it";
const { ipcRenderer } = window.require("electron");
const { remote } = window.require("electron");
const fs = window.require("fs");
@@ -94,11 +105,11 @@ const baseDir = path.join(appPath, "./rubick-plugins");
const store = useStore();
const localPlugins = computed(() =>
store.state.localPlugins.filter(
(plugin) => plugin.name !== "rubick-system-feature"
plugin => plugin.name !== "rubick-system-feature"
)
);
const updateLocalPlugin = () => store.dispatch("updateLocalPlugin");
const startUnDownload = (name) => store.dispatch("startUnDownload", name);
const startUnDownload = name => store.dispatch("startUnDownload", name);
const currentSelect = ref([0]);
@@ -106,6 +117,23 @@ const pluginDetail = computed(() => {
return localPlugins.value[currentSelect.value] || {};
});
const openPlugin = ({ cmd, code }) => {
console.log(pluginDetail.value);
window.rubick.openPlugin(
JSON.parse(
JSON.stringify({
...pluginDetail.value,
cmd,
ext: {
code,
type: "text",
payload: null
}
})
)
);
};
const readme = computed(() => {
if (!pluginDetail.value.name) return "";
const readmePath = path.resolve(
@@ -121,7 +149,7 @@ const readme = computed(() => {
return "";
});
const deletePlugin = async (plugin) => {
const deletePlugin = async plugin => {
startUnDownload(plugin.name);
await window.market.deletePlugin(plugin);
updateLocalPlugin();
@@ -198,6 +226,15 @@ const deletePlugin = async (plugin) => {
.desc-item {
border-bottom: 1px solid #ddd;
padding: 10px 0;
.ant-tag {
margin-top: 6px;
&.executable {
cursor: pointer;
&:hover {
transform: translateY(-2px);
}
}
}
.desc-title {
display: flex;
align-items: center;

View File

@@ -333,6 +333,10 @@ const { shortCut, common, local, global } = toRefs(state);
font-weight: lighter;
margin-top: 10px;
position: relative;
:deep(.ant-input) {
color: #6c9fe2;
font-weight: lighter;
}
&.ant-input-affix-wrapper {
display: flex;
}

View File

@@ -19,7 +19,7 @@
</a-form-item>
<a-form-item has-feedback label="database url" name="database">
<a-input
placeholder="https://gitee.com/monkeyWang/rubick-database/raw/master"
placeholder="https://gitcode.net/rubickcenter/rubick-database/-/raw/master"
v-model:value="formState.database"
/>
</a-form-item>
@@ -43,7 +43,7 @@ let _rev: any;
let defaultConfig = {
register: "https://registry.npm.taobao.org",
database: "https://gitee.com/monkeyWang/rubick-database/raw/master",
database: "https://gitcode.net/rubickcenter/rubick-database/-/raw/master",
access_token: "",
};
@@ -69,7 +69,7 @@ const layout = {
const resetForm = () => {
formState.value = {
register: "https://registry.npm.taobao.org",
database: "https://gitee.com/monkeyWang/rubick-database/raw/master",
database: "https://gitcode.net/rubickcenter/rubick-database/-/raw/master",
access_token: "",
};
};

9469
feature/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "rubick",
"version": "2.0.3-beta.1",
"version": "2.0.4-beta.3",
"author": "muwoo <2424880409@qq.com>",
"private": true,
"scripts": {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -4,7 +4,7 @@ const os = require("os");
const ipcSendSync = (type, data) => {
const returnValue = ipcRenderer.sendSync("msg-trigger", {
type,
data,
data
});
if (returnValue instanceof Error) throw returnValue;
return returnValue;
@@ -13,7 +13,7 @@ const ipcSendSync = (type, data) => {
const ipcSend = (type, data) => {
ipcRenderer.send("msg-trigger", {
type,
data,
data
});
};
@@ -30,7 +30,9 @@ window.rubick = {
onPluginOut(cb) {
typeof cb === "function" && (window.rubick.hooks.onPluginOut = cb);
},
openPlugin(plugin) {
ipcSendSync("loadPlugin", plugin);
},
// 窗口交互
hideMainWindow() {
ipcSendSync("hideMainWindow");
@@ -49,7 +51,7 @@ window.rubick = {
(window.rubick.hooks.onSubInputChange = onChange);
ipcSendSync("setSubInput", {
placeholder,
isFocus,
isFocus
});
},
removeSubInput() {
@@ -74,15 +76,15 @@ window.rubick = {
copyText(text) {
return ipcSendSync("copyText", { text });
},
copyFile: (file) => {
return ipcSendSync("copyFile", { file })
copyFile: file => {
return ipcSendSync("copyFile", { file });
},
db: {
put: (data) => ipcSendSync("dbPut", { data }),
get: (id) => ipcSendSync("dbGet", { id }),
remove: (doc) => ipcSendSync("dbRemove", { doc }),
bulkDocs: (docs) => ipcSendSync("dbBulkDocs", { docs }),
allDocs: (key) => ipcSendSync("dbAllDocs", { key }),
put: data => ipcSendSync("dbPut", { data }),
get: id => ipcSendSync("dbGet", { id }),
remove: doc => ipcSendSync("dbRemove", { doc }),
bulkDocs: docs => ipcSendSync("dbBulkDocs", { docs }),
allDocs: key => ipcSendSync("dbAllDocs", { key })
},
dbStorage: {
setItem: (key, value) => {
@@ -93,14 +95,14 @@ window.rubick = {
const res = ipcSendSync("dbPut", { data: target });
if (res.error) throw new Error(res.message);
},
getItem: (key) => {
getItem: key => {
const res = ipcSendSync("dbGet", { id: key });
return res && "value" in res ? res.value : null;
},
removeItem: (key) => {
removeItem: key => {
const res = ipcSendSync("dbGet", { id: key });
res && ipcSendSync("dbRemove", { doc: res });
},
}
},
isDarkColors() {
return false;
@@ -145,4 +147,12 @@ window.rubick = {
shellShowItemInFolder: path => {
ipcSend("shellShowItemInFolder", { path });
},
redirect: (label, payload) => {
// todo
},
shellBeep: () => {
ipcSend("shellBeep")
},
};

View File

@@ -3,9 +3,11 @@ import path from "path";
import commonConst from "../../common/utils/commonConst";
import { PLUGIN_INSTALL_DIR as baseDir } from "@/common/constans/main";
const getRelativePath = (indexPath) => {
return commonConst.windows() ? indexPath.replace("file://", "") : indexPath.replace("file:", "");
}
const getRelativePath = indexPath => {
return commonConst.windows()
? indexPath.replace("file://", "")
: indexPath.replace("file:", "");
};
const getPreloadPath = (plugin, pluginIndexPath) => {
const { name, preload, tplPath, indexPath } = plugin;
@@ -54,8 +56,8 @@ export default () => {
devTools: true,
webviewTag: true,
preload,
session: ses,
},
session: ses
}
});
window.setBrowserView(view);
view.webContents.loadURL(pluginIndexPath);
@@ -67,6 +69,25 @@ export default () => {
executeHooks("PluginReady", plugin.ext);
window.webContents.executeJavaScript(`window.pluginLoaded()`);
});
// 修复请求跨域问题
view.webContents.session.webRequest.onBeforeSendHeaders(
(details, callback) => {
callback({
requestHeaders: { referer: "*", ...details.requestHeaders }
});
}
);
view.webContents.session.webRequest.onHeadersReceived(
(details, callback) => {
callback({
responseHeaders: {
"Access-Control-Allow-Origin": ["*"],
...details.responseHeaders
}
});
}
);
};
const removeView = (window: BrowserWindow) => {
@@ -95,6 +116,6 @@ export default () => {
init,
getView,
removeView,
executeHooks,
executeHooks
};
};

View File

@@ -6,7 +6,7 @@ import {
Notification,
nativeImage,
clipboard,
shell,
shell
} from "electron";
import { runner, detach } from "../browsers";
import fs from "fs";
@@ -37,7 +37,15 @@ export const API: any = {
return;
}
},
openPlugin({ plugin }, window) {
loadPlugin({ data: plugin }, window) {
window.webContents.executeJavaScript(
`window.loadPlugin(${JSON.stringify(plugin)})`
);
API.openPlugin({ data: plugin }, window);
},
openPlugin({ data: plugin }, window) {
if (API.currentPlugin && API.currentPlugin.name === plugin.name) return;
window.setSize(window.getSize()[0], 60);
runnerInstance.removeView(window);
@@ -45,7 +53,7 @@ export const API: any = {
API.currentPlugin = plugin;
window.webContents.executeJavaScript(
`window.setCurrentPlugin(${JSON.stringify({
currentPlugin: API.currentPlugin,
currentPlugin: API.currentPlugin
})})`
);
window.show();
@@ -86,7 +94,7 @@ export const API: any = {
if (!originWindow) return;
originWindow.webContents.executeJavaScript(
`window.setSubInput(${JSON.stringify({
placeholder: data.placeholder,
placeholder: data.placeholder
})})`
);
},
@@ -106,7 +114,7 @@ export const API: any = {
if (!originWindow) return;
originWindow.webContents.executeJavaScript(
`window.setSubInputValue(${JSON.stringify({
value: data.text,
value: data.text
})})`
);
},
@@ -121,7 +129,7 @@ export const API: any = {
const notify = new Notification({
title: plugin.pluginName,
body,
icon: plugin.logo,
icon: plugin.logo
});
notify.show();
},
@@ -166,7 +174,7 @@ export const API: any = {
...API.currentPlugin,
features: (() => {
let has = false;
API.currentPlugin.features.some((feature) => {
API.currentPlugin.features.some(feature => {
has = feature.code === data.feature.code;
return has;
});
@@ -174,11 +182,11 @@ export const API: any = {
return [...API.currentPlugin.features, data.feature];
}
return API.currentPlugin.features;
})(),
})()
};
window.webContents.executeJavaScript(
`window.updatePlugin(${JSON.stringify({
currentPlugin: API.currentPlugin,
currentPlugin: API.currentPlugin
})})`
);
return true;
@@ -186,16 +194,16 @@ export const API: any = {
removeFeature({ data }, window) {
API.currentPlugin = {
...API.currentPlugin,
features: API.currentPlugin.features.filter((feature) => {
features: API.currentPlugin.features.filter(feature => {
if (data.code.type) {
return feature.code.type !== data.code.type;
}
return feature.code !== data.code;
}),
})
};
window.webContents.executeJavaScript(
`window.updatePlugin(${JSON.stringify({
currentPlugin: API.currentPlugin,
currentPlugin: API.currentPlugin
})})`
);
return true;
@@ -207,12 +215,12 @@ export const API: any = {
runnerInstance.getView().webContents.sendInputEvent({
type: "keyDown",
modifiers,
keyCode: code,
keyCode: code
});
} else {
runnerInstance.getView().webContents.sendInputEvent({
type: "keyDown",
keyCode: code,
keyCode: code
});
}
},
@@ -223,11 +231,11 @@ export const API: any = {
window.setBrowserView(null);
window.webContents
.executeJavaScript(`window.getMainInputInfo()`)
.then((res) => {
.then(res => {
detachInstance.init(
{
...API.currentPlugin,
subInput: res,
subInput: res
},
window.getBounds(),
view
@@ -249,6 +257,11 @@ export const API: any = {
shell.showItemInFolder(data.path);
return true;
},
shellBeep() {
shell.beep();
return true;
},
};
export default (mainWindow: BrowserWindow) => {

View File

@@ -37,9 +37,9 @@ const registerHotKey = (mainWindow: BrowserWindow): void => {
mainWindow.show();
});
globalShortcut.register(config.perf.shortCut.separate, () => {
// todo
});
// globalShortcut.register(config.perf.shortCut.separate, () => {
//
// });
globalShortcut.register(config.perf.shortCut.quit, () => {
// mainWindow.webContents.send('init-rubick');

View File

@@ -39,14 +39,14 @@ const props = defineProps({
},
options: {
type: Array,
default: () => [],
default: (() => [])(),
},
currentSelect: {
type: Number,
default: 0,
},
currentPlugin: {},
clipboardFile: () => [],
clipboardFile: (() => [])(),
});
const renderTitle = (title) => {

View File

@@ -63,7 +63,7 @@ const props: any = defineProps({
},
currentPlugin: {},
pluginLoading: Boolean,
clipboardFile: () => [],
clipboardFile: (() => [])(),
});
const changeValue = (e) => {

View File

@@ -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,25 +28,29 @@ const createPluginManager = (): any => {
appList.value = await appSearch(nativeImage);
};
const openPlugin = (plugin) => {
const loadPlugin = plugin => {
state.pluginLoading = true;
state.currentPlugin = plugin;
};
const openPlugin = plugin => {
if (plugin.pluginType === "ui" || plugin.pluginType === "system") {
if (state.currentPlugin && state.currentPlugin.name === plugin.name) {
return;
}
state.pluginLoading = true;
state.currentPlugin = plugin;
loadPlugin(plugin);
ipcRenderer.sendSync("msg-trigger", {
type: "openPlugin",
plugin: JSON.parse(
data: JSON.parse(
JSON.stringify({
...plugin,
ext: plugin.ext || {
code: plugin.feature.code,
type: plugin.cmd.type || "text",
payload: null,
},
payload: null
}
})
),
)
});
setSearchValue("");
}
@@ -57,13 +61,18 @@ const createPluginManager = (): any => {
const { searchValue, onSearch, setSearchValue, placeholder } =
searchManager();
const { options, searchFocus, clipboardFile, clearClipboardFile, readClipboardContent } =
optionsManager({
searchValue,
appList,
openPlugin,
currentPlugin: toRefs(state).currentPlugin,
});
const {
options,
searchFocus,
clipboardFile,
clearClipboardFile,
readClipboardContent
} = optionsManager({
searchValue,
appList,
openPlugin,
currentPlugin: toRefs(state).currentPlugin
});
// plugin operation
const getPluginInfo = async ({ pluginName, pluginPath }) => {
const pluginInfo = await pluginInstance.getAdapterInfo(
@@ -75,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;
};
@@ -90,6 +99,9 @@ const createPluginManager = (): any => {
const removePlugin = (plugin: any) => {
// todo
};
window.loadPlugin = plugin => loadPlugin(plugin);
window.updatePlugin = ({ currentPlugin }: any) => {
state.currentPlugin = currentPlugin;
remote.getGlobal("LOCAL_PLUGINS").updatePlugin(currentPlugin);
@@ -125,7 +137,7 @@ const createPluginManager = (): any => {
searchFocus,
clipboardFile,
clearClipboardFile,
readClipboardContent,
readClipboardContent
};
};

View File

@@ -1,22 +1,23 @@
/* eslint-disable */
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
declare module "*.vue" {
import type { DefineComponent } from "vue";
const component: DefineComponent<{}, {}, any>;
export default component;
}
declare module 'main' {
export function main (): any
declare module "main" {
export function main(): any;
}
declare const __static: string
declare const __static: string;
declare module 'lodash.throttle'
declare module "lodash.throttle";
interface Window {
setSubInput: ({ placeholder }: { placeholder: string }) => void;
setSubInputValue: ({ value }: { value: string }) => void;
removeSubInput: () => void;
loadPlugin: (plugin: any) => void;
updatePlugin: (plugin: any) => void;
initRubick: () => void;
setCurrentPlugin: (plugin: any) => void;

11783
yarn.lock Normal file

File diff suppressed because it is too large Load Diff