mirror of
https://github.com/rubickCenter/rubick
synced 2025-07-20 14:49:31 +08:00
bugfix: 修复 安装包下载
This commit is contained in:
parent
0624be2d57
commit
96268de9d8
@ -69,6 +69,8 @@
|
|||||||
"puppeteer-in-electron": "^3.0.3",
|
"puppeteer-in-electron": "^3.0.3",
|
||||||
"query-string": "^7.0.0",
|
"query-string": "^7.0.0",
|
||||||
"robotjs": "git+ssh://git@github.com/Toinane/robotjs.git",
|
"robotjs": "git+ssh://git@github.com/Toinane/robotjs.git",
|
||||||
|
"sudo-prompt": "^9.2.1",
|
||||||
|
"unzip": "^0.1.11",
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
"vue": "^2.5.16",
|
"vue": "^2.5.16",
|
||||||
"vue-electron": "^1.0.6",
|
"vue-electron": "^1.0.6",
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
import {WINDOW_MAX_HEIGHT, WINDOW_MIN_HEIGHT, PRE_ITEM_HEIGHT, SYSTEM_PLUGINS} from './constans';
|
import {WINDOW_MAX_HEIGHT, WINDOW_MIN_HEIGHT, PRE_ITEM_HEIGHT, SYSTEM_PLUGINS} from './constans';
|
||||||
import download from 'download-git-repo';
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import process from 'child_process';
|
|
||||||
import Store from 'electron-store';
|
import Store from 'electron-store';
|
||||||
import downloadFile from 'download';
|
import downloadFile from 'download';
|
||||||
import {nativeImage} from 'electron';
|
import {nativeImage} from 'electron';
|
||||||
import {APP_FINDER_PATH} from './constans';
|
import {APP_FINDER_PATH} from './constans';
|
||||||
|
import {getlocalDataFile} from "../../../main/common/utils";
|
||||||
|
|
||||||
const store = new Store();
|
const store = new Store();
|
||||||
|
|
||||||
@ -35,69 +34,21 @@ function existOrNot(path) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function mkdirFolder(name) {
|
const appPath = getlocalDataFile();
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
process.exec(`mkdir ${name}`, async function (error, stdout, stderr) {
|
|
||||||
if (error) {
|
|
||||||
reject(false);
|
|
||||||
} else {
|
|
||||||
resolve(true);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function downloadZip(downloadRepoUrl, name) {
|
async function downloadZip(downloadRepoUrl, name) {
|
||||||
try {
|
try {
|
||||||
const plugin_path = path.join(__static, './plugins');
|
const plugin_path = appPath;
|
||||||
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`;
|
// const temp_dest = `${plugin_path}/${name}`;
|
||||||
// 下载模板
|
await downloadFile(downloadRepoUrl, plugin_path,{extract: true});
|
||||||
if (await existOrNot(temp_dest)) {
|
|
||||||
await process.execSync(`rm -rf ${temp_dest}`);
|
return `${plugin_path}/${name}`
|
||||||
}
|
|
||||||
await downloadFile(targetUrl, `${__static}/plugins`,{extract: true})
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadFunc(downloadRepoUrl, name) {
|
|
||||||
const targetGit = downloadRepoUrl ? downloadRepoUrl : `github:clouDr-f2e/${name}`;
|
|
||||||
const plugin_path = path.join(__static, './plugins');
|
|
||||||
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
try {
|
|
||||||
if (!(await existOrNot(plugin_path))) {
|
|
||||||
await mkdirFolder(plugin_path);
|
|
||||||
}
|
|
||||||
// 基础模版所在目录,如果是初始化,则是模板名称,否则是项目名称
|
|
||||||
const temp_dest = `${plugin_path}/${name}`;
|
|
||||||
// 下载模板
|
|
||||||
if (await existOrNot(temp_dest)) {
|
|
||||||
await process.execSync(`rm -rf ${temp_dest}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
download(targetGit, temp_dest, {clone: true}, function (err) {
|
|
||||||
console.log(err ? 'Error' : 'Success')
|
|
||||||
if (err) {
|
|
||||||
console.log(err);
|
|
||||||
reject('请求模板下载失败');
|
|
||||||
} else {
|
|
||||||
resolve('请求模板下载成功');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const sysFile = {
|
const sysFile = {
|
||||||
savePlugins(plugins) {
|
savePlugins(plugins) {
|
||||||
store.set('user-plugins', plugins);
|
store.set('user-plugins', plugins);
|
||||||
@ -113,7 +64,6 @@ const sysFile = {
|
|||||||
store.delete('user-plugins');
|
store.delete('user-plugins');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sysFile.removeAllPlugins()
|
|
||||||
|
|
||||||
function mergePlugins(plugins) {
|
function mergePlugins(plugins) {
|
||||||
return [
|
return [
|
||||||
@ -218,7 +168,6 @@ function debounce(fn, delay) {
|
|||||||
export {
|
export {
|
||||||
getWindowHeight,
|
getWindowHeight,
|
||||||
searchKeyValues,
|
searchKeyValues,
|
||||||
downloadFunc,
|
|
||||||
sysFile,
|
sysFile,
|
||||||
mergePlugins,
|
mergePlugins,
|
||||||
find,
|
find,
|
||||||
|
@ -73,6 +73,7 @@ export default {
|
|||||||
this.$set(this.loading, index, false);
|
this.$set(this.loading, index, false);
|
||||||
},
|
},
|
||||||
showButton(item) {
|
showButton(item) {
|
||||||
|
console.log(this.devPlugins)
|
||||||
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;
|
||||||
},
|
},
|
||||||
...mapActions('main', ['downloadPlugin'])
|
...mapActions('main', ['downloadPlugin'])
|
||||||
@ -89,6 +90,7 @@ export default {
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
overflow: auto;
|
||||||
.ant-carousel .slick-slide {
|
.ant-carousel .slick-slide {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
height: 235px;
|
height: 235px;
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<a-tabs default-active-key="1">
|
<a-tabs default-active-key="1">
|
||||||
<a-tab-pane key="1" tab="功能关键字">
|
<a-tab-pane key="1" tab="功能关键字">
|
||||||
<div class="detail-container">
|
<div class="feature-container">
|
||||||
<div class="desc-item" v-for="item in pluginDetail.features">
|
<div class="desc-item" v-for="item in pluginDetail.features">
|
||||||
<div>{{item.explain}}</div>
|
<div>{{item.explain}}</div>
|
||||||
<a-tag @click="openPlugin({cmd, plugin: pluginDetail, feature: item, router: $router})" v-for="cmd in item.cmds">{{cmd}}</a-tag>
|
<a-tag @click="openPlugin({cmd, plugin: pluginDetail, feature: item, router: $router})" v-for="cmd in item.cmds">{{cmd}}</a-tag>
|
||||||
@ -123,7 +123,7 @@ export default {
|
|||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.detail-container {
|
.detail-container, .feature-container {
|
||||||
height: 340px;
|
height: 340px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import { v4 as uuidv4 } from 'uuid';
|
|||||||
import {
|
import {
|
||||||
getWindowHeight,
|
getWindowHeight,
|
||||||
searchKeyValues,
|
searchKeyValues,
|
||||||
downloadFunc,
|
|
||||||
sysFile,
|
sysFile,
|
||||||
mergePlugins,
|
mergePlugins,
|
||||||
find,
|
find,
|
||||||
@ -221,8 +220,9 @@ const actions = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
async downloadPlugin({commit}, payload) {
|
async downloadPlugin({commit}, payload) {
|
||||||
await downloadZip(payload.gitUrl, payload.name);
|
const distUrl = await downloadZip(payload.downloadUrl, payload.name);
|
||||||
const fileUrl = find(path.join(__static, `plugins/${payload.name}-master`));
|
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 = {
|
const pluginConfig = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user