Commit 0b217159 authored by nanahira's avatar nanahira

Merge branch 'v3-workon' into v3

parents 563f37d3 668702ee
...@@ -17,4 +17,4 @@ Thumbs.db ...@@ -17,4 +17,4 @@ Thumbs.db
messages.xlf messages.xlf
messages.xlf.bak messages.xlf.bak
locale/*.xlf.bak locale/*.xlf.bak
/package-lock.json # /package-lock.json
variables:
GIT_DEPTH: "1"
stages:
- prepare
- build
- deploy
macOS_bin:
stage: prepare
tags:
- linux
artifacts:
paths:
- bin
script:
- mkdir -p bin; curl --location --retry
5 https://github.com/aria2/aria2/releases/download/release-1.29.0/aria2-1.29.0-osx-darwin.tar.bz2
| tar --strip-components=2 -C bin -jxf - aria2-1.29.0/bin/aria2c
windows_bin:
stage: prepare
tags:
- linux
artifacts:
paths:
- bin
script:
- mkdir -p bin
- curl --location --retry 5 --output aria2-1.29.0-win-32bit-build1.zip https://github.com/aria2/aria2/releases/download/release-1.29.0/aria2-1.29.0-win-32bit-build1.zip
- unzip -o aria2-1.29.0-win-32bit-build1.zip aria2-1.29.0-win-32bit-build1/aria2c.exe
- mv aria2-1.29.0-win-32bit-build1/aria2c.exe bin
- rm -rf aria2-1.29.0-win-32bit-build1 aria2-1.29.0-win-32bit-build1.zip
- curl --location --retry 5 "http://downloads.sourceforge.net/project/msys2/REPOS/MSYS2/i686/bsdtar-3.4.2-2-i686.pkg.tar.xz" | tar --strip-components=2 -C bin -Jxf - usr/bin/bsdtar.exe
- curl --location --retry 5 "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 msys32/usr/bin/sha256sum.exe msys32/usr/bin/msys-intl-8.dll
windows:
stage: build
dependencies:
- windows_bin
tags:
- vs
script:
- npm ci
- npm run dist
- dir dist
artifacts:
paths:
- dist/
linux:
image: node:16
stage: build
tags:
- linux
script:
- apt update ; apt -y install python3 build-essential git
- npm ci
- npm run dist
- ls -la dist
artifacts:
paths:
- dist/
macOS:
stage: build
dependencies:
- macOS_bin
tags:
- macOS
script:
- npm ci
- npm run dist
- ls -la dist
artifacts:
paths:
- dist/
upload_to_minio:
stage: deploy
dependencies:
- macOS
- windows
- linux
tags:
- linux
script:
- aws s3 --endpoint=https://minio.mycard.moe:9000 sync dist/ s3://mycard/mycard-reborn
only:
- tags
- v3
...@@ -214,6 +214,7 @@ ...@@ -214,6 +214,7 @@
<h4 i18n>快捷方式</h4> <h4 i18n>快捷方式</h4>
<div class="checkbox"> <div class="checkbox">
<input id="create_application_shortcut" type="checkbox" name="application" [(ngModel)]="installOption.createShortcut"> <input id="create_application_shortcut" type="checkbox" name="application" [(ngModel)]="installOption.createShortcut">
<label i18n *ngIf="platform == 'linux'" for="create_application_shortcut">创建启动菜单快捷方式</label>
<label i18n *ngIf="platform == 'darwin'" for="create_application_shortcut">创建 LaunchPad 快捷方式</label> <label i18n *ngIf="platform == 'darwin'" for="create_application_shortcut">创建 LaunchPad 快捷方式</label>
<label i18n *ngIf="platform == 'win32'" for="create_application_shortcut">创建开始菜单快捷方式</label> <label i18n *ngIf="platform == 'win32'" for="create_application_shortcut">创建开始菜单快捷方式</label>
</div> </div>
...@@ -362,4 +363,4 @@ ...@@ -362,4 +363,4 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -94,7 +94,7 @@ export class AppDetailComponent implements OnInit, OnChanges { ...@@ -94,7 +94,7 @@ export class AppDetailComponent implements OnInit, OnChanges {
this.availableLibraries.push(currentVolume); this.availableLibraries.push(currentVolume);
} }
} }
resolve(); resolve(null);
}); });
}); });
} }
......
...@@ -193,7 +193,7 @@ export class App { ...@@ -193,7 +193,7 @@ export class App {
findDependencies(): App[] { findDependencies(): App[] {
if (this.dependencies && this.dependencies.size > 0) { if (this.dependencies && this.dependencies.size > 0) {
let set = new Set(); let set = new Set<App>();
for (let dependency of this.dependencies.values()) { for (let dependency of this.dependencies.values()) {
dependency.findDependencies() dependency.findDependencies()
.forEach((value) => { .forEach((value) => {
......
import { ApplicationRef, EventEmitter, Injectable, NgZone } from '@angular/core'; import {ApplicationRef, EventEmitter, Injectable, NgZone} from '@angular/core';
import { Http } from '@angular/http'; import {Http} from '@angular/http';
import * as child_process from 'child_process'; import * as child_process from 'child_process';
import { ChildProcess } from 'child_process'; import {ChildProcess} from 'child_process';
import * as crypto from 'crypto'; import * as crypto from 'crypto';
import { remote } from 'electron'; import {remote} from 'electron';
import * as sudo from 'electron-sudo'; import * as sudo from 'electron-sudo';
import * as fs from 'fs'; import * as fs from 'fs';
import * as glob from 'glob'; import * as glob from 'glob';
...@@ -11,16 +11,17 @@ import * as ini from 'ini'; ...@@ -11,16 +11,17 @@ import * as ini from 'ini';
import * as path from 'path'; import * as path from 'path';
import * as readline from 'readline'; import * as readline from 'readline';
import 'rxjs/Rx'; import 'rxjs/Rx';
import { Observable, Observer } from 'rxjs/Rx'; import {Observable, Observer} from 'rxjs/Rx';
import { Action, App, AppStatus } from './app'; import {Action, App, AppStatus} from './app';
import { AppLocal } from './app-local'; import {AppLocal} from './app-local';
import { DownloadService, DownloadStatus } from './download.service'; import {DownloadService, DownloadStatus} from './download.service';
import { InstallOption } from './install-option'; import {InstallOption} from './install-option';
import { LoginService } from './login.service'; import {LoginService} from './login.service';
import { SettingsService } from './settings.sevices'; import {SettingsService} from './settings.sevices';
import { ComparableSet } from './shared/ComparableSet'; import {ComparableSet} from './shared/ComparableSet';
import Timer = NodeJS.Timer; import Timer = NodeJS.Timer;
import ReadableStream = NodeJS.ReadableStream; import ReadableStream = NodeJS.ReadableStream;
const Logger = { const Logger = {
info: (...message: any[]) => { info: (...message: any[]) => {
console.log('AppService [INFO]: ', ...message); console.log('AppService [INFO]: ', ...message);
...@@ -29,16 +30,19 @@ const Logger = { ...@@ -29,16 +30,19 @@ const Logger = {
console.error('AppService [ERROR]: ', ...message); console.error('AppService [ERROR]: ', ...message);
} }
}; };
interface InstallTask { interface InstallTask {
app: App; app: App;
option: InstallOption; option: InstallOption;
} }
interface InstallStatus { interface InstallStatus {
status: string; status: string;
progress: number; progress: number;
total: number; total: number;
lastItem: string; lastItem: string;
} }
interface Connection { interface Connection {
connection: WebSocket; connection: WebSocket;
address: string | null; address: string | null;
...@@ -49,16 +53,14 @@ declare const System: any; ...@@ -49,16 +53,14 @@ declare const System: any;
@Injectable() @Injectable()
export class AppsService { export class AppsService {
private apps: Map<string, App>;
eventEmitter = new EventEmitter<void>(); eventEmitter = new EventEmitter<void>();
map: Map<string, string> = new Map(); map: Map<string, string> = new Map();
connections = new Map<App, Connection>(); connections = new Map<App, Connection>();
maotama: Promise<ChildProcess>; maotama: Promise<ChildProcess>;
readonly tarPath = process.platform === 'win32' ? readonly tarPath = process.platform === 'win32' ?
path.join(process.env['NODE_ENV'] === 'production' ? process.resourcesPath! : '', 'bin', 'bsdtar.exe') path.join(process.env['NODE_ENV'] === 'production' ? process.resourcesPath! : '', 'bin', 'bsdtar.exe')
: 'bsdtar'; : 'bsdtar';
private apps: Map<string, App>;
constructor(private http: Http, private settingsService: SettingsService, private ref: ApplicationRef, constructor(private http: Http, private settingsService: SettingsService, private ref: ApplicationRef,
private downloadService: DownloadService, private ngZone: NgZone, private loginService: LoginService) { private downloadService: DownloadService, private ngZone: NgZone, private loginService: LoginService) {
...@@ -264,6 +266,8 @@ export class AppsService { ...@@ -264,6 +266,8 @@ export class AppsService {
if (app[key]) { if (app[key]) {
if (app[key][platform]) { if (app[key][platform]) {
app[key] = app[key][platform]; app[key] = app[key][platform];
} else if (platform === 'linux' && app[key].darwin) {
app[key] = app[key].darwin;
} else { } else {
app[key] = null; app[key] = null;
} }
...@@ -368,7 +372,7 @@ export class AppsService { ...@@ -368,7 +372,7 @@ export class AppsService {
checksumFiles.set(file, 'DO_NOT_CARE_HASH'); checksumFiles.set(file, 'DO_NOT_CARE_HASH');
} }
} }
resolve(); resolve(null);
}); });
}); });
} }
...@@ -404,7 +408,7 @@ export class AppsService { ...@@ -404,7 +408,7 @@ export class AppsService {
} }
} }
} }
resolve(); resolve(null);
} catch (e) { } catch (e) {
reject(e); reject(e);
} }
...@@ -455,7 +459,7 @@ export class AppsService { ...@@ -455,7 +459,7 @@ export class AppsService {
result.set(file, sha256sum); result.set(file, sha256sum);
} }
callback(); callback();
resolve(); resolve(null);
}); });
}); });
} }
...@@ -475,7 +479,7 @@ export class AppsService { ...@@ -475,7 +479,7 @@ export class AppsService {
} else { } else {
readyToUpdate = app.isReady() && mods.every((mod) => mod.isReady()); readyToUpdate = app.isReady() && mods.every((mod) => mod.isReady());
} }
if (readyToUpdate && (verify || app.local!.version !== app.version )) { if (readyToUpdate && (verify || app.local!.version !== app.version)) {
app.status.status = 'updating'; app.status.status = 'updating';
try { try {
Logger.info('Checking updating: ', app); Logger.info('Checking updating: ', app);
...@@ -492,7 +496,7 @@ export class AppsService { ...@@ -492,7 +496,7 @@ export class AppsService {
localFiles = await this.verifyFiles(app, latestFiles, () => { localFiles = await this.verifyFiles(app, latestFiles, () => {
app.status.progress += 1; app.status.progress += 1;
}); });
resolve(); resolve(null);
} catch (e) { } catch (e) {
reject(e); reject(e);
} }
...@@ -524,7 +528,7 @@ export class AppsService { ...@@ -524,7 +528,7 @@ export class AppsService {
ignoreFiles.add(file); ignoreFiles.add(file);
} }
} }
resolve(); resolve(null);
}); });
}); });
} }
...@@ -652,7 +656,7 @@ export class AppsService { ...@@ -652,7 +656,7 @@ export class AppsService {
}, (error) => { }, (error) => {
reject(error); reject(error);
}, () => { }, () => {
resolve(); resolve(null);
}); });
}); });
} }
...@@ -674,7 +678,7 @@ export class AppsService { ...@@ -674,7 +678,7 @@ export class AppsService {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
this.eventEmitter.subscribe(() => { this.eventEmitter.subscribe(() => {
if (task.app.readyForInstall()) { if (task.app.readyForInstall()) {
resolve(); resolve(null);
} else if (task.app.findDependencies().find((dependency: App) => !dependency.isInstalled())) { } else if (task.app.findDependencies().find((dependency: App) => !dependency.isInstalled())) {
reject('Dependencies failed'); reject('Dependencies failed');
} }
...@@ -784,7 +788,7 @@ export class AppsService { ...@@ -784,7 +788,7 @@ export class AppsService {
if (error) { if (error) {
reject(error); reject(error);
} else { } else {
resolve(); resolve(null);
} }
}); });
}); });
...@@ -824,7 +828,7 @@ export class AppsService { ...@@ -824,7 +828,7 @@ export class AppsService {
if (error) { if (error) {
reject(error); reject(error);
} else { } else {
resolve(); resolve(null);
} }
}); });
}); });
...@@ -988,7 +992,7 @@ export class AppsService { ...@@ -988,7 +992,7 @@ export class AppsService {
await this.backupFiles(app.parent!.local!.path, backupPath, conflictFiles, (n) => { await this.backupFiles(app.parent!.local!.path, backupPath, conflictFiles, (n) => {
app.status.progress += 1; app.status.progress += 1;
}); });
resolve(); resolve(null);
} catch (e) { } catch (e) {
reject(e); reject(e);
} }
...@@ -1009,7 +1013,7 @@ export class AppsService { ...@@ -1009,7 +1013,7 @@ export class AppsService {
reject(error); reject(error);
}, },
() => { () => {
resolve(); resolve(null);
}); });
}); });
} }
...@@ -1026,8 +1030,7 @@ export class AppsService { ...@@ -1026,8 +1030,7 @@ export class AppsService {
} catch (e) { } catch (e) {
console.log('exception in doInstall', e); console.log('exception in doInstall', e);
throw e; throw e;
} } finally {
finally {
this.eventEmitter.emit(); this.eventEmitter.emit();
} }
...@@ -1107,6 +1110,7 @@ export class AppsService { ...@@ -1107,6 +1110,7 @@ export class AppsService {
command.unshift(openAction.execute); command.unshift(openAction.execute);
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// @ts-ignore
let child = child_process.spawn(command.shift()!, command, { let child = child_process.spawn(command.shift()!, command, {
cwd: appPath, cwd: appPath,
env: env, env: env,
...@@ -1263,7 +1267,7 @@ export class AppsService { ...@@ -1263,7 +1267,7 @@ export class AppsService {
await this.restoreFiles(appDir, backupDir, Array.from(difference)); await this.restoreFiles(appDir, backupDir, Array.from(difference));
} }
} }
resolve(); resolve(null);
} catch (e) { } catch (e) {
reject(e); reject(e);
} }
......
...@@ -171,7 +171,7 @@ export class DownloadService { ...@@ -171,7 +171,7 @@ export class DownloadService {
if (allStatus.status === 'error') { if (allStatus.status === 'error') {
throw `Download Error: code ${allStatus.errorCode}, message: ${allStatus.errorMessage}`; throw `Download Error: code ${allStatus.errorCode}, message: ${allStatus.errorMessage}`;
} else if (allStatus.status === 'complete') { } else if (allStatus.status === 'complete') {
resolve(); resolve(null);
subscription.unsubscribe(); subscription.unsubscribe();
} else { } else {
callback(allStatus); callback(allStatus);
...@@ -199,7 +199,7 @@ export class DownloadService { ...@@ -199,7 +199,7 @@ export class DownloadService {
} }
async addMetalink (metalink: string, library: string): Promise<string> { async addMetalink (metalink: string, library: string): Promise<string> {
let encodedMeta4 = new Buffer((metalink)).toString('base64'); let encodedMeta4 = Buffer.from((metalink)).toString('base64');
let gidList = await this.aria2.addMetalink(encodedMeta4, {dir: library}); let gidList = await this.aria2.addMetalink(encodedMeta4, {dir: library});
let taskId = this.createId(); let taskId = this.createId();
this.taskMap.set(taskId, gidList); this.taskMap.set(taskId, gidList);
......
...@@ -28,7 +28,7 @@ export class ComparableSet<T> extends Set<T> { ...@@ -28,7 +28,7 @@ export class ComparableSet<T> extends Set<T> {
} }
intersection(setB: Set<T>): Set<T> { intersection(setB: Set<T>): Set<T> {
let intersection = new Set(); let intersection = new Set<T>();
for (let elem of setB) { for (let elem of setB) {
if (this.has(elem)) { if (this.has(elem)) {
intersection.add(elem); intersection.add(elem);
......
/** /**
* Created by zh99998 on 16/9/2. * Created by zh99998 on 16/9/2.
*/ */
import { import {ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild} from '@angular/core';
ChangeDetectorRef, import {Headers, Http} from '@angular/http';
Component,
ElementRef,
EventEmitter,
Input,
OnDestroy,
OnInit,
Output,
ViewChild
} from '@angular/core';
import { Headers, Http } from '@angular/http';
import * as child_process from 'child_process'; import * as child_process from 'child_process';
import { clipboard, remote, shell } from 'electron'; import {clipboard, remote, shell} from 'electron';
import * as fs from 'fs-extra'; import * as fs from 'fs-extra';
import * as ini from 'ini'; import * as ini from 'ini';
import { EncodeOptions } from 'ini'; import {EncodeOptions} from 'ini';
import * as $ from 'jquery'; import * as $ from 'jquery';
import * as path from 'path'; import * as path from 'path';
import 'rxjs/Rx'; import 'rxjs/Rx';
import { ISubscription } from 'rxjs/Subscription'; import {ISubscription} from 'rxjs/Subscription';
import { App } from './app'; import {App} from './app';
import { AppsService } from './apps.service'; import {AppsService} from './apps.service';
import { LoginService } from './login.service'; import {LoginService} from './login.service';
import { SettingsService } from './settings.sevices'; import {SettingsService} from './settings.sevices';
import Timer = NodeJS.Timer; import Timer = NodeJS.Timer;
import WillNavigateEvent = Electron.WillNavigateEvent; import WillNavigateEvent = Electron.WillNavigateEvent;
...@@ -87,6 +77,7 @@ interface Options { ...@@ -87,6 +77,7 @@ interface Options {
lflist?: number; lflist?: number;
time_limit?: number; time_limit?: number;
} }
export interface Points { export interface Points {
exp: number; exp: number;
exp_rank: number; exp_rank: number;
...@@ -155,7 +146,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -155,7 +146,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
time_limit: 180 time_limit: 180
}; };
room: Room = { title: this.loginService.user.username + '的房间', options: Object.assign({}, this.default_options) }; room: Room = {title: this.loginService.user.username + '的房间', options: Object.assign({}, this.default_options)};
rooms: Room[] = []; rooms: Room[] = [];
...@@ -184,8 +175,23 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -184,8 +175,23 @@ export class YGOProComponent implements OnInit, OnDestroy {
constructor(private http: Http, private appsService: AppsService, private loginService: LoginService, constructor(private http: Http, private appsService: AppsService, private loginService: LoginService,
public settingsService: SettingsService, private ref: ChangeDetectorRef) { public settingsService: SettingsService, private ref: ChangeDetectorRef) {
switch (process.platform) { switch (process.platform) {
// linux should have fonts set by default
case 'linux':
this.numfont = [
'/usr/share/fonts/truetype/DroidSansFallbackFull.ttf',
'/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc',
'/usr/share/fonts/google-noto-cjk/NotoSansCJK-Bold.ttc',
'/usr/share/fonts/noto-cjk/NotoSansCJK-Bold.ttc',
];
this.textfont = [
'/usr/share/fonts/truetype/DroidSansFallbackFull.ttf',
'/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc',
'/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc',
'/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc',
];
break;
case 'darwin': case 'darwin':
this.numfont = ['/System/Library/Fonts/SFNSTextCondensed-Bold.otf','/System/Library/Fonts/Supplemental/Arial.ttf']; this.numfont = ['/System/Library/Fonts/SFNSTextCondensed-Bold.otf', '/System/Library/Fonts/Supplemental/Arial.ttf'];
this.textfont = ['/System/Library/Fonts/PingFang.ttc']; this.textfont = ['/System/Library/Fonts/PingFang.ttc'];
break; break;
case 'win32': case 'win32':
...@@ -246,11 +252,11 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -246,11 +252,11 @@ export class YGOProComponent implements OnInit, OnDestroy {
refresh_replay_rooms() { refresh_replay_rooms() {
this.replay_rooms_show = this.replay_rooms.filter((room) => { this.replay_rooms_show = this.replay_rooms.filter((room) => {
return ((this.replay_rooms_filter.athletic && room.arena === 'athletic') || return ((this.replay_rooms_filter.athletic && room.arena === 'athletic') ||
(this.replay_rooms_filter.entertain && room.arena === 'entertain') || (this.replay_rooms_filter.entertain && room.arena === 'entertain') ||
(this.replay_rooms_filter.single && room.options.mode === 0 && !room.arena && !room.id!.startsWith('AI#')) || (this.replay_rooms_filter.single && room.options.mode === 0 && !room.arena && !room.id!.startsWith('AI#')) ||
(this.replay_rooms_filter.match && room.options.mode === 1 && !room.arena && !room.id!.startsWith('AI#')) || (this.replay_rooms_filter.match && room.options.mode === 1 && !room.arena && !room.id!.startsWith('AI#')) ||
(this.replay_rooms_filter.tag && room.options.mode === 2 && !room.arena && !room.id!.startsWith('AI#')) || (this.replay_rooms_filter.tag && room.options.mode === 2 && !room.arena && !room.id!.startsWith('AI#')) ||
(this.replay_rooms_filter.windbot && room.id!.startsWith('AI#'))); (this.replay_rooms_filter.windbot && room.id!.startsWith('AI#')));
}).sort((a, b) => { }).sort((a, b) => {
// if (a.arena === 'athletic' && b.arena === 'athletic') { // if (a.arena === 'athletic' && b.arena === 'athletic') {
// return a.dp - b.dp; // return a.dp - b.dp;
...@@ -306,11 +312,11 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -306,11 +312,11 @@ export class YGOProComponent implements OnInit, OnDestroy {
case 'init': case 'init':
this.rooms_loading = false; this.rooms_loading = false;
this.rooms = this.rooms.filter(room => room.server !== server).concat( this.rooms = this.rooms.filter(room => room.server !== server).concat(
message.data.map((room: Room) => Object.assign({ server: server }, room)) message.data.map((room: Room) => Object.assign({server: server}, room))
); );
break; break;
case 'create': case 'create':
this.rooms.push(Object.assign({ server: server }, message.data)); this.rooms.push(Object.assign({server: server}, message.data));
break; break;
case 'update': case 'update':
Object.assign(this.rooms.find(room => room.server === server && room.id === message.data.id), message.data); Object.assign(this.rooms.find(room => room.server === server && room.id === message.data.id), message.data);
...@@ -467,12 +473,12 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -467,12 +473,12 @@ export class YGOProComponent implements OnInit, OnDestroy {
}; };
async load_system_conf(): Promise<SystemConf> { async load_system_conf(): Promise<SystemConf> {
let data = await fs.readFile(this.system_conf, { encoding: 'utf-8' }); let data = await fs.readFile(this.system_conf, {encoding: 'utf-8'});
return <any>ini.parse(data); return <any>ini.parse(data);
}; };
save_system_conf(data: SystemConf) { save_system_conf(data: SystemConf) {
return fs.writeFile(this.system_conf, ini.unsafe(ini.stringify(data, <EncodeOptions>{ whitespace: true }))); return fs.writeFile(this.system_conf, ini.unsafe(ini.stringify(data, <EncodeOptions>{whitespace: true})));
}; };
async join(name: string, server: Server) { async join(name: string, server: Server) {
...@@ -530,7 +536,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -530,7 +536,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
child.on('exit', async (code, signal) => { child.on('exit', async (code, signal) => {
// error 触发之后还可能会触发exit,但是Promise只承认首次状态转移,因此这里无需重复判断是否已经error过。 // error 触发之后还可能会触发exit,但是Promise只承认首次状态转移,因此这里无需重复判断是否已经error过。
await this.refresh(); await this.refresh();
resolve(); resolve(null);
win.restore(); win.restore();
}); });
try { try {
...@@ -551,7 +557,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -551,7 +557,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
console.log(error); console.log(error);
} }
try { try {
this.http.get('https://api.mycard.moe/ygopro/arena/user', { search: { username: this.loginService.user.username } }) this.http.get('https://api.mycard.moe/ygopro/arena/user', {search: {username: this.loginService.user.username}})
.map((response) => response.json()) .map((response) => response.json())
.toPromise() .toPromise()
.then((d2) => { .then((d2) => {
...@@ -605,7 +611,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -605,7 +611,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
}; };
create_room(room: Room) { create_room(room: Room) {
let options_buffer = new Buffer(6); let options_buffer = Buffer.alloc(6);
// 建主密码 https://docs.google.com/document/d/1rvrCGIONua2KeRaYNjKBLqyG9uybs9ZI-AmzZKNftOI/edit // 建主密码 https://docs.google.com/document/d/1rvrCGIONua2KeRaYNjKBLqyG9uybs9ZI-AmzZKNftOI/edit
options_buffer.writeUInt8((room.private ? 2 : 1) << 4, 1); options_buffer.writeUInt8((room.private ? 2 : 1) << 4, 1);
options_buffer.writeUInt8( options_buffer.writeUInt8(
...@@ -629,7 +635,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -629,7 +635,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
} }
let password = options_buffer.toString('base64') + (room.private ? this.host_password : let password = options_buffer.toString('base64') + (room.private ? this.host_password :
room.title!.replace(/\s/, String.fromCharCode(0xFEFF))); room.title!.replace(/\s/, String.fromCharCode(0xFEFF)));
// let room_id = crypto.createHash('md5').update(password + this.loginService.user.username).digest('base64') // let room_id = crypto.createHash('md5').update(password + this.loginService.user.username).digest('base64')
// .slice(0, 10).replace('+', '-').replace('/', '_'); // .slice(0, 10).replace('+', '-').replace('/', '_');
...@@ -643,11 +649,13 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -643,11 +649,13 @@ export class YGOProComponent implements OnInit, OnDestroy {
copy(text: string, event: Event) { copy(text: string, event: Event) {
clipboard.writeText(text); clipboard.writeText(text);
$('#copy-wrapper').tooltip({ trigger: 'manual' }).tooltip('show'); const copyWrapper = $('#copy-wrapper');
copyWrapper.tooltip({trigger: 'manual'});
copyWrapper.tooltip('show');
} }
join_room(room: Room) { join_room(room: Room) {
let options_buffer = new Buffer(6); let options_buffer = Buffer.alloc(6);
options_buffer.writeUInt8(3 << 4, 1); options_buffer.writeUInt8(3 << 4, 1);
let checksum = 0; let checksum = 0;
for (let i = 1; i < options_buffer.length; i++) { for (let i = 1; i < options_buffer.length; i++) {
...@@ -667,7 +675,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -667,7 +675,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
} }
join_private(password: string) { join_private(password: string) {
let options_buffer = new Buffer(6); let options_buffer = Buffer.alloc(6);
options_buffer.writeUInt8(5 << 4, 1); options_buffer.writeUInt8(5 << 4, 1);
let checksum = 0; let checksum = 0;
for (let i = 1; i < options_buffer.length; i++) { for (let i = 1; i < options_buffer.length; i++) {
...@@ -699,7 +707,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -699,7 +707,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
} }
}).map(response => response.json()) }).map(response => response.json())
.subscribe((data) => { .subscribe((data) => {
this.join(data['password'], { address: data['address'], port: data['port'] }); this.join(data['password'], {address: data['address'], port: data['port']});
}, (error) => { }, (error) => {
alert(`匹配失败`); alert(`匹配失败`);
this.matching = matching = undefined; this.matching = matching = undefined;
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
<i class="fa fa-times close" i18n="" i18n-title="" title="关闭" onclick="window.close()"></i> <i class="fa fa-times close" i18n="" i18n-title="" title="关闭" onclick="window.close()"></i>
</div> </div>
<div class="loading"> <div id="loading">
<img src="./images/CubbitLogo.png"> <img src="./images/CubbitLogo.png">
<p> <p>
LOADING LOADING
......
...@@ -12,7 +12,7 @@ function handleElevate() { ...@@ -12,7 +12,7 @@ function handleElevate() {
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
require('electron').app.dock.hide(); require('electron').app.dock.hide();
} }
let elevate = JSON.parse(new Buffer(process.argv[2], 'base64').toString()); let elevate = JSON.parse(Buffer.from(process.argv[2], 'base64').toString());
require('net').connect(elevate['ipc'], function () { require('net').connect(elevate['ipc'], function () {
process.send = (message, sendHandle, options, callback) => this.write(JSON.stringify(message) + require('os').EOL, callback); process.send = (message, sendHandle, options, callback) => this.write(JSON.stringify(message) + require('os').EOL, callback);
this.on('end', () => process.emit('disconnect')); this.on('end', () => process.emit('disconnect'));
...@@ -130,6 +130,9 @@ function createAria2c() { ...@@ -130,6 +130,9 @@ function createAria2c() {
aria2c_path = path.join('bin', 'aria2c'); aria2c_path = path.join('bin', 'aria2c');
} }
break; break;
case 'linux':
aria2c_path = '/usr/bin/aria2c';
break;
default: default:
throw 'unsupported platform'; throw 'unsupported platform';
} }
...@@ -146,6 +149,7 @@ function createWindow() { ...@@ -146,6 +149,7 @@ function createWindow() {
minWidth: 1024, minWidth: 1024,
minHeight: 640, minHeight: 640,
frame: process.platform === 'darwin', frame: process.platform === 'darwin',
webPreferences: { nodeIntegration: true, contextIsolation: false, enableRemoteModule: true, webviewTag: true },
// transparent: process.platform != 'darwin', // transparent: process.platform != 'darwin',
titleBarStyle: process.platform === 'darwin' ? 'hidden' : undefined titleBarStyle: process.platform === 'darwin' ? 'hidden' : undefined
}); });
......
...@@ -2,7 +2,7 @@ const raw = require("raw-socket"); ...@@ -2,7 +2,7 @@ const raw = require("raw-socket");
let socket = raw.createSocket({protocol: raw.Protocol.UDP}); let socket = raw.createSocket({protocol: raw.Protocol.UDP});
let connect = (local_port, remote_port, remote_address)=> { let connect = (local_port, remote_port, remote_address)=> {
let buffer = new Buffer(9); let buffer = Buffer.alloc(9);
buffer.writeUInt16BE(local_port, 0); buffer.writeUInt16BE(local_port, 0);
buffer.writeUInt16BE(remote_port, 2); buffer.writeUInt16BE(remote_port, 2);
buffer.writeUInt16BE(buffer.length, 4); buffer.writeUInt16BE(buffer.length, 4);
...@@ -21,4 +21,4 @@ process.on('message', (message)=> { ...@@ -21,4 +21,4 @@ process.on('message', (message)=> {
process.on('disconnect', process.exit); process.on('disconnect', process.exit);
process.send('initialized'); process.send('initialized');
\ No newline at end of file
This diff is collapsed.
{ {
"name": "mycard", "name": "mycard",
"version": "3.0.37", "version": "3.0.38",
"description": "moecube", "description": "moecube",
"keywords": [], "keywords": [],
"author": "zh99998 <zh99998@gmail.com>", "author": "zh99998 <zh99998@gmail.com>",
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
"scripts": { "scripts": {
"start": "tsc && electron .", "start": "tsc && electron .",
"lint": "tslint ./app/*.ts -t verbose", "lint": "tslint ./app/*.ts -t verbose",
"pack": "tsc && build --dir", "pack": "tsc && electron-builder --dir",
"dist": "tsc && build", "dist": "tsc && electron-builder",
"release": "tsc && build", "release": "tsc && electron-builder",
"build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup-config.js", "build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup-config.js",
"tsc": "tsc", "tsc": "tsc",
"i18n": "ng-xi18n --i18nFormat 'xlf2' && sed -i.bak 's/source-language=\"en\"/source-language=\"zh-CN\"/' messages.xlf", "i18n": "ng-xi18n --i18nFormat 'xlf2' && sed -i.bak 's/source-language=\"en\"/source-language=\"zh-CN\"/' messages.xlf",
...@@ -62,17 +62,17 @@ ...@@ -62,17 +62,17 @@
"zone.js": "0.8.12" "zone.js": "0.8.12"
}, },
"devDependencies": { "devDependencies": {
"@angular/compiler-cli": "latest", "@angular/compiler-cli": "4.2.6",
"@angular/platform-server": "latest", "@angular/platform-server": "4.2.6",
"@types/bootstrap": "latest", "@types/bootstrap": "^4.0.0",
"@types/glob": "latest", "@types/glob": "latest",
"@types/ini": "latest", "@types/ini": "latest",
"@types/jquery": "^2.0.47", "@types/jquery": "^2.0.47",
"@types/marked": "latest", "@types/marked": "latest",
"@types/node": "latest", "@types/node": "^14.0.1",
"@types/tether": "latest", "@types/tether": "latest",
"@types/typeahead": "latest", "@types/typeahead": "latest",
"electron": "latest", "electron": "^4.2.12",
"electron-builder": "latest", "electron-builder": "latest",
"rollup": "latest", "rollup": "latest",
"rollup-plugin-commonjs": "latest", "rollup-plugin-commonjs": "latest",
...@@ -88,14 +88,26 @@ ...@@ -88,14 +88,26 @@
{ {
"provider": "generic", "provider": "generic",
"url": "https://api.moecube.com/downloads" "url": "https://api.moecube.com/downloads"
},
{
"provider": "github"
} }
], ],
"extraResources": [ "extraResources": [
"bin" "bin"
], ],
"linux": {
"target": [
{
"target": "AppImage"
}
]
},
"appImage": {
"publish": [
{
"provider": "generic",
"url": "https://api.moecube.com/downloads"
}
]
},
"dmg": { "dmg": {
"contents": [ "contents": [
{ {
......
...@@ -124,14 +124,14 @@ body.resizing /deep/ * { ...@@ -124,14 +124,14 @@ body.resizing /deep/ * {
color:#000; color:#000;
} }
.loading { #loading {
height:100%; height:100%;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
flex-direction:column; flex-direction:column;
} }
.loading p{ #loading p{
position:relative; position:relative;
top:-15px; top:-15px;
left:10px; left:10px;
...@@ -141,12 +141,12 @@ body.resizing /deep/ * { ...@@ -141,12 +141,12 @@ body.resizing /deep/ * {
text-shadow: 0 3px 8px rgba(0,0,0,0.1); text-shadow: 0 3px 8px rgba(0,0,0,0.1);
} }
.loading p>span{ #loading p>span{
opacity:0; opacity:0;
} }
.loading p>span:nth-child(1) {animation:show 2s infinite 0.0s linear;} #loading p>span:nth-child(1) {animation:show 2s infinite 0.0s linear;}
.loading p>span:nth-child(2) {animation:show 2s infinite 0.2s linear;} #loading p>span:nth-child(2) {animation:show 2s infinite 0.2s linear;}
.loading p>span:nth-child(3) {animation:show 2s infinite 0.4s linear;} #loading p>span:nth-child(3) {animation:show 2s infinite 0.4s linear;}
@keyframes show{ @keyframes show{
from{} from{}
...@@ -156,10 +156,10 @@ body.resizing /deep/ * { ...@@ -156,10 +156,10 @@ body.resizing /deep/ * {
71% {opacity:0;} 71% {opacity:0;}
to {} to {}
} }
.loading>img{ #loading>img{
width:300px; width:300px;
} }
@keyframes zhuan{ @keyframes zhuan{
from{transform:rotate(0deg);} from{transform:rotate(0deg);}
to {transform:rotate(360deg);} to {transform:rotate(360deg);}
} }
\ No newline at end of file
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
"noImplicitAny": true, "noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true, "suppressImplicitAnyIndexErrors": true,
"strictNullChecks": false, "strictNullChecks": false,
"strict": false,
"skipLibCheck": true "skipLibCheck": true
}, },
"files": [ "files": [
......
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