Commit 63355870 authored by h3remi7's avatar h3remi7

add aria2

parent 51645d88
......@@ -55,7 +55,7 @@
<td>{{searchApp(mod.id).name[searchApp(mod.id).locales[0]]}}</td>
<td>{{mod.type}}</td>
<td *ngIf="checkInstall(mod.id)"><button type="button" class="btn btn-danger btn-sm">卸载</button></td>
<td *ngIf="!checkInstall(mod.id)"><button type="button" class="btn btn-primary btn-sm">安装</button></td>
<td *ngIf="!checkInstall(mod.id)"><button (click)="install()" type="button" class="btn btn-primary btn-sm">安装</button></td>
</tr>
</tbody>
</table>
......
import { Component } from '@angular/core';
import { AppsService } from './apps.service'
import { AppService } from './app.service'
import { RoutingService } from './routing.service'
import {App} from "./app";
......@@ -12,6 +13,8 @@ declare var process;
})
export class AppDetailComponent {
constructor(private appsService: AppsService, private appService: AppService, private routingService: RoutingService ) {
}
_currentApp;
get currentApp(): App {
return this.searchApp(this.routingService.app);
......@@ -55,7 +58,6 @@ export class AppDetailComponent {
if(this.currentApp) {
if(this.currentApp.references[process.platform] && this.currentApp.references[process.platform].length > 0) {
console.log(this.currentApp.references[process.platform]);
let refs = this.currentApp.references[process.platform];
refs = refs.filter((ref)=>{
return contains.includes(ref.type);
......@@ -72,7 +74,7 @@ export class AppDetailComponent {
default:
break;
}
console.log(tmp.type);
//console.log(tmp.type);
return tmp;
});
return refs;
......@@ -82,8 +84,6 @@ export class AppDetailComponent {
}
}
constructor(private appsService: AppsService, private routingService: RoutingService ) {
}
searchApp(id): App {
let data = this.appsService.data;
......@@ -103,4 +103,10 @@ export class AppDetailComponent {
return false;
}
install() {
this.appService.download();
}
}
import {Injectable} from '@angular/core';
import {Http} from '@angular/http';
import 'rxjs/Rx';
import {AppLocal} from "./app-local";
// declare var System;
@Injectable()
export class AppService {
Aria2 = window['System']._nodeRequire('aria2');
constructor(private http: Http) {
}
download() {
const aria2 = new this.Aria2();
console.log(aria2);
aria2.open(()=>{
//aria2.addUri(['http://thief.mycard.moe/metalinks/th13.meta4']);
})
}
}
......@@ -12,11 +12,11 @@ export class AppsComponent {
constructor(private appsService: AppsService, private routingService: RoutingService ) {
appsService.getApps(()=>{
console.log(appsService.data)
//console.log(appsService.data)
if(appsService.data.length > 0) {
this.selectApp(appsService.data[0].id);
let tmp = this.appsService.data.filter((v)=>v.id === this.routingService.app);
console.log(tmp);
//console.log(tmp);
}
});
}
......
......@@ -19,7 +19,7 @@ export class AppsService {
})
.subscribe(data => {
this.data = data;
console.log(this.data);
//console.log(this.data);
if(typeof(callback) === 'function') {
callback();
}
......
......@@ -14,12 +14,13 @@ import { CommunityComponent } from './community.component';
import { RoutingService } from './routing.service';
import { AppsService } from './apps.service';
import { AppService } from './app.service';
@NgModule({
imports: [ BrowserModule,HttpModule ],
declarations: [ MyCardComponent, LoginComponent, StoreComponent, LobbyComponent, CommunityComponent, AppsComponent, AppDetailComponent, RosterComponent, CandyComponent ],
bootstrap: [ MyCardComponent ],
providers: [ RoutingService, AppsService ],
providers: [ RoutingService, AppsService, AppService ],
})
export class MyCard { }
\ No newline at end of file
......@@ -4,6 +4,35 @@ const app = electron.app
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow
function createAria2c() {
"use strict";
const ChildProcess = require('child_process');
const path = require('path');
const appFolder = path.resolve(process.execPath, '..');
const rootAtomFolder = path.resolve(appFolder, '..');
const aria2Bin = path.resolve(path.join(rootAtomFolder, 'aria2c.exe'));
const aria2Name = 'arai2';
const spawn = function(command, args) {
let spawnedProcess, error;
try {
spawnedProcess = ChildProcess.spawn(command, args, {detached: true});
} catch (error) {}
return spawnedProcess;
};
const aria2c = spawn('aria2c', ['--enable-rpc', '--rpc-allow-origin-all']);
aria2c.on('data', (data)=>{
console.log(`${data}`);
})
}
createAria2c();
// this should be placed at top of main.js to handle setup events quickly
if (handleSquirrelEvent()) {
// squirrel event handled and app will exit in 1000ms, so don't do anything else
......
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