mirror of
https://github.com/rubickCenter/rubick
synced 2025-07-19 06:09:41 +08:00
bugfix: 修复 安装包下载
This commit is contained in:
parent
0624be2d57
commit
96268de9d8
@ -69,6 +69,8 @@
|
||||
"puppeteer-in-electron": "^3.0.3",
|
||||
"query-string": "^7.0.0",
|
||||
"robotjs": "git+ssh://git@github.com/Toinane/robotjs.git",
|
||||
"sudo-prompt": "^9.2.1",
|
||||
"unzip": "^0.1.11",
|
||||
"uuid": "^8.3.2",
|
||||
"vue": "^2.5.16",
|
||||
"vue-electron": "^1.0.6",
|
||||
|
@ -1,12 +1,11 @@
|
||||
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 fs from 'fs';
|
||||
import process from 'child_process';
|
||||
import Store from 'electron-store';
|
||||
import downloadFile from 'download';
|
||||
import {nativeImage} from 'electron';
|
||||
import {APP_FINDER_PATH} from './constans';
|
||||
import {getlocalDataFile} from "../../../main/common/utils";
|
||||
|
||||
const store = new Store();
|
||||
|
||||
@ -35,69 +34,21 @@ function existOrNot(path) {
|
||||
});
|
||||
}
|
||||
|
||||
function mkdirFolder(name) {
|
||||
return new Promise((resolve, reject) => {
|
||||
process.exec(`mkdir ${name}`, async function (error, stdout, stderr) {
|
||||
if (error) {
|
||||
reject(false);
|
||||
} else {
|
||||
resolve(true);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
const appPath = getlocalDataFile();
|
||||
|
||||
async function downloadZip(downloadRepoUrl, name) {
|
||||
try {
|
||||
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 plugin_path = appPath;
|
||||
// 基础模版所在目录,如果是初始化,则是模板名称,否则是项目名称
|
||||
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})
|
||||
// const temp_dest = `${plugin_path}/${name}`;
|
||||
await downloadFile(downloadRepoUrl, plugin_path,{extract: true});
|
||||
|
||||
return `${plugin_path}/${name}`
|
||||
} catch (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 = {
|
||||
savePlugins(plugins) {
|
||||
store.set('user-plugins', plugins);
|
||||
@ -113,7 +64,6 @@ const sysFile = {
|
||||
store.delete('user-plugins');
|
||||
}
|
||||
}
|
||||
sysFile.removeAllPlugins()
|
||||
|
||||
function mergePlugins(plugins) {
|
||||
return [
|
||||
@ -218,7 +168,6 @@ function debounce(fn, delay) {
|
||||
export {
|
||||
getWindowHeight,
|
||||
searchKeyValues,
|
||||
downloadFunc,
|
||||
sysFile,
|
||||
mergePlugins,
|
||||
find,
|
||||
|
@ -73,6 +73,7 @@ export default {
|
||||
this.$set(this.loading, index, false);
|
||||
},
|
||||
showButton(item) {
|
||||
console.log(this.devPlugins)
|
||||
return !this.devPlugins.filter(plugin => (plugin.name === item.name && plugin.type === 'prod')).length;
|
||||
},
|
||||
...mapActions('main', ['downloadPlugin'])
|
||||
@ -89,6 +90,7 @@ export default {
|
||||
background: #fff;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
overflow: auto;
|
||||
.ant-carousel .slick-slide {
|
||||
text-align: center;
|
||||
height: 235px;
|
||||
|
@ -27,7 +27,7 @@
|
||||
</div>
|
||||
<a-tabs default-active-key="1">
|
||||
<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>{{item.explain}}</div>
|
||||
<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;
|
||||
}
|
||||
}
|
||||
.detail-container {
|
||||
.detail-container, .feature-container {
|
||||
height: 340px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ import { v4 as uuidv4 } from 'uuid';
|
||||
import {
|
||||
getWindowHeight,
|
||||
searchKeyValues,
|
||||
downloadFunc,
|
||||
sysFile,
|
||||
mergePlugins,
|
||||
find,
|
||||
@ -221,8 +220,9 @@ const actions = {
|
||||
});
|
||||
},
|
||||
async downloadPlugin({commit}, payload) {
|
||||
await downloadZip(payload.gitUrl, payload.name);
|
||||
const fileUrl = find(path.join(__static, `plugins/${payload.name}-master`));
|
||||
const distUrl = await downloadZip(payload.downloadUrl, payload.name);
|
||||
const fileUrl = find(distUrl);
|
||||
|
||||
// 复制文件
|
||||
const config = JSON.parse(fs.readFileSync(`${fileUrl}/plugin.json`, 'utf-8'));
|
||||
const pluginConfig = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user