mirror of
https://github.com/rubickCenter/rubick
synced 2025-10-26 14:42:43 +08:00
Compare commits
19 Commits
v0.0.3-bet
...
v0.0.7-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c893542b9 | ||
|
|
e9fa7b2276 | ||
|
|
db12d66ff7 | ||
|
|
9d3e7fc4a5 | ||
|
|
be21302738 | ||
|
|
a535c5d89b | ||
|
|
1eeb0fad9a | ||
|
|
511b357e28 | ||
|
|
87e7501c0a | ||
|
|
9242f17cde | ||
|
|
d047119076 | ||
|
|
5118fa6ca4 | ||
|
|
424c40a99c | ||
|
|
651e202ab1 | ||
|
|
614d5ae369 | ||
|
|
f287d10ca9 | ||
|
|
a04efd0d4f | ||
|
|
153d9dc5d7 | ||
|
|
de138955b5 |
11
.gitignore
vendored
11
.gitignore
vendored
@@ -1,12 +1,21 @@
|
||||
.DS_Store
|
||||
|
||||
dist/
|
||||
dist/electron/*
|
||||
dist/web/*
|
||||
|
||||
build/*
|
||||
!build/icons/
|
||||
|
||||
node_modules/
|
||||
|
||||
npm-debug.log
|
||||
npm-debug.log.*
|
||||
.pnpm-debug.log
|
||||
|
||||
thumbs.db
|
||||
!.gitkeep
|
||||
|
||||
.idea
|
||||
dist/
|
||||
.vscode
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"0 debug pnpm:scope": {
|
||||
"selected": 1
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,12 @@
|
||||
<a href="https://github.com/clouDr-f2e/rubick/blob/master/LICENSE">
|
||||
<img alt="npm" src="https://img.shields.io/github/license/clouDr-f2e/rubick" />
|
||||
</a>
|
||||
<img alt="star" src="https://img.shields.io/github/stars/clouDr-f2e/rubick?style=social"></a>
|
||||
|
||||
<a href="https://github.com/clouDr-f2e/rubick/stargazers">
|
||||
<img alt="star" src="https://img.shields.io/github/stars/clouDr-f2e/rubick?style=social">
|
||||
</a>
|
||||
<a href="https://gitee.com/monkeyWang/rubick">
|
||||
<img alt="码云" src="https://img.shields.io/badge/Gitee--yellow.svg?style=social&logo=data:image/svg+xml;base64,PHN2ZyB0PSIxNTc0ODM3MTM4ODM3IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjE3NzAiICAgICB3aWR0aD0iMTYiIGhlaWdodD0iMTYiPiAgICA8cGF0aCBkPSJNODkxIDQyOC44SDQ2NS44Yy0yMC40IDAtMzcgMTYuNS0zNyAzN3Y5Mi40YzAgMjAuNCAxNi41IDM3IDM3IDM3aDI1OC45YzIwLjQgMCAzNyAxNi42IDM3IDM3djE4LjRjMCA2MS4zLTQ5LjcgMTEwLjktMTEwLjkgMTEwLjlIMjk5LjRjLTIwLjQgMC0zNy0xNi42LTM3LTM3VjM3My4yYzAtNjEuMyA0OS43LTExMC45IDExMC45LTExMC45aDUxNy42YzIwLjQgMCAzNy0xNi41IDM3LTM3bDAuMS05Mi4zYzAtMjAuNC0xNi41LTM3LTM3LTM3SDM3My4zQzIyMC4yIDk2IDk2IDIyMC4yIDk2IDM3My4zVjg5MWMwIDIwLjQgMTYuNiAzNyAzNyAzN2g1NDUuNEM4MTYuMiA5MjggOTI4IDgxNi4zIDkyOCA2NzguNFY0NjUuOGMwLTIwLjQtMTYuNi0zNy0zNy0zN3oiICAgICAgICAgIGZpbGw9IiNkODFlMDYiIHAtaWQ9IjE3NzEiPjwvcGF0aD48L3N2Zz4="/>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
14
package.json
14
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rubick2",
|
||||
"version": "0.0.3-beta.9",
|
||||
"version": "0.0.7-beta.2",
|
||||
"author": "muwoo <2424880409@qq.com>",
|
||||
"description": "An electron-vue project",
|
||||
"license": null,
|
||||
@@ -11,7 +11,7 @@
|
||||
"dev": "node .electron-vue/dev-runner.js",
|
||||
"rebuild": " ./node_modules/.bin/electron-rebuild",
|
||||
"rebuild_win": "npm rebuild --runtime=electron --target=11.4.10 --disturl=https://atom.io/download/atom-shell --abi=85",
|
||||
"rebuild_linux": "npm rebuild --runtime=electron --target=12.0.15 --disturl=https://atom.io/download/atom-shell --abi=87"
|
||||
"rebuild_linux": "npm rebuild --runtime=electron --target=11.4.10 --disturl=https://atom.io/download/atom-shell --abi=85"
|
||||
},
|
||||
"build": {
|
||||
"asar": true,
|
||||
@@ -56,7 +56,9 @@
|
||||
},
|
||||
"linux": {
|
||||
"icon": "build/icons/",
|
||||
"publish": ["github"]
|
||||
"publish": [
|
||||
"github"
|
||||
]
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -67,6 +69,7 @@
|
||||
"download-git-repo": "^3.0.2",
|
||||
"electron-is-dev": "^2.0.0",
|
||||
"electron-store": "^8.0.0",
|
||||
"extract-file-icon": "^0.3.2",
|
||||
"iohook": "^0.9.3",
|
||||
"is-chinese": "^1.4.2",
|
||||
"jian-pinyin": "^0.2.3",
|
||||
@@ -82,6 +85,7 @@
|
||||
"request-promise": "^4.2.6",
|
||||
"robotjs": "git+https://github.com/Toinane/robotjs.git",
|
||||
"semver": "^7.3.5",
|
||||
"shelljs": "^0.8.4",
|
||||
"sudo-prompt": "^9.2.1",
|
||||
"systeminformation": "^5.8.0",
|
||||
"unzip": "^0.1.11",
|
||||
@@ -109,7 +113,7 @@
|
||||
"css-loader": "^0.28.11",
|
||||
"del": "^3.0.0",
|
||||
"devtron": "^1.4.0",
|
||||
"electron": "^12.0.15",
|
||||
"electron": "^11.4.10",
|
||||
"electron-builder": "22.10.5",
|
||||
"electron-debug": "^1.5.0",
|
||||
"electron-devtools-installer": "^2.2.4",
|
||||
@@ -140,7 +144,7 @@
|
||||
"iohook": {
|
||||
"targets": [
|
||||
"node-83",
|
||||
"electron-87"
|
||||
"electron-85"
|
||||
],
|
||||
"platforms": [
|
||||
"darwin",
|
||||
|
||||
@@ -14,7 +14,7 @@ module.exports = () => {
|
||||
win = new BrowserWindow({
|
||||
height: 60,
|
||||
useContentSize: true,
|
||||
resizable: false,
|
||||
resizable: true,
|
||||
width: 800,
|
||||
frame: false,
|
||||
title: '拉比克',
|
||||
|
||||
@@ -5,7 +5,7 @@ import pkg from '../../../package.json';
|
||||
const os = require('os');
|
||||
|
||||
const version = pkg.version;
|
||||
const releaseUrl = 'http://rubick-server.qa.91jkys.com/release/query';
|
||||
const releaseUrl = 'http://118.195.176.247:8080/release/query';
|
||||
|
||||
export async function autoUpdate() {
|
||||
let res;
|
||||
|
||||
@@ -7,7 +7,7 @@ const configPath = path.join(getlocalDataFile(), './rubick-config.json')
|
||||
|
||||
let defaultConfig = {
|
||||
Darwin: {
|
||||
version: 2,
|
||||
version: 3,
|
||||
perf: {
|
||||
shortCut: {
|
||||
showAndHidden: 'Option+R',
|
||||
@@ -32,7 +32,7 @@ let defaultConfig = {
|
||||
global: []
|
||||
},
|
||||
Windows_NT: {
|
||||
version: 2,
|
||||
version: 3,
|
||||
perf: {
|
||||
shortCut: {
|
||||
showAndHidden: 'Option+R',
|
||||
@@ -57,7 +57,7 @@ let defaultConfig = {
|
||||
global: []
|
||||
},
|
||||
Linux: {
|
||||
version: 1,
|
||||
version: 3,
|
||||
perf: {
|
||||
shortCut: {
|
||||
showAndHidden: 'Option+R',
|
||||
@@ -85,13 +85,13 @@ let defaultConfig = {
|
||||
global.opConfig = {
|
||||
config: null,
|
||||
get() {
|
||||
const platform = os.type()
|
||||
const platform = os.type();
|
||||
try {
|
||||
if (!opConfig.config) {
|
||||
opConfig.config = JSON.parse(fs.readFileSync(configPath) || JSON.stringify(defaultConfig[platform]))
|
||||
}
|
||||
// 重置
|
||||
if (!opConfig.version || opConfig.version < defaultConfig[platform].version) {
|
||||
if (!opConfig.config.version || opConfig.config.version < defaultConfig[platform].version) {
|
||||
opConfig.config = defaultConfig[platform]
|
||||
fs.writeFileSync(configPath, JSON.stringify(opConfig.config))
|
||||
}
|
||||
@@ -102,7 +102,7 @@ global.opConfig = {
|
||||
}
|
||||
},
|
||||
set(key, value) {
|
||||
opConfig.config[key] = value
|
||||
opConfig.config[key] = value;
|
||||
fs.writeFileSync(configPath, JSON.stringify(opConfig.config))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
import {app, nativeImage, BrowserWindow, clipboard, globalShortcut, ipcMain, Notification, screen, TouchBar} from "electron";
|
||||
import {
|
||||
app,
|
||||
nativeImage,
|
||||
BrowserWindow,
|
||||
clipboard,
|
||||
globalShortcut,
|
||||
ipcMain,
|
||||
Notification,
|
||||
screen,
|
||||
TouchBar
|
||||
} from 'electron';
|
||||
import {exec, spawn} from "child_process";
|
||||
import robot from "robotjs";
|
||||
import Api from "./api";
|
||||
@@ -54,7 +64,7 @@ class Listener {
|
||||
// 注册偏好快捷键
|
||||
globalShortcut.register(config.perf.shortCut.showAndHidden, () => {
|
||||
const {x, y} = screen.getCursorScreenPoint();
|
||||
const currentDisplay = screen.getDisplayNearestPoint({ x, y });
|
||||
const currentDisplay = screen.getDisplayNearestPoint({x, y});
|
||||
const wx = parseInt(currentDisplay.workArea.x + currentDisplay.workArea.width / 2 - 400);
|
||||
const wy = parseInt(currentDisplay.workArea.y + currentDisplay.workArea.height / 2 - 200);
|
||||
|
||||
@@ -86,7 +96,7 @@ class Listener {
|
||||
|
||||
init(mainWindow) {
|
||||
this.fn = throttle(({x, y}, picker) => {
|
||||
const { scaleFactor } = screen.getDisplayNearestPoint({x, y});
|
||||
const {scaleFactor} = screen.getDisplayNearestPoint({x, y});
|
||||
const img = robot.screen.capture(
|
||||
x - parseInt(5 / scaleFactor),
|
||||
y - parseInt(5 / scaleFactor),
|
||||
@@ -96,7 +106,7 @@ class Listener {
|
||||
|
||||
const colors = {}
|
||||
|
||||
for(let i = 0; i< 9; i++) {
|
||||
for (let i = 0; i < 9; i++) {
|
||||
colors[i] = {};
|
||||
for (let j = 0; j < 9; j++) {
|
||||
colors[i][j] = img.colorAt(j, i);
|
||||
@@ -142,7 +152,7 @@ class Listener {
|
||||
|
||||
const colors = {}
|
||||
|
||||
for(let i = 0; i< 9; i++) {
|
||||
for (let i = 0; i < 9; i++) {
|
||||
colors[i] = {};
|
||||
for (let j = 0; j < 9; j++) {
|
||||
colors[i][j] = img.colorAt(j, i);
|
||||
@@ -173,7 +183,7 @@ class Listener {
|
||||
let y = e.y
|
||||
const color = "#" + robot.getPixelColor(parseInt(x), parseInt(y));
|
||||
clipboard.writeText("#" + robot.getPixelColor(parseInt(x), parseInt(y)));
|
||||
new Notification({ title: 'Rubick 通知', body: `${color} 已保存到剪切板` }).show();
|
||||
new Notification({title: 'Rubick 通知', body: `${color} 已保存到剪切板`}).show();
|
||||
this.closePicker();
|
||||
}
|
||||
});
|
||||
@@ -195,7 +205,7 @@ class Listener {
|
||||
|
||||
initTouchBar(mainWindow) {
|
||||
if (!commonConst.macOS()) return;
|
||||
const { TouchBarButton, TouchBarGroup, TouchBarPopover } = TouchBar;
|
||||
const {TouchBarButton, TouchBarGroup, TouchBarPopover} = TouchBar;
|
||||
let items = [];
|
||||
let system = [];
|
||||
ipcMain.on('pluginInit', (e, args) => {
|
||||
@@ -218,7 +228,7 @@ class Listener {
|
||||
}).filter(Boolean);
|
||||
|
||||
system = args.plugins.map((item) => {
|
||||
if(item.type === 'system') {
|
||||
if (item.type === 'system') {
|
||||
return new TouchBarButton({
|
||||
icon: nativeImage.createFromDataURL(item.logo).resize({width: 20, height: 20}),
|
||||
click() {
|
||||
@@ -364,6 +374,7 @@ class Listener {
|
||||
windowMoveInit(win) {
|
||||
let hasInit = false;
|
||||
ipcMain.on('window-move', () => {
|
||||
let bounds = win.getBounds();
|
||||
if (!hasInit) {
|
||||
hasInit = true;
|
||||
ioHook.start(false);
|
||||
@@ -377,8 +388,9 @@ class Listener {
|
||||
const cursorPosition = screen.getCursorScreenPoint();
|
||||
const dx = winStartPosition.x + cursorPosition.x - mouseStartPosition.x;
|
||||
const dy = winStartPosition.y + cursorPosition.y - mouseStartPosition.y;
|
||||
let {x, y} = {x: dx, y: dy};
|
||||
win.setPosition(parseInt(x), parseInt(y));
|
||||
bounds.x = parseInt(dx);
|
||||
bounds.y = parseInt(dy);
|
||||
win.setBounds(bounds);
|
||||
});
|
||||
|
||||
ioHook.on('mouseup', e => {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { app, globalShortcut } from 'electron'
|
||||
import '../renderer/store'
|
||||
import init from './common/common'
|
||||
import { autoUpdate } from './common/autoUpdate'
|
||||
import createTray from './tray'
|
||||
import { commonConst } from './common/utils'
|
||||
import pkg from '../../package.json'
|
||||
import Store from 'electron-store';
|
||||
|
||||
Store.initRenderer()
|
||||
|
||||
const { main } = require("./browsers")()
|
||||
|
||||
@@ -106,4 +108,4 @@ class initApp {
|
||||
}
|
||||
}
|
||||
|
||||
(new initApp()).launchApp()
|
||||
(new initApp()).launchApp()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div @mousedown="drag" >
|
||||
<a-layout id="components-layout">
|
||||
<div @mousedown="drag">
|
||||
<a-layout id="components-layout">
|
||||
<div v-if="!searchType" class="rubick-select">
|
||||
<div class="tag-container" v-if="selected">
|
||||
<a-tag
|
||||
@@ -16,23 +16,26 @@
|
||||
<a-input
|
||||
id="search"
|
||||
:placeholder="
|
||||
subPlaceHolder && selected && selected.key === 'plugin-container'
|
||||
? subPlaceHolder
|
||||
: 'Hi, Rubick'
|
||||
"
|
||||
subPlaceHolder && selected && selected.key === 'plugin-container'
|
||||
? subPlaceHolder
|
||||
: 'Hi, Rubick'
|
||||
"
|
||||
@mousedown.stop="dragWhenInput"
|
||||
class="main-input"
|
||||
@change="(e) => search({ value: e.target.value })"
|
||||
@keydown.ctrl.86="shouldPaste"
|
||||
:value="searchValue"
|
||||
:maxLength="selected && selected.key !== 'plugin-container' ? 0 : 1000"
|
||||
:maxLength="
|
||||
selected && selected.key !== 'plugin-container' ? 0 : 1000
|
||||
"
|
||||
@keydown.down="(e) => changeCurrent(1)"
|
||||
@keydown.up="() => changeCurrent(-1)"
|
||||
@keypress.enter="
|
||||
(e) => targetSearch({ value: e.target.value, type: 'enter' })
|
||||
"
|
||||
(e) => targetSearch({ value: e.target.value, type: 'enter' })
|
||||
"
|
||||
@keypress.space="
|
||||
(e) => targetSearch({ value: e.target.value, type: 'space' })
|
||||
"
|
||||
(e) => targetSearch({ value: e.target.value, type: 'space' })
|
||||
"
|
||||
>
|
||||
<div @click="goMenu" class="suffix-tool" slot="suffix">
|
||||
<a-icon
|
||||
@@ -42,12 +45,14 @@
|
||||
/>
|
||||
<div v-if="selected && selected.icon" style="position: relative">
|
||||
<a-spin v-show="pluginLoading" class="loading">
|
||||
<a-icon slot="indicator" type="loading" style="font-size: 42px" spin />
|
||||
<a-icon
|
||||
slot="indicator"
|
||||
type="loading"
|
||||
style="font-size: 42px"
|
||||
spin
|
||||
/>
|
||||
</a-spin>
|
||||
<img
|
||||
class="icon-tool"
|
||||
:src="selected.icon"
|
||||
/>
|
||||
<img class="icon-tool" :src="selected.icon" />
|
||||
</div>
|
||||
<div v-else class="rubick-logo">
|
||||
<img src="./assets/imgs/logo.png" />
|
||||
@@ -87,19 +92,19 @@
|
||||
:placeholder="subPlaceHolder"
|
||||
class="sub-input"
|
||||
@change="
|
||||
(e) =>
|
||||
search({
|
||||
value: e.target.value,
|
||||
searchType: pluginInfo.searchType,
|
||||
})
|
||||
"
|
||||
(e) =>
|
||||
search({
|
||||
value: e.target.value,
|
||||
searchType: pluginInfo.searchType,
|
||||
})
|
||||
"
|
||||
:value="searchValue"
|
||||
@keypress.enter="
|
||||
(e) => targetSearch({ value: e.target.value, type: 'enter' })
|
||||
"
|
||||
(e) => targetSearch({ value: e.target.value, type: 'enter' })
|
||||
"
|
||||
@keypress.space="
|
||||
(e) => targetSearch({ value: e.target.value, type: 'space' })
|
||||
"
|
||||
(e) => targetSearch({ value: e.target.value, type: 'space' })
|
||||
"
|
||||
></a-input>
|
||||
</div>
|
||||
|
||||
@@ -121,6 +126,7 @@ import {
|
||||
searchKeyValues,
|
||||
fileLists,
|
||||
} from "./assets/common/utils";
|
||||
import { commonConst } from "../main/common/utils";
|
||||
const opConfig = remote.getGlobal("opConfig");
|
||||
const { Menu, MenuItem } = remote;
|
||||
|
||||
@@ -167,20 +173,21 @@ export default {
|
||||
const feature = plugin.features;
|
||||
feature.forEach((fe) => {
|
||||
const cmd = searchKeyValues(fe.cmds, args)[0];
|
||||
const systemPlugin = fileLists.filter(
|
||||
(plugin) => {
|
||||
let has = false;
|
||||
plugin.keyWords.some(keyWord => {
|
||||
if (keyWord.toLocaleUpperCase().indexOf(args.toLocaleUpperCase()) >= 0) {
|
||||
has = keyWord;
|
||||
plugin.name = keyWord;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return has;
|
||||
}
|
||||
)[0];
|
||||
const systemPlugin = fileLists.filter((plugin) => {
|
||||
let has = false;
|
||||
plugin.keyWords.some((keyWord) => {
|
||||
if (
|
||||
keyWord.toLocaleUpperCase().indexOf(args.toLocaleUpperCase()) >=
|
||||
0
|
||||
) {
|
||||
has = keyWord;
|
||||
plugin.name = keyWord;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return has;
|
||||
})[0];
|
||||
if (cmd) {
|
||||
config = {
|
||||
cmd: cmd,
|
||||
@@ -210,18 +217,56 @@ export default {
|
||||
...mapActions("main", ["onSearch", "showMainUI", "openPlugin"]),
|
||||
...mapMutations("main", ["commonUpdate"]),
|
||||
shouldPaste(e) {
|
||||
let filePath = '';
|
||||
if (process.platform === 'win32') {
|
||||
const rawFilePath = clipboard.read('FileNameW');
|
||||
filePath = rawFilePath.replace(new RegExp(String.fromCharCode(0), 'g'), '');
|
||||
if (filePath.indexOf('plugin.json') >= 0) {
|
||||
let filePath = "";
|
||||
if (commonConst.windows()) {
|
||||
const rawFilePath = clipboard.read("FileNameW");
|
||||
filePath = rawFilePath.replace(
|
||||
new RegExp(String.fromCharCode(0), "g"),
|
||||
""
|
||||
);
|
||||
if (filePath.indexOf("plugin.json") >= 0) {
|
||||
this.search({
|
||||
filePath,
|
||||
disableDebounce: true,
|
||||
});
|
||||
}
|
||||
} else if (commonConst.linux()) {
|
||||
const text = clipboard.readText("selection");
|
||||
// 在gnome的文件管理器中,复制文件的结果通常是
|
||||
//
|
||||
// x-special/nautilus-clipboard
|
||||
// copy
|
||||
// file:///home/admin/dir/plugin.json
|
||||
const splitLF = text.split(" ");
|
||||
let pathUrl;
|
||||
if (
|
||||
splitLF.length == 3 &&
|
||||
splitLF[0] === "x-special/nautilus-clipboard" &&
|
||||
splitLF[1] === "copy" &&
|
||||
(pathUrl = splitLF[2]).startsWith("file://") &&
|
||||
pathUrl.indexOf("plugin.json") >= 0
|
||||
) {
|
||||
filePath = pathUrl.slice(7);
|
||||
this.search({
|
||||
filePath,
|
||||
disableDebounce: true,
|
||||
});
|
||||
}
|
||||
// 其他的发行版、文件管理器尚未测试
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {Object} v 搜索配置对象。
|
||||
* 若v.disableDebounce为true,则不会触发防抖动保护。
|
||||
* 该值的作用是让search()方法被多个监听器同时调用时,在某些情况下无视其他监听器的防抖动保护。
|
||||
* 其他属性 v.value、v.filePath 参见 src/renderer/store/modules/main.js的onSearch函数。
|
||||
*/
|
||||
search(v) {
|
||||
console.log("search was called , param v is :", v);
|
||||
if (!v.disableDebounce) {
|
||||
this.onSearch(v);
|
||||
return;
|
||||
}
|
||||
if (!this.searchFn) {
|
||||
this.searchFn = debounce(this.onSearch, 200);
|
||||
}
|
||||
@@ -260,7 +305,7 @@ export default {
|
||||
|
||||
renderTitle(title) {
|
||||
if (typeof title !== "string") return;
|
||||
const result = title.split(this.searchValue);
|
||||
const result = title.toLowerCase().split(this.searchValue.toLowerCase());
|
||||
if (result && result.length > 1) {
|
||||
return `<div>${result[0]}<span style="color: red">${this.searchValue}</span>${result[1]}</div>`;
|
||||
} else {
|
||||
@@ -288,9 +333,13 @@ export default {
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight([]),
|
||||
});
|
||||
this.$router.push({
|
||||
path: "/home",
|
||||
});
|
||||
if (this.$router.history.current.fullPath !== "/home") {
|
||||
// 该if是为了避免跳转到相同路由而报错。
|
||||
// (之前在输入栏为空时按退格会疯狂报错)
|
||||
this.$router.push({
|
||||
path: "/home",
|
||||
});
|
||||
}
|
||||
},
|
||||
newWindow() {
|
||||
ipcRenderer.send("new-window", {
|
||||
@@ -340,8 +389,13 @@ export default {
|
||||
this.changePath({ key: "market" });
|
||||
},
|
||||
drag() {
|
||||
ipcRenderer.send('window-move');
|
||||
}
|
||||
ipcRenderer.send("window-move");
|
||||
},
|
||||
dragWhenInput(e) {
|
||||
if (this.searchValue == "") {
|
||||
ipcRenderer.send("window-move");
|
||||
}
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
...mapState("main", [
|
||||
@@ -479,7 +533,7 @@ export default {
|
||||
cursor: pointer;
|
||||
}
|
||||
.loading {
|
||||
position:absolute;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
120
src/renderer/assets/common/darwin-app.js
Normal file
120
src/renderer/assets/common/darwin-app.js
Normal file
@@ -0,0 +1,120 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import {nativeImage} from "electron";
|
||||
import translate from "./translate";
|
||||
import {APP_FINDER_PATH} from "./constans";
|
||||
import iconvLite from "iconv-lite";
|
||||
import bpList from "bplist-parser";
|
||||
|
||||
const fileLists = [];
|
||||
|
||||
const isZhRegex = /[\u4e00-\u9fa5]/;
|
||||
const getDisplayNameRegex = /\"(?:CFBundleDisplayName)\"\s\=\s\"(.*)\"/;
|
||||
|
||||
async function getAppZhName(rootPath, appName) {
|
||||
try {
|
||||
const ERROR_RESULT = '';
|
||||
const systemPath = path.join(rootPath, `${appName}/Contents/Resources/zh_CN.lproj/InfoPlist.strings`);
|
||||
const customizePath = path.join(rootPath, `${appName}/Contents/Resources/zh-Hans.lproj/InfoPlist.strings`);
|
||||
let appInfoPath = '';
|
||||
|
||||
if (fs.existsSync(systemPath)) {
|
||||
appInfoPath = systemPath;
|
||||
} else if (fs.existsSync(customizePath)) {
|
||||
appInfoPath = customizePath;
|
||||
} else {
|
||||
return ERROR_RESULT;
|
||||
}
|
||||
let appZhName = '';
|
||||
if (rootPath == '/Applications') {
|
||||
const container = iconvLite.decode(fs.readFileSync(appInfoPath), 'utf-16');
|
||||
if (container) {
|
||||
const res = container.match(getDisplayNameRegex);
|
||||
appZhName = res && res[1];
|
||||
} else {
|
||||
return ERROR_RESULT;
|
||||
}
|
||||
} else {
|
||||
const [{ CFBundleDisplayName = '', CFBundleName = '' }] = await bpList.parseFile(appInfoPath);
|
||||
appZhName = CFBundleDisplayName || CFBundleName;
|
||||
}
|
||||
|
||||
return appZhName;
|
||||
} catch (error) {
|
||||
return ERROR_RESULT;
|
||||
}
|
||||
}
|
||||
|
||||
function getDarwinAppList () {
|
||||
APP_FINDER_PATH.forEach((searchPath, index) => {
|
||||
fs.readdir(searchPath, async (err, files) => {
|
||||
try {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const appName = files[i];
|
||||
const extname = path.extname(appName);
|
||||
const appSubStr = appName.split(extname)[0];
|
||||
if ((extname === '.app' || extname === '.prefPane') >= 0) {
|
||||
try {
|
||||
const path1 = path.join(searchPath, `${appName}/Contents/Resources/App.icns`);
|
||||
const path2 = path.join(searchPath, `${appName}/Contents/Resources/AppIcon.icns`);
|
||||
const path3 = path.join(searchPath, `${appName}/Contents/Resources/${appSubStr}.icns`);
|
||||
const path4 = path.join(searchPath, `${appName}/Contents/Resources/${appSubStr.replace(' ', '')}.icns`);
|
||||
let iconPath = path1;
|
||||
if (fs.existsSync(path1)) {
|
||||
iconPath = path1;
|
||||
} else if (fs.existsSync(path2)) {
|
||||
iconPath = path2;
|
||||
} else if (fs.existsSync(path3)) {
|
||||
iconPath = path3;
|
||||
} else if (fs.existsSync(path4)) {
|
||||
iconPath = path4;
|
||||
} else {
|
||||
// 性能最低的方式
|
||||
const resourceList = fs.readdirSync(path.join(searchPath, `${appName}/Contents/Resources`));
|
||||
const iconName = resourceList.filter((file) => path.extname(file) === '.icns')[0];
|
||||
iconPath = path.join(searchPath, `${appName}/Contents/Resources/${iconName}`);
|
||||
}
|
||||
const img = await nativeImage.createThumbnailFromPath(iconPath, { width: 64, height: 64 });
|
||||
|
||||
const appZhName = await getAppZhName(searchPath, appName);
|
||||
|
||||
const fileOptions = {
|
||||
value: 'plugin',
|
||||
icon: img.toDataURL(),
|
||||
desc: path.join(searchPath, appName),
|
||||
type: 'app',
|
||||
action: `open ${path.join(searchPath, appName).replace(' ', '\\ ')}`,
|
||||
keyWords: [appSubStr]
|
||||
};
|
||||
|
||||
if (appZhName && isZhRegex.test(appZhName)) {
|
||||
const py = translate(appZhName);
|
||||
const pinyinArr = py.split(',');
|
||||
const firstLatter = pinyinArr.map(py => py[0]);
|
||||
// 拼音
|
||||
fileOptions.keyWords.push(pinyinArr.join(''));
|
||||
// 缩写
|
||||
fileOptions.keyWords.push(firstLatter.join(''));
|
||||
// 中文
|
||||
fileOptions.keyWords.push(appZhName);
|
||||
}
|
||||
|
||||
fileLists.push({
|
||||
...fileOptions,
|
||||
name: appSubStr,
|
||||
names: JSON.parse(JSON.stringify(fileOptions.keyWords)),
|
||||
});
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export const getApp = {
|
||||
init: getDarwinAppList,
|
||||
fileLists,
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
import { WINDOW_MAX_HEIGHT, WINDOW_MIN_HEIGHT, PRE_ITEM_HEIGHT, SYSTEM_PLUGINS } from './constans';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import process from 'child_process';
|
||||
import Store from 'electron-store';
|
||||
import downloadFile from 'download';
|
||||
import { nativeImage, ipcRenderer } from 'electron';
|
||||
import { APP_FINDER_PATH } from './constans';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { getlocalDataFile } from '../../../main/common/utils';
|
||||
import iconvLite from 'iconv-lite';
|
||||
import bpList from 'bplist-parser';
|
||||
import shell from 'shelljs';
|
||||
|
||||
import translate from './translate'
|
||||
const getApp = process.platform === 'win32' ? require('./win-app').getApp : require('./darwin-app').getApp;
|
||||
|
||||
const store = new Store();
|
||||
|
||||
getApp.init();
|
||||
const fileLists = getApp.fileLists;
|
||||
|
||||
function getWindowHeight(searchList) {
|
||||
if (!searchList) return WINDOW_MAX_HEIGHT;
|
||||
if (!searchList.length) return WINDOW_MIN_HEIGHT;
|
||||
@@ -24,8 +24,8 @@ function getWindowHeight(searchList) {
|
||||
|
||||
function searchKeyValues(lists, value) {
|
||||
return lists.filter((item) => {
|
||||
if (typeof item === 'string') return item.indexOf(value) >= 0;
|
||||
return item.type.indexOf(value) >= 0;
|
||||
if (typeof item === 'string') return item.toLowerCase().indexOf(value.toLowerCase()) >= 0;
|
||||
return item.type.toLowerCase().indexOf(value.toLowerCase()) >= 0;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ async function downloadZip(downloadRepoUrl, name) {
|
||||
const temp_dest = `${plugin_path}/${name}`;
|
||||
// 下载模板
|
||||
if (await existOrNot(temp_dest)) {
|
||||
await process.execSync(`rm -rf ${temp_dest}`);
|
||||
shell.rm('-rf', temp_dest);
|
||||
}
|
||||
|
||||
await downloadFile(downloadRepoUrl, plugin_path, { extract: true });
|
||||
@@ -158,110 +158,6 @@ function find(p, target = 'plugin.json') {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
const fileLists = [];
|
||||
// 默认搜索目录
|
||||
const isZhRegex = /[\u4e00-\u9fa5]/;
|
||||
const getDisplayNameRegex = /\"(?:CFBundleDisplayName)\"\s\=\s\"(.*)\"/;
|
||||
|
||||
async function getAppZhName(rootPath, appName) {
|
||||
try {
|
||||
const ERROR_RESULT = '';
|
||||
const systemPath = path.join(rootPath, `${appName}/Contents/Resources/zh_CN.lproj/InfoPlist.strings`);
|
||||
const customizePath = path.join(rootPath, `${appName}/Contents/Resources/zh-Hans.lproj/InfoPlist.strings`);
|
||||
let appInfoPath = '';
|
||||
|
||||
if (fs.existsSync(systemPath)) {
|
||||
appInfoPath = systemPath;
|
||||
} else if (fs.existsSync(customizePath)) {
|
||||
appInfoPath = customizePath;
|
||||
} else {
|
||||
return ERROR_RESULT;
|
||||
}
|
||||
let appZhName = '';
|
||||
if (rootPath == '/Applications') {
|
||||
const container = iconvLite.decode(fs.readFileSync(appInfoPath), 'utf-16');
|
||||
if (container) {
|
||||
const res = container.match(getDisplayNameRegex);
|
||||
appZhName = res && res[1];
|
||||
} else {
|
||||
return ERROR_RESULT;
|
||||
}
|
||||
} else {
|
||||
const [{ CFBundleDisplayName = '', CFBundleName = '' }] = await bpList.parseFile(appInfoPath);
|
||||
appZhName = CFBundleDisplayName || CFBundleName;
|
||||
}
|
||||
|
||||
return appZhName;
|
||||
} catch (error) {
|
||||
return ERROR_RESULT;
|
||||
}
|
||||
}
|
||||
APP_FINDER_PATH.forEach((searchPath, index) => {
|
||||
fs.readdir(searchPath, async (err, files) => {
|
||||
try {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const appName = files[i];
|
||||
const extname = path.extname(appName);
|
||||
const appSubStr = appName.split(extname)[0];
|
||||
if ((extname === '.app' || extname === '.prefPane') >= 0) {
|
||||
try {
|
||||
const path1 = path.join(searchPath, `${appName}/Contents/Resources/App.icns`);
|
||||
const path2 = path.join(searchPath, `${appName}/Contents/Resources/AppIcon.icns`);
|
||||
const path3 = path.join(searchPath, `${appName}/Contents/Resources/${appSubStr}.icns`);
|
||||
const path4 = path.join(searchPath, `${appName}/Contents/Resources/${appSubStr.replace(' ', '')}.icns`);
|
||||
let iconPath = path1;
|
||||
if (fs.existsSync(path1)) {
|
||||
iconPath = path1;
|
||||
} else if (fs.existsSync(path2)) {
|
||||
iconPath = path2;
|
||||
} else if (fs.existsSync(path3)) {
|
||||
iconPath = path3;
|
||||
} else if (fs.existsSync(path4)) {
|
||||
iconPath = path4;
|
||||
} else {
|
||||
// 性能最低的方式
|
||||
const resourceList = fs.readdirSync(path.join(searchPath, `${appName}/Contents/Resources`));
|
||||
const iconName = resourceList.filter((file) => path.extname(file) === '.icns')[0];
|
||||
iconPath = path.join(searchPath, `${appName}/Contents/Resources/${iconName}`);
|
||||
}
|
||||
const img = await nativeImage.createThumbnailFromPath(iconPath, { width: 64, height: 64 });
|
||||
|
||||
const appZhName = await getAppZhName(searchPath, appName);
|
||||
|
||||
const fileOptions = {
|
||||
value: 'plugin',
|
||||
icon: img.toDataURL(),
|
||||
desc: path.join(searchPath, appName),
|
||||
type: 'app',
|
||||
action: `open ${path.join(searchPath, appName).replace(' ', '\\ ')}`,
|
||||
keyWords: [appSubStr]
|
||||
};
|
||||
|
||||
if (appZhName && isZhRegex.test(appZhName)) {
|
||||
const py = translate(appZhName);
|
||||
const pinyinArr = py.split(',');
|
||||
const firstLatter = pinyinArr.map(py => py[0]);
|
||||
// 拼音
|
||||
fileOptions.keyWords.push(pinyinArr.join(''));
|
||||
// 缩写
|
||||
fileOptions.keyWords.push(firstLatter.join(''));
|
||||
// 中文
|
||||
fileOptions.keyWords.push(appZhName);
|
||||
}
|
||||
|
||||
fileLists.push({
|
||||
...fileOptions,
|
||||
name: appSubStr,
|
||||
names: JSON.parse(JSON.stringify(fileOptions.keyWords)),
|
||||
});
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function debounce(fn, delay) {
|
||||
let timer;
|
||||
|
||||
93
src/renderer/assets/common/win-app.js
Normal file
93
src/renderer/assets/common/win-app.js
Normal file
@@ -0,0 +1,93 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
import translate from './translate';
|
||||
import {shell} from 'electron';
|
||||
const fileIcon = require('extract-file-icon');
|
||||
const filePath = path.resolve('C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs');
|
||||
|
||||
const fileLists = [];
|
||||
const isZhRegex = /[\u4e00-\u9fa5]/;
|
||||
|
||||
const icondir = path.join(os.tmpdir(), 'ProcessIcon');
|
||||
const exists = fs.existsSync(icondir);
|
||||
if (!exists) { fs.mkdirSync(icondir) }
|
||||
|
||||
const getico = app =>{
|
||||
try {
|
||||
const buffer = fileIcon(app.desc, 32);
|
||||
const iconpath = path.join(icondir, `${app.name}.png`);
|
||||
|
||||
fs.exists(iconpath, exists => {
|
||||
if (!exists) {
|
||||
fs.writeFile(iconpath, buffer, 'base64', () => {});
|
||||
}
|
||||
});
|
||||
|
||||
} catch(e) {
|
||||
console.log(e, app.desc);
|
||||
}
|
||||
}
|
||||
|
||||
function fileDisplay(filePath){
|
||||
//根据文件路径读取文件,返回文件列表
|
||||
fs.readdir(filePath,function(err,files){
|
||||
if(err){
|
||||
console.warn(err)
|
||||
}else{
|
||||
files.forEach(function(filename){
|
||||
const filedir = path.join(filePath, filename);
|
||||
fs.stat(filedir,function(eror,stats){
|
||||
if(eror){
|
||||
console.warn('获取文件stats失败');
|
||||
} else {
|
||||
const isFile = stats.isFile(); // 是文件
|
||||
const isDir = stats.isDirectory(); // 是文件夹
|
||||
if(isFile){
|
||||
const appName = filename.split('.')[0];
|
||||
const keyWords = [appName];
|
||||
const appDetail = shell.readShortcutLink(filedir);
|
||||
if (!appDetail.target) return;
|
||||
|
||||
if (isZhRegex.test(appName)) {
|
||||
const py = translate(appName);
|
||||
const pinyinArr = py.split(',');
|
||||
const zh_firstLatter = pinyinArr.map(py => py[0]);
|
||||
// 拼音
|
||||
keyWords.push(pinyinArr.join(''));
|
||||
// 缩写
|
||||
keyWords.push(zh_firstLatter.join(''));
|
||||
} else {
|
||||
const firstLatter = appName.split(' ').map(name => name[0]).join('');
|
||||
keyWords.push(firstLatter);
|
||||
}
|
||||
|
||||
const icon = path.join(os.tmpdir(), 'ProcessIcon', `${encodeURIComponent(appName)}.png`);
|
||||
|
||||
const appInfo = {
|
||||
value: 'plugin',
|
||||
desc: appDetail.target,
|
||||
type: 'app',
|
||||
icon,
|
||||
action: `start "dummyclient" "${appDetail.target}"`,
|
||||
keyWords: keyWords,
|
||||
name: appName,
|
||||
names: JSON.parse(JSON.stringify(keyWords)),
|
||||
}
|
||||
fileLists.push(appInfo);
|
||||
getico(appInfo);
|
||||
}
|
||||
if(isDir) {
|
||||
fileDisplay(filedir); // 递归,如果是文件夹,就继续遍历该文件夹下面的文件
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export const getApp = {
|
||||
init: () => fileDisplay(filePath),
|
||||
fileLists
|
||||
}
|
||||
@@ -2,14 +2,19 @@
|
||||
<div class="market">
|
||||
<a-carousel v-if="bannerList && !!bannerList.length" arrows>
|
||||
<div
|
||||
slot="prevArrow"
|
||||
slot-scope="props"
|
||||
class="custom-slick-arrow"
|
||||
style="left: 10px;zIndex: 1"
|
||||
slot="prevArrow"
|
||||
slot-scope="props"
|
||||
class="custom-slick-arrow"
|
||||
style="left: 10px;zIndex: 1"
|
||||
>
|
||||
<a-icon type="left-circle" />
|
||||
</div>
|
||||
<div slot="nextArrow" slot-scope="props" class="custom-slick-arrow" style="right: 10px">
|
||||
<div
|
||||
slot="nextArrow"
|
||||
slot-scope="props"
|
||||
class="custom-slick-arrow"
|
||||
style="right: 10px"
|
||||
>
|
||||
<a-icon type="right-circle" />
|
||||
</div>
|
||||
<div v-for="banner in bannerList">
|
||||
@@ -18,38 +23,49 @@
|
||||
</a-carousel>
|
||||
<a-divider v-if="bannerList && !!bannerList.length"></a-divider>
|
||||
<h2>插件</h2>
|
||||
<a-list item-layout="horizontal" style="width: 100%" :grid="{ gutter: 16, column: 2 }" :data-source="pluginList">
|
||||
<a-list
|
||||
item-layout="horizontal"
|
||||
style="width: 100%"
|
||||
:grid="{ gutter: 16, column: 2 }"
|
||||
:data-source="pluginList"
|
||||
>
|
||||
<a-list-item slot="renderItem" slot-scope="item, index">
|
||||
<a-button v-if="showButton(item)" :loading="loading[index]" type="link" slot="actions" @click="download(index, item)">
|
||||
<a-icon v-show="!loading[index]" style="font-size: 20px;" type="cloud-download" />
|
||||
<a-button
|
||||
v-if="showButton(item)"
|
||||
:loading="loading[index]"
|
||||
type="link"
|
||||
slot="actions"
|
||||
@click="download(index, item)"
|
||||
>
|
||||
<a-icon
|
||||
v-show="!loading[index]"
|
||||
style="font-size: 20px;"
|
||||
type="cloud-download"
|
||||
/>
|
||||
</a-button>
|
||||
|
||||
|
||||
<a-list-item-meta
|
||||
@click="showPannel(item, index)"
|
||||
:description="item.description"
|
||||
@click="showPannel(item, index)"
|
||||
:description="item.description"
|
||||
>
|
||||
<div slot="title">{{ item.pluginName }}</div>
|
||||
<a-avatar
|
||||
slot="avatar"
|
||||
:src="item.logo"
|
||||
/>
|
||||
<a-avatar slot="avatar" :src="item.logo" />
|
||||
</a-list-item-meta>
|
||||
</a-list-item>
|
||||
</a-list>
|
||||
<a-drawer
|
||||
placement="right"
|
||||
:visible="show"
|
||||
@close="show=false"
|
||||
@close="show = false"
|
||||
width="100%"
|
||||
>
|
||||
<div class="plugin-market-desc" slot="title">
|
||||
<img width="80" :src="currentSelect.logo"/>
|
||||
<img width="80" :src="currentSelect.logo" />
|
||||
<div class="desc">
|
||||
<h4>{{currentSelect.pluginName}}</h4>
|
||||
<h4>{{ currentSelect.pluginName }}</h4>
|
||||
<div class="info">
|
||||
<div class="actor">
|
||||
开发者:{{currentSelect.author}}
|
||||
开发者:{{ currentSelect.author }}
|
||||
<a-button
|
||||
v-if="showButton(currentSelect)"
|
||||
:loading="loading[currentSelect.index]"
|
||||
@@ -60,7 +76,7 @@
|
||||
获取
|
||||
</a-button>
|
||||
</div>
|
||||
<div>{{currentSelect.description}}</div>
|
||||
<div>{{ currentSelect.description }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -70,10 +86,10 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import api from '../../../assets/api';
|
||||
import {mapActions, mapState} from 'vuex';
|
||||
import api from "../../../assets/api";
|
||||
import { mapActions, mapState } from "vuex";
|
||||
import marked from "marked";
|
||||
import {shell} from "electron";
|
||||
import { shell } from "electron";
|
||||
const rendererMD = new marked.Renderer();
|
||||
|
||||
export default {
|
||||
@@ -83,8 +99,8 @@ export default {
|
||||
loading: {},
|
||||
bannerList: [],
|
||||
show: false,
|
||||
currentSelect: {}
|
||||
}
|
||||
currentSelect: {},
|
||||
};
|
||||
},
|
||||
async created() {
|
||||
const [result, bannerRes] = await Promise.all([
|
||||
@@ -93,7 +109,7 @@ export default {
|
||||
]);
|
||||
this.pluginList = result.result;
|
||||
this.bannerList = bannerRes.result;
|
||||
console.log(bannerRes)
|
||||
console.log(bannerRes);
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -108,7 +124,9 @@ export default {
|
||||
this.$set(this.loading, index, false);
|
||||
},
|
||||
showButton(item) {
|
||||
return !this.devPlugins.filter(plugin => (plugin.name === item.name && plugin.type === 'prod')).length;
|
||||
return !this.devPlugins.filter(
|
||||
(plugin) => plugin.name === item.name && plugin.type === "prod"
|
||||
).length;
|
||||
},
|
||||
showPannel(item, index) {
|
||||
this.show = true;
|
||||
@@ -117,13 +135,13 @@ export default {
|
||||
},
|
||||
jumpTo(link) {
|
||||
if (link) {
|
||||
shell.openExternal(link)
|
||||
shell.openExternal(link);
|
||||
}
|
||||
},
|
||||
...mapActions('main', ['downloadPlugin'])
|
||||
...mapActions("main", ["downloadPlugin"]),
|
||||
},
|
||||
computed: {
|
||||
...mapState('main', ['devPlugins']),
|
||||
...mapState("main", ["devPlugins"]),
|
||||
readme() {
|
||||
marked.setOptions({
|
||||
renderer: rendererMD,
|
||||
@@ -133,17 +151,16 @@ export default {
|
||||
pedantic: false,
|
||||
sanitize: false,
|
||||
smartLists: true,
|
||||
smartypants: false
|
||||
smartypants: false,
|
||||
});
|
||||
try {
|
||||
return marked(this.currentSelect.detail);
|
||||
} catch (e) {
|
||||
return '暂无描述信息'
|
||||
return "暂无描述信息";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@@ -177,49 +194,48 @@ export default {
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
.market {
|
||||
height: calc(~'100vh - 110px');
|
||||
background: #fff;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
overflow: auto;
|
||||
.ant-carousel .slick-slide {
|
||||
text-align: center;
|
||||
height: 235px;
|
||||
line-height: 160px;
|
||||
background: #364d79;
|
||||
overflow: hidden;
|
||||
}
|
||||
.market {
|
||||
height: calc(~"100vh - 110px");
|
||||
background: #fff;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
overflow: auto;
|
||||
.ant-carousel .slick-slide {
|
||||
text-align: center;
|
||||
height: 235px;
|
||||
line-height: 160px;
|
||||
background: #364d79;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ant-carousel .custom-slick-arrow {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
font-size: 25px;
|
||||
color: #fff;
|
||||
background-color: rgba(31, 45, 61, 0.11);
|
||||
opacity: 0.3;
|
||||
}
|
||||
.ant-carousel .custom-slick-arrow:before {
|
||||
display: none;
|
||||
}
|
||||
.ant-carousel .custom-slick-arrow:hover {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.ant-carousel .slick-slide h3 {
|
||||
color: #fff;
|
||||
}
|
||||
.ant-list-item {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.ant-list-item-meta-description {
|
||||
width: 200px;
|
||||
overflow: hidden;
|
||||
text-overflow:ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
.ant-carousel .custom-slick-arrow {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
font-size: 25px;
|
||||
color: #fff;
|
||||
background-color: rgba(31, 45, 61, 0.11);
|
||||
opacity: 0.3;
|
||||
}
|
||||
.ant-carousel .custom-slick-arrow:before {
|
||||
display: none;
|
||||
}
|
||||
.ant-carousel .custom-slick-arrow:hover {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.ant-carousel .slick-slide h3 {
|
||||
color: #fff;
|
||||
}
|
||||
.ant-list-item {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.ant-list-item-meta-description {
|
||||
width: 200px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { clipboard, ipcRenderer, remote } from 'electron';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { clipboard, ipcRenderer, remote } from "electron";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import {
|
||||
getWindowHeight,
|
||||
searchKeyValues,
|
||||
@@ -7,34 +7,34 @@ import {
|
||||
mergePlugins,
|
||||
find,
|
||||
downloadZip,
|
||||
fileLists
|
||||
} from '../../assets/common/utils';
|
||||
import systemMethod from '../../assets/common/system';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { execSync } from 'child_process';
|
||||
fileLists,
|
||||
} from "../../assets/common/utils";
|
||||
import systemMethod from "../../assets/common/system";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { execSync } from "child_process";
|
||||
|
||||
const state = {
|
||||
selected: null,
|
||||
options: [],
|
||||
showMain: false,
|
||||
current: ['market'],
|
||||
searchValue: '',
|
||||
current: ["market"],
|
||||
searchValue: "",
|
||||
devPlugins: mergePlugins(sysFile.getUserPlugins() || []),
|
||||
subPlaceHolder: '',
|
||||
subPlaceHolder: "",
|
||||
pluginLoading: true,
|
||||
pluginInfo: (() => {
|
||||
try {
|
||||
return window.pluginInfo || {};
|
||||
} catch (e) {}
|
||||
})()
|
||||
})(),
|
||||
};
|
||||
|
||||
const mutations = {
|
||||
commonUpdate(state, payload) {
|
||||
Object.keys(payload).forEach((key) => {
|
||||
state[key] = payload[key];
|
||||
if (key === 'devPlugins') {
|
||||
if (key === "devPlugins") {
|
||||
sysFile.savePlugins(payload[key]);
|
||||
}
|
||||
});
|
||||
@@ -43,11 +43,15 @@ const mutations = {
|
||||
state.subPlaceHolder = payload;
|
||||
},
|
||||
deleteDevPlugin(state, payload) {
|
||||
state.devPlugins = state.devPlugins.filter((plugin) => plugin.name !== payload.name);
|
||||
state.devPlugins = state.devPlugins.filter(
|
||||
(plugin) => plugin.name !== payload.name
|
||||
);
|
||||
sysFile.savePlugins(state.devPlugins);
|
||||
},
|
||||
deleteProdPlugin(state, payload) {
|
||||
state.devPlugins = state.devPlugins.filter((plugin) => plugin.id !== payload.id);
|
||||
state.devPlugins = state.devPlugins.filter(
|
||||
(plugin) => plugin.id !== payload.id
|
||||
);
|
||||
sysFile.savePlugins(state.devPlugins);
|
||||
// todo 删除 static 目录下的对应插件
|
||||
},
|
||||
@@ -59,124 +63,136 @@ const mutations = {
|
||||
});
|
||||
state.devPlugins = [...state.devPlugins];
|
||||
sysFile.savePlugins(state.devPlugins);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const actions = {
|
||||
showMainUI({ commit, state }, paylpad) {
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight()
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight(),
|
||||
});
|
||||
setTimeout(() => {
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
showMain: true,
|
||||
selected: {
|
||||
key: 'market',
|
||||
name: '插件中心'
|
||||
}
|
||||
key: "market",
|
||||
name: "插件中心",
|
||||
},
|
||||
});
|
||||
}, 50);
|
||||
},
|
||||
reloadDevPlugin({ commit }, payload) {
|
||||
const config = JSON.parse(fs.readFileSync(path.join(payload.sourceFile, '../plugin.json'), 'utf-8'));
|
||||
const config = JSON.parse(
|
||||
fs.readFileSync(path.join(payload.sourceFile, "../plugin.json"), "utf-8")
|
||||
);
|
||||
const pluginConfig = {
|
||||
...config,
|
||||
sourceFile: path.join(payload.sourceFile, `../${config.main}`)
|
||||
sourceFile: path.join(payload.sourceFile, `../${config.main}`),
|
||||
};
|
||||
const devPlugins = [...state.devPlugins];
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
devPlugins: devPlugins.map((plugin) => {
|
||||
if (plugin.name === payload.name) {
|
||||
return {
|
||||
...plugin,
|
||||
...pluginConfig
|
||||
...pluginConfig,
|
||||
};
|
||||
}
|
||||
return plugin;
|
||||
})
|
||||
}),
|
||||
});
|
||||
},
|
||||
async onSearch({ commit }, paylpad) {
|
||||
if (state.selected && state.selected.key !== 'plugin-container') {
|
||||
commit('commonUpdate', { searchValue: '' });
|
||||
/**
|
||||
* @param {Object} payload payload.filePath为配置文件的绝对路径。payload.value为搜索栏文字值。
|
||||
*/
|
||||
async onSearch({ commit }, payload) {
|
||||
if (state.selected && state.selected.key !== "plugin-container") {
|
||||
commit("commonUpdate", { searchValue: "" });
|
||||
return;
|
||||
}
|
||||
const value = paylpad.value;
|
||||
const value = payload.value;
|
||||
// 在插件界面不触发其他功能
|
||||
if ((state.selected && state.selected.key === 'plugin-container') || paylpad.searchType === 'subWindow') {
|
||||
commit('commonUpdate', { searchValue: value });
|
||||
if (
|
||||
(state.selected && state.selected.key === "plugin-container") ||
|
||||
payload.searchType === "subWindow"
|
||||
) {
|
||||
commit("commonUpdate", { searchValue: value });
|
||||
return;
|
||||
}
|
||||
const fileUrl = paylpad.filePath || clipboard.read('public.file-url').replace('file://', '');
|
||||
commit('commonUpdate', { searchValue: value });
|
||||
const fileUrl =
|
||||
payload.filePath ||
|
||||
clipboard.read("public.file-url").replace("file://", "");
|
||||
commit("commonUpdate", { searchValue: value });
|
||||
// 复制文件
|
||||
if (paylpad.filePath || (fileUrl && value === 'plugin.json')) {
|
||||
const config = JSON.parse(fs.readFileSync(fileUrl, 'utf-8'));
|
||||
if (payload.filePath || (fileUrl && value === "plugin.json")) {
|
||||
const config = JSON.parse(fs.readFileSync(fileUrl, "utf-8"));
|
||||
|
||||
const pluginConfig = {
|
||||
...config,
|
||||
sourceFile: path.join(fileUrl, `../${config.main || 'index.html'}`),
|
||||
sourceFile: path.join(fileUrl, `../${config.main || "index.html"}`),
|
||||
id: uuidv4(),
|
||||
type: 'dev',
|
||||
icon: 'image://' + path.join(fileUrl, `../${config.logo}`),
|
||||
type: "dev",
|
||||
icon: "image://" + path.join(fileUrl, `../${config.logo}`),
|
||||
subType: (() => {
|
||||
if (config.main) {
|
||||
return '';
|
||||
return "";
|
||||
}
|
||||
return 'template';
|
||||
})()
|
||||
return "template";
|
||||
})(),
|
||||
};
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
selected: {
|
||||
key: 'plugin',
|
||||
name: 'plugin.json'
|
||||
key: "plugin",
|
||||
name: "plugin.json",
|
||||
},
|
||||
searchValue: '',
|
||||
searchValue: "",
|
||||
options: [
|
||||
{
|
||||
name: '新建rubick开发插件',
|
||||
value: 'new-plugin',
|
||||
icon: 'https://static.91jkys.com/activity/img/b37ff555c748489f88f3adac15b76f18.png',
|
||||
desc: '新建rubick开发插件',
|
||||
name: "新建rubick开发插件",
|
||||
value: "new-plugin",
|
||||
icon:
|
||||
"https://static.91jkys.com/activity/img/b37ff555c748489f88f3adac15b76f18.png",
|
||||
desc: "新建rubick开发插件",
|
||||
click: (router) => {
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
showMain: true,
|
||||
devPlugins: [pluginConfig, ...state.devPlugins],
|
||||
selected: {
|
||||
key: 'plugin',
|
||||
name: '新建rubick开发插件'
|
||||
key: "plugin",
|
||||
name: "新建rubick开发插件",
|
||||
},
|
||||
current: ['dev']
|
||||
current: ["dev"],
|
||||
});
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight()
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight(),
|
||||
});
|
||||
router.push('/home/dev');
|
||||
}
|
||||
router.push("/home/dev");
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '复制路径',
|
||||
desc: '复制路径',
|
||||
value: 'copy-path',
|
||||
icon: 'https://static.91jkys.com/activity/img/ac0d4df0247345b9a84c8cd7ea3dd696.png',
|
||||
name: "复制路径",
|
||||
desc: "复制路径",
|
||||
value: "copy-path",
|
||||
icon:
|
||||
"https://static.91jkys.com/activity/img/ac0d4df0247345b9a84c8cd7ea3dd696.png",
|
||||
click: () => {
|
||||
clipboard.writeText(fileUrl);
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
showMain: false,
|
||||
selected: null,
|
||||
options: []
|
||||
options: [],
|
||||
});
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight([])
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight([]),
|
||||
});
|
||||
remote.Notification('Rubick 通知', { body: '复制成功' });
|
||||
}
|
||||
}
|
||||
]
|
||||
remote.Notification("Rubick 通知", { body: "复制成功" });
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
// 调整窗口大小
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight(state.options)
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight(state.options),
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -187,7 +203,7 @@ const actions = {
|
||||
if (value) {
|
||||
state.devPlugins.forEach((plugin) => {
|
||||
// dev 插件未开启
|
||||
if (plugin.type === 'dev' && !plugin.status) return;
|
||||
if (plugin.type === "dev" && !plugin.status) return;
|
||||
const feature = plugin.features;
|
||||
feature.forEach((fe) => {
|
||||
const cmds = searchKeyValues(fe.cmds, value);
|
||||
@@ -195,14 +211,19 @@ const actions = {
|
||||
...options,
|
||||
...cmds.map((cmd) => ({
|
||||
name: cmd,
|
||||
value: 'plugin',
|
||||
icon: plugin.sourceFile ? 'image://' + path.join(plugin.sourceFile, `../${plugin.logo}`) : plugin.logo,
|
||||
value: "plugin",
|
||||
icon: plugin.sourceFile
|
||||
? "image://" + path.join(plugin.sourceFile, `../${plugin.logo}`)
|
||||
: plugin.logo,
|
||||
desc: fe.explain,
|
||||
type: plugin.type,
|
||||
click: (router) => {
|
||||
actions.openPlugin({ commit }, { cmd, plugin, feature: fe, router });
|
||||
}
|
||||
}))
|
||||
actions.openPlugin(
|
||||
{ commit },
|
||||
{ cmd, plugin, feature: fe, router }
|
||||
);
|
||||
},
|
||||
})),
|
||||
];
|
||||
});
|
||||
});
|
||||
@@ -215,8 +236,12 @@ const actions = {
|
||||
if (!descMap.get(plugin)) {
|
||||
descMap.set(plugin, true);
|
||||
let has = false;
|
||||
plugin.keyWords.some(keyWord => {
|
||||
if (keyWord.toLocaleUpperCase().indexOf(value.toLocaleUpperCase()) >= 0) {
|
||||
plugin.keyWords.some((keyWord) => {
|
||||
if (
|
||||
keyWord
|
||||
.toLocaleUpperCase()
|
||||
.indexOf(value.toLocaleUpperCase()) >= 0
|
||||
) {
|
||||
has = keyWord;
|
||||
plugin.name = keyWord;
|
||||
return true;
|
||||
@@ -233,17 +258,17 @@ const actions = {
|
||||
actions.openPlugin({ commit }, { plugin });
|
||||
};
|
||||
return plugin;
|
||||
})
|
||||
}),
|
||||
];
|
||||
|
||||
descMap = null;
|
||||
}
|
||||
|
||||
commit('commonUpdate', {
|
||||
options
|
||||
commit("commonUpdate", {
|
||||
options,
|
||||
});
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight(state.options)
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight(state.options),
|
||||
});
|
||||
},
|
||||
async downloadPlugin({ commit }, payload) {
|
||||
@@ -251,88 +276,90 @@ const actions = {
|
||||
const fileUrl = find(distUrl);
|
||||
|
||||
// 复制文件
|
||||
const config = JSON.parse(fs.readFileSync(`${fileUrl}/plugin.json`, 'utf-8'));
|
||||
const config = JSON.parse(
|
||||
fs.readFileSync(`${fileUrl}/plugin.json`, "utf-8")
|
||||
);
|
||||
const pluginConfig = {
|
||||
...config,
|
||||
id: uuidv4(),
|
||||
sourceFile: `${fileUrl}/${config.main}`,
|
||||
type: 'prod',
|
||||
type: "prod",
|
||||
icon: payload.logo,
|
||||
subType: (() => {
|
||||
if (config.main) {
|
||||
return '';
|
||||
return "";
|
||||
}
|
||||
return 'template';
|
||||
})()
|
||||
return "template";
|
||||
})(),
|
||||
};
|
||||
commit('commonUpdate', {
|
||||
devPlugins: [pluginConfig, ...state.devPlugins]
|
||||
commit("commonUpdate", {
|
||||
devPlugins: [pluginConfig, ...state.devPlugins],
|
||||
});
|
||||
},
|
||||
openPlugin({ commit }, { cmd, plugin, feature, router, payload }) {
|
||||
if (plugin.type === 'app') {
|
||||
if (plugin.type === "app") {
|
||||
execSync(plugin.action);
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
selected: null,
|
||||
showMain: false,
|
||||
options: [],
|
||||
searchValue: ''
|
||||
searchValue: "",
|
||||
});
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight([])
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight([]),
|
||||
});
|
||||
return;
|
||||
}
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
selected: {
|
||||
key: 'plugin-container',
|
||||
key: "plugin-container",
|
||||
name: cmd.label ? cmd.label : cmd,
|
||||
icon: 'image://' + path.join(plugin.sourceFile, `../${plugin.logo}`)
|
||||
icon: "image://" + path.join(plugin.sourceFile, `../${plugin.logo}`),
|
||||
},
|
||||
searchValue: '',
|
||||
showMain: true
|
||||
searchValue: "",
|
||||
showMain: true,
|
||||
});
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight()
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight(),
|
||||
});
|
||||
if (plugin.type === 'system') {
|
||||
if (plugin.type === "system") {
|
||||
systemMethod[plugin.tag][feature.code]();
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
selected: null,
|
||||
showMain: false,
|
||||
options: []
|
||||
options: [],
|
||||
});
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight([])
|
||||
ipcRenderer.send("changeWindowSize-rubick", {
|
||||
height: getWindowHeight([]),
|
||||
});
|
||||
router.push({
|
||||
path: '/home'
|
||||
path: "/home",
|
||||
});
|
||||
return;
|
||||
}
|
||||
commit('commonUpdate', {
|
||||
commit("commonUpdate", {
|
||||
pluginInfo: {
|
||||
cmd,
|
||||
...plugin,
|
||||
detail: feature,
|
||||
payload
|
||||
}
|
||||
payload,
|
||||
},
|
||||
});
|
||||
|
||||
router.push({
|
||||
path: '/plugin',
|
||||
path: "/plugin",
|
||||
query: {
|
||||
...plugin,
|
||||
_modify: Date.now(),
|
||||
detail: JSON.stringify(feature)
|
||||
}
|
||||
detail: JSON.stringify(feature),
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions
|
||||
actions,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const {getData, getlocalDataFile, saveData} = require("./utils");
|
||||
|
||||
const axios = require('axios');
|
||||
const marked = require("marked");
|
||||
const rendererMD = new marked.Renderer();
|
||||
const path = require('path');
|
||||
@@ -22,7 +22,7 @@ function getQueryVariable(variable) {
|
||||
if (location.href.indexOf('targetFile') > -1) {
|
||||
filePath = decodeURIComponent(getQueryVariable('targetFile'));
|
||||
} else {
|
||||
filePath = process.platform === 'win32' ? location.pathname.split(':')[1] : location.pathname.replace('file://', '');
|
||||
filePath = process.platform === 'win32' ? location.pathname.replace('/', '') : location.pathname.replace('file://', '');
|
||||
}
|
||||
const {ipcRenderer, nativeImage, clipboard, remote, shell} = require('electron');
|
||||
|
||||
@@ -255,6 +255,14 @@ window.rubick = {
|
||||
|
||||
shellOpenPath(path) {
|
||||
shell.openPath(path)
|
||||
},
|
||||
|
||||
request(config = {}) {
|
||||
return axios.create({
|
||||
timeout: 10000,
|
||||
withCredentials: true,
|
||||
...config,
|
||||
});
|
||||
}
|
||||
}
|
||||
const preloadPath = getQueryVariable('preloadPath') || './preload.js';
|
||||
|
||||
Reference in New Issue
Block a user