Commit 00a56db8 authored by A's avatar A

add rely install

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