Commit 00a56db8 authored by A's avatar A

add rely install

parent 49c13820
......@@ -82,6 +82,7 @@
{{appsService.downloadsInfo | json}}
{{appsService.installConfig | json}}
{{appsService.tarQueue | json}}
{{appsService.waitInstallQueue | json}}
</pre>
<button (click)="appsService.doTar()" >DOTAR</button>
......@@ -126,7 +127,7 @@
<label>
<input type="checkbox" [(ngModel)]="appsService.installConfig.mods[mod.id]" name="{{mod.id}}"
[disabled]="['dependency', 'runtime'].includes(mod.type)">
{{searchApp(mod.id).name[searchApp(mod.id).locales[0]]}}
{{appsService.searchApp(mod.id).name[appsService.searchApp(mod.id).locales[0]]}}
</label>
</div>
</div>
......
......@@ -23,7 +23,7 @@ export class AppDetailComponent {
}
_currentApp;
get currentApp(): App {
return this.searchApp(this.routingService.app);
return this.appsService.searchApp(this.routingService.app);
}
_name;
......@@ -92,18 +92,10 @@ export class AppDetailComponent {
}
searchApp(id): App {
let data = this.appsService.data;
let tmp;
if(data) {
tmp = data.find((v)=>v.id === id);
return tmp;
}
}
checkInstall(id): boolean {
if(this.searchApp(id)) {
if(this.searchApp(id).local.path) {
if(this.appsService.searchApp(id)) {
if(this.appsService.searchApp(id).local.path) {
return true;
}
}
......@@ -111,7 +103,8 @@ export class AppDetailComponent {
}
install(id) {
let uri = this.searchApp(id).download;
let uri = this.appsService.searchApp(id).download[process.platform];
console.log(process.platform);
if(uri) {
this.appsService.download(id, uri);
} else {
......@@ -140,23 +133,24 @@ export class AppDetailComponent {
return dir[0];
}
openDir(id) {
this.electron.remote.shell.showItemInFolder(this.searchApp(id).local.path);
this.electron.remote.shell.showItemInFolder(this.appsService.searchApp(id).local.path);
}
startApp(id) {
let execute = this.path.join(this.searchApp(id).local.path, this.searchApp(id).actions[process.platform]["main"].execute);
let args = this.searchApp(id).actions[process.platform]["main"].args;
let env = this.searchApp(id).actions[process.platform]["main"].env;
let execute = this.path.join(this.appsService.searchApp(id).local.path, this.appsService.searchApp(id).actions[process.platform]["main"].execute);
let args = this.appsService.searchApp(id).actions[process.platform]["main"].args;
let env = this.appsService.searchApp(id).actions[process.platform]["main"].env;
let opt = {
cwd: this.appsService.searchApp(id).local.path,
env: env
};
let open = '';
let openId = this.searchApp(id).actions[process.platform]["main"].open;
let openId = this.appsService.searchApp(id).actions[process.platform]["main"].open;
if(openId) {
this.searchApp(openId).actions[process.platform]["main"].execute;
this.appsService.searchApp(openId).actions[process.platform]["main"].execute;
if(this.checkInstall(openId)) {
open = this.path.join(this.searchApp(openId).local.path, this.searchApp(openId).actions[process.platform]["main"].execute);
open = this.path.join(this.appsService.searchApp(openId).local.path, this.appsService.searchApp(openId).actions[process.platform]["main"].execute);
args.push(execute);
} else {
console.error('open app not found');
......
......@@ -30,10 +30,10 @@ export class App {
actions: {[platform: string]: {[action: string]: {execute: string, args: string[], env: {}, open: string}}};
references: {[platform: string]: {id: string, type: string}[]};
locales: string[];
download: string; // meta4 url
download: {[platform: string]: string}; // meta4 url
news: {title: string, url: string, image: string}[];
tags: string[];
version: string;
version: {[platform: string]: string};
local: AppLocal;
constructor(app: AppInterface) {
this.id = app.id;
......
......@@ -46,6 +46,10 @@ export class AppsService {
//[{"id": "th01", "gid": "aria2gid", "status": "active/install/complete/wait", "progress": "0-100"}]
downloadsInfo = [];
//[{"id": "th01", "wait":["wine", "dx"], resolve: resolve, tarObj: tarObj}]
// th01
waitInstallQueue = [];
aria2IsOpen = false;
......@@ -76,10 +80,49 @@ export class AppsService {
this.downloadsInfo[index].status = "wait";
let tarObj = {
id: this.downloadsInfo[index].id,
xzFile: res.files[0].path,
installDir: this.installConfig.installDir
xzFile: res.files[0].path,
installDir: this.installConfig.installDir
};
this.tarPush(tarObj);
let promise = new Promise((resolve, reject)=>{
let refs = this.searchApp(this.downloadsInfo[index].id).references;
console.log(refs);
//[{"id": "th01", "wait":["wine", "dx"], resolve: resolve, tarObj: tarObj}]
let waitObj;
let waitRef = ["runtime", "emulator", "dependency"];
if(!this.isEmptyObject(refs)) {
refs[process.platform].map((ref)=>{
if(waitRef.includes(ref.type)) {
if(!this.checkInstall(ref.id)) {
if(!waitObj) {
waitObj = {
id: this.downloadsInfo[index].id,
wait: [ref.id],
resolve: resolve,
tarObj: tarObj
}
} else {
waitObj.wait.push(ref.id);
}
}
}
});
}
console.log("wait obj:", waitObj);
if(waitObj) {
this.waitInstallQueue.push(waitObj);
} else {
resolve();
}
}).then(()=>{
console.log(tarObj);
this.tarPush(tarObj);
});
promise.catch((err)=>{
console.log("err", err);
})
}
} else {
console.log("cannot found download info!");
......@@ -163,6 +206,24 @@ export class AppsService {
});
}
searchApp(id): App {
let data = this.data;
let tmp;
if(data) {
tmp = data.find((v)=>v.id === id);
return tmp;
}
}
checkInstall(id): boolean {
if(this.searchApp(id)) {
if(this.searchApp(id).local.path) {
return true;
}
}
return false;
}
download(id, uri) {
//console.log(id);
//console.log(uri);
......@@ -333,6 +394,25 @@ export class AppsService {
}
return app;
});
//[{"id": "th01", "wait":["wine", "dx"], resolve: resolve, tarObj: tarObj}]
this.waitInstallQueue = this.waitInstallQueue.map((waitObj)=>{
waitObj.wait.splice(waitObj.wait.findIndex(()=>tarObj.id), 1);
if(waitObj.wait.length <= 0) {
waitObj.resolve();
console.log(tarObj);
return;
} else {
return waitObj;
}
});
this.waitInstallQueue = this.waitInstallQueue.filter((waitObj)=>{
if(waitObj){
return true;
} else {
return false;
}
});
console.log(tmp);
console.log("this app complete!");
console.log(localAppData);
......@@ -342,4 +422,11 @@ export class AppsService {
});
}
isEmptyObject(e) {
let t;
for (t in e)
return !1;
return !0
}
}
......@@ -2,7 +2,7 @@
{
"id": "th105",
"name": {
"zh-CN": "东方绯想天"
"zh-CN": "th07"
},
"description": {
"zh-CN": "fxt desc"
......@@ -13,7 +13,7 @@
"actions": {
"darwin": {
"main": {
"execute": "th13.exe",
"execute": "th07.exe",
"args": [],
"env": {"LC_ALL": "ja_JP"},
"open": "wine"
......@@ -24,7 +24,7 @@
"darwin": [
{
"id": "th06",
"type": "optional"
"type": "emulator"
},
{
"id": "th12_mod1",
......@@ -39,7 +39,7 @@
"locales": [
"zh-CN"
],
"download": "http://thief.mycard.moe/metalinks/th13.meta4",
"download": {"darwin": "http://thief.mycard.moe/metalinks/th07.meta4"},
"news": [
{
"title": "News Title",
......@@ -55,6 +55,7 @@
"tags": [
"game"
],
"version": {"darwin": "1.06"},
"local": {
"path": "",
"version": ""
......@@ -96,11 +97,12 @@
"locales": [
"zh-CN"
],
"download": "",
"download": {},
"news": [],
"tags": [
"STG"
],
"version": {"darwin": "1.06"},
"local": {
"path": "/foo/bar",
"version": "10.3"
......@@ -131,11 +133,12 @@
"locales": [
"zh-CN"
],
"download": "http://thief.mycard.moe/metalinks/th12.meta4",
"download": {"darwin": "http://thief.mycard.moe/metalinks/th12.meta4"},
"news": [],
"tags": [
"STG"
],
"version": {"darwin": "1.06"},
"local": {
"path": "",
"version": "10.3"
......@@ -166,11 +169,12 @@
"locales": [
"zh-CN"
],
"download": "http://thief.mycard.moe/metalinks/th11.meta4",
"download": {"darwin": "http://thief.mycard.moe/metalinks/th11.meta4"},
"news": [],
"tags": [
"STG"
],
"version": {"darwin": "1.06"},
"local": {
"path": "/usr/local/bin",
"version": "1.8"
......@@ -179,7 +183,7 @@
{
"id": "th06",
"name": {
"zh-CN": "东方绯想天"
"zh-CN": "th06"
},
"description": {
"zh-CN": "fxt desc"
......@@ -201,7 +205,7 @@
"locales": [
"zh-CN"
],
"download": "http://thief.mycard.moe/metalinks/th10.meta4",
"download": {"darwin": "http://thief.mycard.moe/metalinks/th06.meta4"},
"news": [
{
"title": "News Title",
......@@ -217,6 +221,7 @@
"tags": [
"game"
],
"version": {"darwin": "1.06"},
"local": {
"path": "",
"version": ""
......@@ -247,7 +252,7 @@
"locales": [
"zh-CN"
],
"download": "",
"download": {},
"news": [
{
"title": "News Title",
......@@ -263,6 +268,7 @@
"tags": [
"game"
],
"version": {"darwin": "1.06"},
"local": {
"path": "/Applications/Sublime Text.app/Contents/MacOS",
"version": ""
......@@ -271,7 +277,7 @@
{
"id": "th08",
"name": {
"zh-CN": "东方绯想天"
"zh-CN": "TH08"
},
"description": {
"zh-CN": "fxt desc"
......@@ -282,10 +288,10 @@
"actions": {
"darwin": {
"main": {
"execute": "",
"execute": "th08.exe",
"args": [],
"env": "",
"open": ""
"env": {"LC_ALL": "ja_JP"},
"open": "wine"
}
}
},
......@@ -293,7 +299,7 @@
"locales": [
"zh-CN"
],
"download": "",
"download": {"darwin": "http://thief.mycard.moe/metalinks/th08.meta4"},
"news": [
{
"title": "News Title",
......@@ -309,6 +315,7 @@
"tags": [
"game"
],
"version": {"darwin": "1.06"},
"local": {
"path": "",
"version": ""
......@@ -339,7 +346,7 @@
"locales": [
"zh-CN"
],
"download": "",
"download": {},
"news": [
{
"title": "News Title",
......@@ -355,6 +362,7 @@
"tags": [
"game"
],
"version": {"darwin": "1.06"},
"local": {
"path": "",
"version": ""
......@@ -385,7 +393,7 @@
"locales": [
"zh-CN"
],
"download": "",
"download": {},
"news": [
{
"title": "News Title",
......@@ -401,6 +409,7 @@
"tags": [
"game"
],
"version": {"darwin": "1.06"},
"local": {
"path": "",
"version": ""
......@@ -431,7 +440,7 @@
"locales": [
"zh-CN"
],
"download": "",
"download": {},
"news": [
{
"title": "News Title",
......@@ -447,6 +456,7 @@
"tags": [
"game"
],
"version": {"darwin": "1.06"},
"local": {
"path": "",
"version": ""
......@@ -477,7 +487,7 @@
"locales": [
"zh-CN"
],
"download": "",
"download": {},
"news": [
{
"title": "News Title",
......@@ -493,6 +503,7 @@
"tags": [
"game"
],
"version": {"darwin": "1.06"},
"local": {
"path": "",
"version": ""
......
......@@ -90,7 +90,8 @@ function createAria2c() {
default:
throw 'unsupported platform';
}
let aria2c = child_process.spawn(aria2c_path, ['--enable-rpc', '--rpc-allow-origin-all']);
//--split=10 --min-split-size=1M --max-connection-per-server=10
let aria2c = child_process.spawn(aria2c_path, ['--enable-rpc', '--rpc-allow-origin-all', "--continue", "--split=10", "--min-split-size=1M", "--max-connection-per-server=10"]);
aria2c.on('data', (data)=> {
console.log(data);
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment