Commit ffb80d0f authored by 神楽坂玲奈's avatar 神楽坂玲奈

clean

parent 32be85f0
...@@ -34,11 +34,13 @@ before_install: ...@@ -34,11 +34,13 @@ before_install:
- chmod 600 $HOME/.ssh/id_ecdsa - chmod 600 $HOME/.ssh/id_ecdsa
install: install:
- npm install - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir -p bin; curl -L https://github.com/aria2/aria2/releases/download/release-1.27.1/aria2-1.27.1-osx-darwin.tar.bz2 | tar --strip-components=2 -C bin -jxf - aria2-1.27.1/bin/aria2c; fi
- npm prune
- npm install
- npm prune
script: script:
- npm run dist - npm run dist
deploy: deploy:
provider: script provider: script
......
# MyCard [![Build Status](https://travis-ci.org/mycard/mycard.svg?branch=v3)](https://travis-ci.org/mycard/mycard) [![Build status](https://ci.appveyor.com/api/projects/status/t4jyh0rkwh0nep7w?svg=true)](https://ci.appveyor.com/project/zh99998/mycard) [![NSP Status](https://nodesecurity.io/orgs/mycard/projects/62dd15a6-3927-49c2-8c30-1bc19d4a6e92/badge)](https://nodesecurity.io/orgs/mycard/projects/62dd15a6-3927-49c2-8c30-1bc19d4a6e92) # MyCard [![Build Status](https://travis-ci.org/mycard/mycard.svg?branch=v3)](https://travis-ci.org/mycard/mycard) [![Build status](https://ci.appveyor.com/api/projects/status/t4jyh0rkwh0nep7w?svg=true)](https://ci.appveyor.com/project/zh99998/mycard) [![NSP Status](https://nodesecurity.io/orgs/mycard/projects/62dd15a6-3927-49c2-8c30-1bc19d4a6e92/badge)](https://nodesecurity.io/orgs/mycard/projects/62dd15a6-3927-49c2-8c30-1bc19d4a6e92)
## Install Dependencies ## Install Dependencies
``` ```bash
npm install npm install
``` ```
## Build ## Build
``` ```bash
npm run tsc npm run tsc
npm run dist npm run dist
``` ```
## Debug ## Debug
``` ```bash
./node_modules/.bin/electron . ./node_modules/.bin/electron .
``` ```
## Install Dependencies (macOS)
```bash
mkdir -p bin
curl -L https://github.com/aria2/aria2/releases/download/release-1.27.1/aria2-1.27.1-osx-darwin.tar.bz2 | tar --strip-components=2 -C bin -jxf - aria2-1.27.1/bin/aria2c
```
## Install Dependencies (Windows)
```bash
mkdir -p bin
curl -L -o aria2-1.27.1-win-32bit-build1.zip https://github.com/aria2/aria2/releases/download/release-1.27.1/aria2-1.27.1-win-32bit-build1.zip
unzip -o /Users/zh99998/Downloads/aria2-1.28.0-win-32bit-build1.zip aria2-1.28.0-win-32bit-build1/aria2c.exe
mv aria2-1.28.0-win-32bit-build1/aria2c.exe bin
rm -rf aria2-1.28.0-win-32bit-build1 aria2-1.27.1-win-32bit-build1.zip
curl -L 'http://downloads.sourceforge.net/project/msys2/REPOS/MSYS2/i686/bsdtar-3.2.1-1-i686.pkg.tar.xz' | tar --strip-components=2 -C bin -Jxf - usr/bin/bsdtar.exe
curl -L 'http://downloads.sourceforge.net/project/msys2/Base/i686/msys2-base-i686-20161025.tar.xz' | tar --strip-components=3 -C bin -Jxf - msys32/usr/bin/msys-2.0.dll msys32/usr/bin/msys-bz2-1.dll msys32/usr/bin/msys-gcc_s-1.dll msys32/usr/bin/msys-iconv-2.dll msys32/usr/bin/msys-lzma-5.dll msys32/usr/bin/msys-lzo2-2.dll msys32/usr/bin/msys-nettle-6.dll msys32/usr/bin/msys-xml2-2.dll msys32/usr/bin/msys-z.dll
```
\ No newline at end of file
import {Injectable, ApplicationRef} from "@angular/core"; import {Injectable, ApplicationRef, NgZone} from "@angular/core";
import {Http} from "@angular/http"; import {Http} from "@angular/http";
import {App, AppStatus} from "./app"; import {App, AppStatus} from "./app";
import {InstallConfig} from "./install-config"; import {InstallConfig} from "./install-config";
...@@ -17,8 +17,8 @@ import {AppLocal} from "./app-local"; ...@@ -17,8 +17,8 @@ import {AppLocal} from "./app-local";
const Aria2 = require('aria2'); const Aria2 = require('aria2');
const Sudo = require('electron-sudo').default; const Sudo = require('electron-sudo').default;
Sudo.prototype.fork = function (modulePath, args, options) { Sudo.prototype.fork = async function (modulePath, args, options) {
return this.spawn(remote.app.getPath('exe'), ['-e', modulePath].concat(args), options).then((child)=> { let child = await this.spawn(remote.app.getPath('exe'), ['-e', modulePath].concat(args), options);
readline.createInterface({input: child.stdout}).on('line', (line) => { readline.createInterface({input: child.stdout}).on('line', (line) => {
child.emit('message', JSON.parse(line)); child.emit('message', JSON.parse(line));
}); });
...@@ -29,13 +29,12 @@ Sudo.prototype.fork = function (modulePath, args, options) { ...@@ -29,13 +29,12 @@ Sudo.prototype.fork = function (modulePath, args, options) {
} }
}; };
return child return child
})
}; };
@Injectable() @Injectable()
export class AppsService { export class AppsService {
constructor(private http: Http, private settingsService: SettingsService, private ref: ApplicationRef,) { constructor(private http: Http, private settingsService: SettingsService, private ref: ApplicationRef, private ngZong: NgZone) {
} }
...@@ -466,11 +465,15 @@ export class AppsService { ...@@ -466,11 +465,15 @@ export class AppsService {
connections = new Map<App, {connection: WebSocket, address: string}>(); connections = new Map<App, {connection: WebSocket, address: string}>();
maotama; maotama;
network(app: App, server) { async network(app: App, server) {
if (!this.maotama) { if (!this.maotama) {
this.maotama = new Sudo({name: 'MyCard'}).fork('maotama') this.maotama = new Sudo({name: 'MyCard'}).fork('maotama')
} }
this.maotama.then((child)=> { let child = await this.maotama;
// child.on('message', console.log);
// child.on('exit', console.log);
// child.on('error', console.log);
let connection = this.connections.get(app); let connection = this.connections.get(app);
if (connection) { if (connection) {
connection.connection.close(); connection.connection.close();
...@@ -488,12 +491,14 @@ export class AppsService { ...@@ -488,12 +491,14 @@ export class AppsService {
this.ref.tick(); this.ref.tick();
break; break;
case 'CONNECT': case 'CONNECT':
this.ngZong.runOutsideAngular(()=> {
id = setInterval(()=> { id = setInterval(()=> {
child.send({ child.send({
action: 'connect', action: 'connect',
arguments: [app.network.port, port, address] arguments: [app.network.port, port, address]
}) })
}, 200); }, 200);
});
break; break;
case 'CONNECTED': case 'CONNECTED':
clearInterval(id); clearInterval(id);
...@@ -509,12 +514,11 @@ export class AppsService { ...@@ -509,12 +514,11 @@ export class AppsService {
if (this.connections.get(app) == connection) { if (this.connections.get(app) == connection) {
this.connections.delete(app); this.connections.delete(app);
if (event.code != 1000 && !connection.address) { if (event.code != 1000 && !connection.address) {
// 如果还没建立好就出错了,就弹窗提示这个错误
alert(`出错了 ${event.code}`); alert(`出错了 ${event.code}`);
} }
}
// 如果还没建立好就出错了,就弹窗提示这个错误
this.ref.tick(); this.ref.tick();
}
}; };
})
} }
} }
\ No newline at end of file
...@@ -34,6 +34,14 @@ init: ...@@ -34,6 +34,14 @@ init:
- git config --global core.autocrlf input - git config --global core.autocrlf input
install: install:
- mkdir -p bin
- curl -L -o aria2-1.27.1-win-32bit-build1.zip https://github.com/aria2/aria2/releases/download/release-1.27.1/aria2-1.27.1-win-32bit-build1.zip
- unzip -o /Users/zh99998/Downloads/aria2-1.28.0-win-32bit-build1.zip aria2-1.28.0-win-32bit-build1/aria2c.exe
- mv aria2-1.28.0-win-32bit-build1/aria2c.exe bin
- rm -rf aria2-1.28.0-win-32bit-build1 aria2-1.27.1-win-32bit-build1.zip
- curl -L 'http://downloads.sourceforge.net/project/msys2/REPOS/MSYS2/i686/bsdtar-3.2.1-1-i686.pkg.tar.xz' | tar --strip-components=2 -C bin -Jxf - usr/bin/bsdtar.exe
- curl -L 'http://downloads.sourceforge.net/project/msys2/Base/i686/msys2-base-i686-20161025.tar.xz' | tar --strip-components=3 -C bin -Jxf - msys32/usr/bin/msys-2.0.dll msys32/usr/bin/msys-bz2-1.dll msys32/usr/bin/msys-gcc_s-1.dll msys32/usr/bin/msys-iconv-2.dll msys32/usr/bin/msys-lzma-5.dll msys32/usr/bin/msys-lzo2-2.dll msys32/usr/bin/msys-nettle-6.dll msys32/usr/bin/msys-xml2-2.dll msys32/usr/bin/msys-z.dll
- ps: Install-Product node - ps: Install-Product node
- npm install - npm install
- npm prune - npm prune
......
...@@ -27,11 +27,11 @@ ...@@ -27,11 +27,11 @@
"@angular/router-deprecated": "latest", "@angular/router-deprecated": "latest",
"@angular/upgrade": "latest", "@angular/upgrade": "latest",
"angular2-in-memory-web-api": "latest", "angular2-in-memory-web-api": "latest",
"electron-auto-updater": "latest",
"aria2": "latest", "aria2": "latest",
"bootstrap": "next", "bootstrap": "next",
"core-js": "latest", "core-js": "latest",
"electron-sudo": "github:mycard/electron-sudo", "electron-auto-updater": "latest",
"electron-sudo": "github:mycard/electron-sudo#patch-1",
"font-awesome": "latest", "font-awesome": "latest",
"ini": "latest", "ini": "latest",
"mkdirp": "latest", "mkdirp": "latest",
...@@ -69,15 +69,6 @@ ...@@ -69,15 +69,6 @@
"extraResources": [ "extraResources": [
"bin" "bin"
], ],
"publish": [
{
"provider": "generic",
"url": "https://wudizhanche.mycard.moe/downloads"
},
{
"provider": "github"
}
],
"win": { "win": {
"target": [ "target": [
"nsis" "nsis"
......
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