Commit 927e633a authored by wudizhanche1000's avatar wudizhanche1000

添加DownloadService

parent 0a8be1c5
...@@ -3,6 +3,7 @@ import {AppsService} from "./apps.service"; ...@@ -3,6 +3,7 @@ import {AppsService} from "./apps.service";
import {InstallConfig} from "./install-config"; import {InstallConfig} from "./install-config";
import {SettingsService} from "./settings.sevices"; import {SettingsService} from "./settings.sevices";
import {App} from "./app"; import {App} from "./app";
import {DownloadService} from "./download.service";
declare var System; declare var System;
declare var process; declare var process;
...@@ -32,6 +33,7 @@ sudo.fork = function (modulePath, args, options) { ...@@ -32,6 +33,7 @@ sudo.fork = function (modulePath, args, options) {
selector: 'app-detail', selector: 'app-detail',
templateUrl: 'app/app-detail.component.html', templateUrl: 'app/app-detail.component.html',
styleUrls: ['app/app-detail.component.css'], styleUrls: ['app/app-detail.component.css'],
providers: [DownloadService]
}) })
export class AppDetailComponent implements OnInit { export class AppDetailComponent implements OnInit {
platform = process.platform; platform = process.platform;
...@@ -43,7 +45,8 @@ export class AppDetailComponent implements OnInit { ...@@ -43,7 +45,8 @@ export class AppDetailComponent implements OnInit {
installConfig: InstallConfig; installConfig: InstallConfig;
constructor(private appsService: AppsService, private settingsService: SettingsService) { constructor(private appsService: AppsService, private settingsService: SettingsService,
private downloadService: DownloadService) {
} }
ngOnInit() { ngOnInit() {
......
/**
* Created by weijian on 2016/10/26.
*/
import {Injectable} from "@angular/core";
import {SettingsService} from "./settings.sevices";
import {ipcRenderer} from "electron";
@Injectable()
export class DownloadService {
constructor(private settingsService: SettingsService) {
ipcRenderer.send("download-message", "123");
}
sendEvent(event, args) {
ipcRenderer.send()
}
listenEvent() {
console.log(ipcRenderer);
}
}
/**
* Created by weijian on 2016/10/27.
*/
const Rx = require("rxjs/Rx");
const {ipcMain}= require('electron');
import {ChildProcess, spawn} from "child_process";
// import * as Aria2 from "aria2";
const Aria2 = require("aria2");
let a = (createProcess("D:/Github/mycard/bin/aria2c.exe", ['--enable-rpc', '--rpc-allow-origin-all', "--continue", "--split=10", "--min-split-size=1M", "--max-connection-per-server=10"]))
a.on('error', (error)=> {
console.log(error);
});
// console.log(Aria2,2);
function createProcess(aria2c_path: string, args: string[] = []): ChildProcess {
return spawn(aria2c_path, args);
}
let options = {'host': 'localhost', 'port': 6800, 'secure': false}
let aria2 = new Aria2(options);
aria2.onDownloadComplete = (response)=> {
console.log(response);
};
let open = aria2.open();
function addUri(uri: string[], path: string) {
return open.then(()=> {
return aria2.addUri(uri, {'dir': path});
});
}
function pause(gid: string): Promise<string> {
return aria2.pause(gid)
}
function reportStatus() {
aria2.tellActive()
}
ipcMain.on()
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api', 'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
'rxjs': 'node_modules/rxjs', 'rxjs': 'node_modules/rxjs',
'ng2-translate': 'node_modules/ng2-translate/bundles/ng2-translate.js', 'ng2-translate': 'node_modules/ng2-translate/bundles/ng2-translate.js',
"os":'' "os": '',
"electron": "@node/electron"
}; };
// packages tells the System loader how to load when no filename and/or no extension // packages tells the System loader how to load when no filename and/or no extension
var packages = { var packages = {
......
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