mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-26 20:54:18 +08:00
init
This commit is contained in:
0
src/renderer/assets/.gitkeep
Normal file
0
src/renderer/assets/.gitkeep
Normal file
4
src/renderer/assets/api/config.js
Normal file
4
src/renderer/assets/api/config.js
Normal file
@@ -0,0 +1,4 @@
|
||||
export default {
|
||||
development: 'http://localhost:7001',
|
||||
// development: 'http://kaer-server.qa.91jkys.com',
|
||||
};
|
||||
5
src/renderer/assets/api/index.js
Normal file
5
src/renderer/assets/api/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import plugin from './list/plugin';
|
||||
|
||||
export default {
|
||||
plugin
|
||||
}
|
||||
16
src/renderer/assets/api/list/plugin.js
Normal file
16
src/renderer/assets/api/list/plugin.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import instance from '../request';
|
||||
|
||||
export default {
|
||||
async add(params) {
|
||||
const result = await instance.post('/plugin/create', params);
|
||||
return result.data;
|
||||
},
|
||||
async update(params) {
|
||||
const result = await instance.post('/plugin/update', params);
|
||||
return result.data;
|
||||
},
|
||||
async query(params) {
|
||||
const result = await instance.get('/plugin/query', {params});
|
||||
return result.data;
|
||||
}
|
||||
}
|
||||
10
src/renderer/assets/api/request.js
Normal file
10
src/renderer/assets/api/request.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import axios from 'axios';
|
||||
import config from "./config";
|
||||
|
||||
const instance = axios.create({
|
||||
baseURL: config[process.env.NODE_ENV],
|
||||
timeout: 10000,
|
||||
withCredentials: true
|
||||
});
|
||||
|
||||
export default instance;
|
||||
9
src/renderer/assets/common/constans.js
Normal file
9
src/renderer/assets/common/constans.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const WINDOW_MAX_HEIGHT = 766;
|
||||
const WINDOW_MIN_HEIGHT = 60;
|
||||
const PRE_ITEM_HEIGHT = 60;
|
||||
|
||||
export {
|
||||
WINDOW_MAX_HEIGHT,
|
||||
WINDOW_MIN_HEIGHT,
|
||||
PRE_ITEM_HEIGHT,
|
||||
}
|
||||
94
src/renderer/assets/common/utils.js
Normal file
94
src/renderer/assets/common/utils.js
Normal file
@@ -0,0 +1,94 @@
|
||||
import {WINDOW_MAX_HEIGHT, WINDOW_MIN_HEIGHT, PRE_ITEM_HEIGHT} 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';
|
||||
|
||||
const store = new Store();
|
||||
|
||||
function getWindowHeight(searchList) {
|
||||
if (!searchList) return WINDOW_MAX_HEIGHT;
|
||||
if (!searchList.length) return WINDOW_MIN_HEIGHT;
|
||||
return searchList.length * PRE_ITEM_HEIGHT + WINDOW_MIN_HEIGHT + 5 > WINDOW_MAX_HEIGHT ? WINDOW_MAX_HEIGHT : searchList.length * PRE_ITEM_HEIGHT + WINDOW_MIN_HEIGHT + 5;
|
||||
}
|
||||
|
||||
function searchKeyValues(lists, value){
|
||||
return lists.filter(item => item.indexOf(value) >= 0)
|
||||
}
|
||||
|
||||
function existOrNot(path) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.stat(path, async (err, stat) => {
|
||||
if (err) {
|
||||
resolve(false);
|
||||
} else {
|
||||
resolve(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function mkdirFolder(name) {
|
||||
return new Promise((resolve, reject) => {
|
||||
process.exec(`mkdir ${name}`, async function (error, stdout, stderr) {
|
||||
if (error) {
|
||||
reject(false);
|
||||
} else {
|
||||
resolve(true);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function downloadFunc(downloadRepoUrl, 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(`github:clouDr-f2e/${name}`, temp_dest, 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);
|
||||
},
|
||||
getUserPlugins() {
|
||||
try {
|
||||
console.log(store.get('user-plugins').devPlugins)
|
||||
return store.get('user-plugins').devPlugins;
|
||||
} catch (e) {
|
||||
return []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
getWindowHeight,
|
||||
searchKeyValues,
|
||||
downloadFunc,
|
||||
sysFile,
|
||||
}
|
||||
BIN
src/renderer/assets/logo.png
Normal file
BIN
src/renderer/assets/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
Reference in New Issue
Block a user