mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-25 11:59:27 +08:00
feat: 支持截屏,下载方式调整
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
export default {
|
||||
development: 'http://localhost:7001',
|
||||
development: 'http://rubick-server.qa.91jkys.com',
|
||||
production: 'http://rubick-server.qa.91jkys.com',
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ const PRE_ITEM_HEIGHT = 60;
|
||||
const SYSTEM_PLUGINS = [
|
||||
{
|
||||
"pluginName": "rubick 帮助文档",
|
||||
"logo": "logo.png",
|
||||
"logo": "https://static.91jkys.com/activity/img/4eb6f2848b064f569c28fdf8495d5ec7.png",
|
||||
"features": [
|
||||
{
|
||||
"code": "help",
|
||||
@@ -17,7 +17,7 @@ const SYSTEM_PLUGINS = [
|
||||
},
|
||||
{
|
||||
"pluginName": "屏幕颜色拾取",
|
||||
"logo": "logo.png",
|
||||
"logo": "https://static.91jkys.com/activity/img/6a1b4b8a17da45d680ea30b53a91aca8.png",
|
||||
"features": [
|
||||
{
|
||||
"code": "pick",
|
||||
@@ -26,6 +26,18 @@ const SYSTEM_PLUGINS = [
|
||||
},
|
||||
],
|
||||
"tag": 'rubick-color',
|
||||
},
|
||||
{
|
||||
"pluginName": "截屏",
|
||||
"logo": "https://static.91jkys.com/activity/img/b34d30b426f24eb2b77bf434b8493495.png",
|
||||
"features": [
|
||||
{
|
||||
"code": "shortCut",
|
||||
"explain": "rubick 屏幕截取",
|
||||
"cmds": [ "截屏", "shortCut" ]
|
||||
},
|
||||
],
|
||||
"tag": 'rubick-screen-short-cut',
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -9,5 +9,10 @@ export default {
|
||||
pick() {
|
||||
ipcRenderer.send('start-picker')
|
||||
}
|
||||
},
|
||||
'rubick-screen-short-cut': {
|
||||
shortCut() {
|
||||
ipcRenderer.send('capture-screen', {type: 'start'})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import path from 'path';
|
||||
import fs from 'fs';
|
||||
import process from 'child_process';
|
||||
import Store from 'electron-store';
|
||||
import downloadFile from 'download';
|
||||
|
||||
const store = new Store();
|
||||
|
||||
@@ -44,6 +45,21 @@ function mkdirFolder(name) {
|
||||
});
|
||||
}
|
||||
|
||||
async function downloadZip(downloadRepoUrl, name) {
|
||||
const plugin_path = path.join(__static, './plugins');
|
||||
const targetUrl = downloadRepoUrl ? downloadRepoUrl : `https://github.com/clouDr-f2e/${name}/archive/refs/heads/master.zip`;
|
||||
if (!(await existOrNot(plugin_path))) {
|
||||
await mkdirFolder(plugin_path);
|
||||
}
|
||||
// 基础模版所在目录,如果是初始化,则是模板名称,否则是项目名称
|
||||
const temp_dest = `${plugin_path}/${name}-master`;
|
||||
// 下载模板
|
||||
if (await existOrNot(temp_dest)) {
|
||||
await process.execSync(`rm -rf ${temp_dest}`);
|
||||
}
|
||||
await downloadFile(targetUrl, `${__static}/plugins`,{extract: true})
|
||||
}
|
||||
|
||||
function downloadFunc(downloadRepoUrl, name) {
|
||||
const targetGit = downloadRepoUrl ? downloadRepoUrl : `github:clouDr-f2e/${name}`;
|
||||
const plugin_path = path.join(__static, './plugins');
|
||||
@@ -82,7 +98,6 @@ const sysFile = {
|
||||
},
|
||||
getUserPlugins() {
|
||||
try {
|
||||
console.log(store.get('user-plugins').devPlugins)
|
||||
return store.get('user-plugins').devPlugins;
|
||||
} catch (e) {
|
||||
return []
|
||||
@@ -92,6 +107,7 @@ const sysFile = {
|
||||
store.delete('user-plugins');
|
||||
}
|
||||
}
|
||||
sysFile.removeAllPlugins()
|
||||
|
||||
function mergePlugins(plugins) {
|
||||
return [
|
||||
@@ -137,4 +153,5 @@ export {
|
||||
sysFile,
|
||||
mergePlugins,
|
||||
find,
|
||||
downloadZip,
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
sysFile,
|
||||
mergePlugins,
|
||||
find,
|
||||
downloadZip,
|
||||
} from '../../assets/common/utils';
|
||||
import systemMethod from '../../assets/common/system';
|
||||
import fs from "fs";
|
||||
@@ -179,7 +180,7 @@ const actions = {
|
||||
...cmds.map((cmd) => ({
|
||||
name: cmd,
|
||||
value: 'plugin',
|
||||
icon: 'image://' + path.join(plugin.sourceFile, `../${plugin.logo}`),
|
||||
icon: plugin.sourceFile ? 'image://' + path.join(plugin.sourceFile, `../${plugin.logo}`) : plugin.logo,
|
||||
desc: fe.explain,
|
||||
type: plugin.type,
|
||||
click: (router) => {
|
||||
@@ -199,8 +200,8 @@ const actions = {
|
||||
});
|
||||
},
|
||||
async downloadPlugin({commit}, payload) {
|
||||
await downloadFunc(payload.gitUrl, payload.name);
|
||||
const fileUrl = find(path.join(__static, `plugins/${payload.name}`));
|
||||
await downloadZip(payload.gitUrl, payload.name);
|
||||
const fileUrl = find(path.join(__static, `plugins/${payload.name}-master`));
|
||||
// 复制文件
|
||||
const config = JSON.parse(fs.readFileSync(`${fileUrl}/plugin.json`, 'utf-8'));
|
||||
const pluginConfig = {
|
||||
@@ -221,7 +222,7 @@ const actions = {
|
||||
icon: 'image://' + path.join(plugin.sourceFile, `../${plugin.logo}`),
|
||||
},
|
||||
searchValue: '',
|
||||
showMain: true,
|
||||
showMain: true
|
||||
});
|
||||
ipcRenderer.send('changeWindowSize-rubick', {
|
||||
height: getWindowHeight(),
|
||||
|
||||
Reference in New Issue
Block a user