Commit 8fd6747f authored by 神楽坂玲奈's avatar 神楽坂玲奈

update bootstrap & ygopro deck group init

parent 231a79bf
...@@ -2,22 +2,22 @@ ...@@ -2,22 +2,22 @@
<img *ngIf="currentApp.cover" class="cover rounded" [src]="currentApp.cover"> <img *ngIf="currentApp.cover" class="cover rounded" [src]="currentApp.cover">
<div id="right"> <div id="right">
<h1>{{currentApp.name}}</h1> <h1>{{currentApp.name}}</h1>
<div id="time">您已玩了 2564 小时</div> <!-- <div id="time">您已玩了 2564 小时</div>-->
<!--应用未购买--> <!--应用未购买-->
<div *ngIf="!currentApp.isBought()"> <div *ngIf="!currentApp.isBought()">
<button i18n type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#purchase-modal">{{currentApp.price.cny | currency:'CNY':true}} 购买</button> <button i18n type="button" class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#purchase-modal">{{currentApp.price.cny | currency:'CNY':true}} 购买</button>
<button i18n type="button" (click)="updateInstallOption(currentApp)" class="btn btn-secondary btn-sm" data-toggle="modal" data-target="#install-modal">安装试玩版</button> <button i18n type="button" (click)="updateInstallOption(currentApp)" class="btn btn-secondary btn-sm" data-bs-toggle="modal" data-bs-target="#install-modal">安装试玩版</button>
<!--<button i18n (click)="updateInstallOption(currentApp)" type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#install-modal">我已经购买过</button>--> <!--<button i18n (click)="updateInstallOption(currentApp)" type="button" class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#install-modal">我已经购买过</button>-->
</div> </div>
<!--应用已购买,未安装--> <!--应用已购买,未安装-->
<div *ngIf="currentApp.isBought() && !currentApp.isInstalled()" class="i-b"> <div *ngIf="currentApp.isBought() && !currentApp.isInstalled()" class="i-b">
<button i18n (click)="updateInstallOption(currentApp)" type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#install-modal">安装</button> <button i18n (click)="updateInstallOption(currentApp)" type="button" class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#install-modal">安装</button>
<button i18n *ngIf="currentApp.runnable()" (click)="updateInstallOption(currentApp)" type="button" class="btn btn-secondary btn-sm" data-toggle="modal" data-target="#import-modal">导入</button> <button i18n *ngIf="currentApp.runnable()" (click)="updateInstallOption(currentApp)" type="button" class="btn btn-secondary btn-sm" data-bs-toggle="modal" data-bs-target="#import-modal">导入</button>
</div> </div>
<!--应用变更中--> <!--应用变更中-->
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
<!--<div class="input-group-btn" style="flex-direction: row">--> <!--<div class="input-group-btn" style="flex-direction: row">-->
<!--<button i18n *ngIf="!appsService.connections.get(currentApp)" [disabled]="!appsService.allReady(currentApp)" (click)="appsService.network(currentApp, currentApp.network.servers[0])" type="button" class="btn btn-secondary btn-sm">联机</button>--> <!--<button i18n *ngIf="!appsService.connections.get(currentApp)" [disabled]="!appsService.allReady(currentApp)" (click)="appsService.network(currentApp, currentApp.network.servers[0])" type="button" class="btn btn-secondary btn-sm">联机</button>-->
<!--<button i18n *ngIf="appsService.connections.get(currentApp)" (click)="copy(appsService.connections.get(currentApp).address)" [disabled]="!appsService.connections.get(currentApp).address" type="button" class="btn btn-secondary btn-sm">复制</button>--> <!--<button i18n *ngIf="appsService.connections.get(currentApp)" (click)="copy(appsService.connections.get(currentApp).address)" [disabled]="!appsService.connections.get(currentApp).address" type="button" class="btn btn-secondary btn-sm">复制</button>-->
<!--<button type="button" class="btn btn-sm btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"></button>--> <!--<button type="button" class="btn btn-sm btn-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown"></button>-->
<!--<div class="dropdown-menu" [class.dropdown-menu-right]="appsService.connections.get(currentApp)">--> <!--<div class="dropdown-menu" [class.dropdown-menu-right]="appsService.connections.get(currentApp)">-->
<!--<h6 i18n class="dropdown-header">选择服务器</h6>--> <!--<h6 i18n class="dropdown-header">选择服务器</h6>-->
<!--<a *ngFor="let server of currentApp.network.servers" (click)="appsService.network(currentApp, server)" class="dropdown-item" href="#">{{server.id}}</a>--> <!--<a *ngFor="let server of currentApp.network.servers" (click)="appsService.network(currentApp, server)" class="dropdown-item" href="#">{{server.id}}</a>-->
...@@ -200,7 +200,7 @@ ...@@ -200,7 +200,7 @@
<form id="install-form" class="modal-content" (ngSubmit)="install(currentApp,installOption,referencesInstall)" #theForm="ngForm"> <form id="install-form" class="modal-content" (ngSubmit)="install(currentApp,installOption,referencesInstall)" #theForm="ngForm">
<div class="modal-header"> <div class="modal-header">
<h5 i18n class="modal-title" id="myModalLabel">安装 {{currentApp.name}}</h5> <h5 i18n class="modal-title" id="myModalLabel">安装 {{currentApp.name}}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
<span>&times;</span> <span>&times;</span>
</button> </button>
</div> </div>
...@@ -233,7 +233,7 @@ ...@@ -233,7 +233,7 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button i18n type="button" class="btn btn-secondary" data-dismiss="modal">取消</button> <button i18n type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
<button i18n type="submit" [disabled]="!theForm.form.valid" class="btn btn-primary">安装</button> <button i18n type="submit" [disabled]="!theForm.form.valid" class="btn btn-primary">安装</button>
</div> </div>
</form> </form>
...@@ -242,20 +242,14 @@ ...@@ -242,20 +242,14 @@
<div class="modal fade" id="import-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" *ngIf="installOption"> <div class="modal fade" id="import-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" *ngIf="installOption">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<form id="import-form" class="modal-content" (ngSubmit)="importGame(currentApp,installOption,referencesInstall)" #theForm="ngForm"> <form id="import-form" class="modal-content" (ngSubmit)="importGame(file.files[0].path,currentApp,installOption,referencesInstall)" #theForm="ngForm" ngNativeValidate>
<div class="modal-header"> <div class="modal-header">
<h5 i18n class="modal-title">导入 {{currentApp.name}}</h5> <h5 i18n class="modal-title">导入 {{currentApp.name}}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
<span>&times;</span>
</button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p i18n>选择主程序 {{currentApp.actions.get('main').execute}}</p> <p i18n>选择主程序 {{currentApp.actions.get('main').execute}}</p>
<label class="custom-file" lang="en"> <input #file name="file" type="file" id="file" class="form-control" required>
<input (click)="$event.preventDefault();selectImport(currentApp)" type="file" id="file" class="custom-file-input">
<span class="custom-file-control">{{import_path || currentApp.actions.get('main').execute}}</span>
</label>
<h4 i18n>导入到</h4> <h4 i18n>导入到</h4>
<div class="form-group"> <div class="form-group">
<select class="form-control" name="installPath" (change)="selectLibrary()" [(ngModel)]="installOption.installLibrary" title="path"> <select class="form-control" name="installPath" (change)="selectLibrary()" [(ngModel)]="installOption.installLibrary" title="path">
...@@ -283,7 +277,7 @@ ...@@ -283,7 +277,7 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button i18n type="button" class="btn btn-secondary" data-dismiss="modal">取消</button> <button i18n type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
<button i18n type="submit" [disabled]="import_path && !theForm.form.valid" class="btn btn-primary">导入</button> <button i18n type="submit" [disabled]="import_path && !theForm.form.valid" class="btn btn-primary">导入</button>
</div> </div>
</form> </form>
...@@ -296,7 +290,7 @@ ...@@ -296,7 +290,7 @@
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 i18n class="modal-title">购买 {{currentApp.name}}</h5> <h5 i18n class="modal-title">购买 {{currentApp.name}}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
<span>&times;</span> <span>&times;</span>
</button> </button>
</div> </div>
...@@ -336,7 +330,7 @@ ...@@ -336,7 +330,7 @@
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button i18n class="btn btn-secondary" data-dismiss="modal">取消</button> <button i18n class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
<button i18n [disabled]="creating_order" class="btn btn-primary" (click)="purchase()">购买</button> <button i18n [disabled]="creating_order" class="btn btn-primary" (click)="purchase()">购买</button>
</div> </div>
</div> </div>
...@@ -349,7 +343,7 @@ ...@@ -349,7 +343,7 @@
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 i18n class="modal-title">购买 {{currentApp.name}}</h5> <h5 i18n class="modal-title">购买 {{currentApp.name}}</h5>
<!--<button type="button" class="close" data-dismiss="modal" aria-label="Close">--> <!--<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">-->
<!--<span>&times;</span>--> <!--<span>&times;</span>-->
<!--</button>--> <!--</button>-->
</div> </div>
...@@ -360,7 +354,7 @@ ...@@ -360,7 +354,7 @@
若支付失败,请返回并选择其他支付方式 若支付失败,请返回并选择其他支付方式
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button i18n type="button" class="btn btn-secondary" data-dismiss="modal">返回</button> <button i18n type="button" class="btn btn-secondary" data-bs-dismiss="modal">返回</button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -36,7 +36,7 @@ export class AppDetailComponent implements OnInit, OnChanges { ...@@ -36,7 +36,7 @@ export class AppDetailComponent implements OnInit, OnChanges {
references: App[]; references: App[];
referencesInstall: { [id: string]: boolean }; referencesInstall: { [id: string]: boolean };
import_path: string; // import_path: string;
background: string; background: string;
points: Points; points: Points;
...@@ -68,9 +68,9 @@ export class AppDetailComponent implements OnInit, OnChanges { ...@@ -68,9 +68,9 @@ export class AppDetailComponent implements OnInit, OnChanges {
} }
async ngOnChanges(changes: SimpleChanges) { async ngOnChanges(changes: SimpleChanges) {
if (this.currentApp.isBought()) { // if (this.currentApp.isBought()) {
$('#purchase-modal-alipay').modal('hide'); // $('#purchase-modal-alipay').modal('hide');
} // }
if (changes['currentApp']) { if (changes['currentApp']) {
if (this.currentApp.background) { if (this.currentApp.background) {
this.el.nativeElement.style.background = `url("${this.currentApp.background}") rgba(255,255,255,.8)`; this.el.nativeElement.style.background = `url("${this.currentApp.background}") rgba(255,255,255,.8)`;
...@@ -150,7 +150,7 @@ export class AppDetailComponent implements OnInit, OnChanges { ...@@ -150,7 +150,7 @@ export class AppDetailComponent implements OnInit, OnChanges {
} }
async install(targetApp: App, options: InstallOption, referencesInstall: { [id: string]: boolean }) { async install(targetApp: App, options: InstallOption, referencesInstall: { [id: string]: boolean }) {
$('#install-modal').modal('hide'); // $('#install-modal').modal('hide');
try { try {
await this.appsService.install(targetApp, options); await this.appsService.install(targetApp, options);
...@@ -210,9 +210,8 @@ export class AppDetailComponent implements OnInit, OnChanges { ...@@ -210,9 +210,8 @@ export class AppDetailComponent implements OnInit, OnChanges {
await this.appsService.runApp(app, 'roll'); await this.appsService.runApp(app, 'roll');
} }
async importGame(targetApp: App, option: InstallOption, referencesInstall: { [id: string]: boolean }) { async importGame(origin: string, targetApp: App, option: InstallOption, referencesInstall: { [id: string]: boolean }) {
$('#import-modal').modal('hide'); let dir = path.dirname(origin);
let dir = path.dirname(this.import_path);
// TODO: 执行依赖和references安装 // TODO: 执行依赖和references安装
try { try {
await this.appsService.importApp(targetApp, dir, option); await this.appsService.importApp(targetApp, dir, option);
...@@ -248,57 +247,57 @@ export class AppDetailComponent implements OnInit, OnChanges { ...@@ -248,57 +247,57 @@ export class AppDetailComponent implements OnInit, OnChanges {
clipboard.writeText(text); clipboard.writeText(text);
} }
async selectImport(app: App) { // async selectImport(app: App) {
let main = app.actions.get('main'); // let main = app.actions.get('main');
if (!main) { // if (!main) {
return; // return;
} // }
if (!main.execute) { // if (!main.execute) {
return; // return;
} // }
let filename = main.execute.split('/')[0]; // let filename = main.execute.split('/')[0];
let extname = path.extname(filename).slice(1); // let extname = path.extname(filename).slice(1);
//
// let remote = require('electron').remote // // let remote = require('electron').remote
let filePaths = await new Promise<string[]>((resolve, reject) => { // let filePaths = await new Promise<string[]>((resolve, reject) => {
remote.dialog.showOpenDialog({ // remote.dialog.showOpenDialog({
filters: [{name: filename, extensions: [extname]}], // filters: [{name: filename, extensions: [extname]}],
properties: ['openFile'] // properties: ['openFile']
}, resolve); // }, resolve);
}); // });
//
if (filePaths && filePaths[0]) { // if (filePaths && filePaths[0]) {
this.import_path = filePaths[0]; // this.import_path = filePaths[0];
} // }
//
} // }
onPoints(points: Points) { onPoints(points: Points) {
this.points = points; this.points = points;
} }
async purchase() { // async purchase() {
this.creating_order = true; // this.creating_order = true;
let data = new URLSearchParams(); // let data = new URLSearchParams();
data.set('app_id', this.currentApp.id); // data.set('app_id', this.currentApp.id);
data.set('user_id', this.loginService.user.email); // data.set('user_id', this.loginService.user.email);
data.set('currency', 'cny'); // data.set('currency', 'cny');
data.set('payment', this.payment); // data.set('payment', this.payment);
try { // try {
let {url} = await this.http.post('https://sapi.moecube.com:444/orders', data).map(response => response.json()).toPromise(); // let {url} = await this.http.post('https://sapi.moecube.com:444/orders', data).map(response => response.json()).toPromise();
open(url); // open(url);
$('#purchase-modal').modal('hide'); // $('#purchase-modal').modal('hide');
$('#purchase-modal-alipay').modal('show'); // $('#purchase-modal-alipay').modal('show');
} catch (error) { // } catch (error) {
console.log(error); // console.log(error);
if (error.status === 409) { // if (error.status === 409) {
alert('卖完了 /\\'); // alert('卖完了 /\\');
} else if (error.status === 403) { // } else if (error.status === 403) {
alert('已经购买过 /\\'); // alert('已经购买过 /\\');
} else { // } else {
alert('出错了 /\\'); // alert('出错了 /\\');
} // }
} // }
this.creating_order = false; // this.creating_order = false;
} // }
} }
<!-- Begin page content --> <!-- Begin page content -->
<div #nav id="nav-wrapper" class="resize-wrapper resize-right"> <div #nav id="nav-wrapper" class="resize-wrapper resize-right">
<nav id="apps" *ngIf="apps" class="bg-faded sidebar scroll"> <nav id="apps" *ngIf="apps" class="bg-faded sidebar scroll">
<div id="search" class="input-group"> <!-- <div id="search" class="input-group">-->
<i class="fa fa-search input-group-addon search" id="basic-addon1"></i> <!-- <i class="fa fa-search input-group-addon search" id="basic-addon1"></i>-->
<input i18n-placeholder #search id="search-input" type="text" class="form-control search" placeholder="搜索游戏" aria-describedby="basic-addon1"> <!-- <input i18n-placeholder #search id="search-input" type="text" class="form-control search" placeholder="搜索游戏" aria-describedby="basic-addon1">-->
</div> <!-- </div>-->
<span i18n *ngIf="grouped_apps.installed">已安装</span> <span i18n *ngIf="grouped_apps.installed">已安装</span>
<ul *ngIf="grouped_apps.installed" class="nav nav-pills flex-column"> <ul *ngIf="grouped_apps.installed" class="nav nav-pills flex-column">
......
<nav id="navbar" class="navbar navbar-toggleable-md navbar-light"> <header id="navbar" class="navbar navbar-toggleable-md navbar-light">
<a id="navbar-brand" class="navbar-brand" href="#"> <a id="navbar-brand" class="navbar-brand" href="#">
<img src="images/icon.ico" /> MyCard <img src="images/icon.ico" /> MyCard
</a> </a>
<ul class="navbar-nav mr-auto"> <ul class="nav me-auto">
<li *ngIf="!loginService.logged_in" class="nav-item active"> <li *ngIf="!loginService.logged_in" class="nav-item active">
<a i18n class="nav-link" href="#">登录</a> <a i18n class="nav-link" href="#">登录</a>
</li> </li>
...@@ -26,16 +26,16 @@ ...@@ -26,16 +26,16 @@
</ul> </ul>
<div id="navbar-right"> <div id="navbar-right">
<div id="update-status"> <div id="update-status">
<i #error [hidden]="update_status != 'error'" (click)="update_retry()" class="fa fa-exclamation-circle" data-toggle="tooltip" i18n-title title="更新出错,点击重试"></i> <i #error [hidden]="update_status != 'error'" (click)="update_retry()" class="fa fa-exclamation-circle" data-bs-toggle="tooltip" i18n-title title="更新出错,点击重试"></i>
<i #checking_for_update [hidden]="update_status != 'checking-for-update'" class="fa fa-spinner fa-pulse fa-spin" data-toggle="tooltip" i18n-title title="正在检查更新"></i> <i #checking_for_update [hidden]="update_status != 'checking-for-update'" class="fa fa-spinner fa-pulse fa-spin" data-bs-toggle="tooltip" i18n-title title="正在检查更新"></i>
<i #update_available [hidden]="update_status != 'update-available'" class="fa fa-refresh fa-spin" data-toggle="tooltip" i18n-title title="正在下载更新"></i> <i #update_available [hidden]="update_status != 'update-available'" class="fa fa-refresh fa-spin" data-bs-toggle="tooltip" i18n-title title="正在下载更新"></i>
<i #update_downloaded [hidden]="update_status != 'update-downloaded'" (click)="update_install()" class="fa fa-angle-double-up" data-toggle="tooltip" i18n-title title="下载更新完成,点击安装"></i> <i #update_downloaded [hidden]="update_status != 'update-downloaded'" (click)="update_install()" class="fa fa-angle-double-up" data-bs-toggle="tooltip" i18n-title title="下载更新完成,点击安装"></i>
</div> </div>
<div id="user" *ngIf="loginService.logged_in"> <div id="user" *ngIf="loginService.logged_in">
<a href="#" class="profile"><img id="avatar" [src]="loginService.user.avatar_url" alt="image"></a> <a href="#" class="profile"><img id="avatar" [src]="loginService.user.avatar_url" alt="image"></a>
<a href="#" class="profile item" id="username">{{loginService.user.username}}</a> <a href="#" class="profile item" id="username">{{loginService.user.username}}</a>
<i i18n (click)="loginService.logout()" class="fa fa-sign-out item-icon" aria-hidden="true" i18n-title title="切换用户"></i> <i i18n (click)="loginService.logout()" class="fa fa-sign-out item-icon" aria-hidden="true" i18n-title title="切换用户"></i>
<i i18n data-toggle="modal" data-target="#settings-modal" class="fa fa-cog item-icon" aria-hidden="true" i18n-title title="设置"></i> <i i18n data-bs-toggle="modal" data-bs-target="#settings-modal" class="fa fa-cog item-icon" aria-hidden="true" i18n-title title="设置"></i>
</div> </div>
<div id="border">|</div> <div id="border">|</div>
<div id="window-buttons"> <div id="window-buttons">
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
<i i18n (click)="currentWindow.hide()" class="fa fa-times" i18n-title title="关闭"></i> <i i18n (click)="currentWindow.hide()" class="fa fa-times" i18n-title title="关闭"></i>
</div> </div>
</div> </div>
</nav> </header>
<login class="page" *ngIf="!loginService.logged_in"></login> <login class="page" *ngIf="!loginService.logged_in"></login>
<store class="page" *ngIf="loginService.logged_in" [hidden]="currentPage != 'store'"></store> <store class="page" *ngIf="loginService.logged_in" [hidden]="currentPage != 'store'"></store>
<lobby class="page" *ngIf="loginService.logged_in" [hidden]="currentPage != 'lobby'"></lobby> <lobby class="page" *ngIf="loginService.logged_in" [hidden]="currentPage != 'lobby'"></lobby>
...@@ -59,9 +59,7 @@ ...@@ -59,9 +59,7 @@
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 i18n class="modal-title" id="myModalLabel">MyCard 设置</h5> <h5 i18n class="modal-title" id="myModalLabel">MyCard 设置</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
<span aria-hidden="true">&times;</span>
</button>
</div> </div>
<form (submit)="submit()"> <form (submit)="submit()">
<div class="modal-body"> <div class="modal-body">
...@@ -78,8 +76,8 @@ ...@@ -78,8 +76,8 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button i18n type="button" class="btn btn-secondary" data-dismiss="modal">取消</button> <button i18n type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
<button i18n type="submit" class="btn btn-primary">确定</button> <button i18n type="submit" class="btn btn-primary" data-bs-dismiss="modal">确定</button>
</div> </div>
</form> </form>
</div> </div>
......
import {ChangeDetectorRef, Component, ElementRef, OnInit, Renderer, ViewChild} from '@angular/core'; import {ChangeDetectorRef, Component, ElementRef, OnInit, Renderer, ViewChild} from '@angular/core';
import 'bootstrap';
import {remote, shell} from 'electron'; import {remote, shell} from 'electron';
import * as $ from 'jquery'; import * as $ from 'jquery';
import * as Tether from 'tether';
import {LoginService} from './login.service'; import {LoginService} from './login.service';
import {SettingsService} from './settings.sevices'; import {SettingsService} from './settings.sevices';
window['Tether'] = Tether; import 'bootstrap';
const autoUpdater: Electron.AutoUpdater = remote.getGlobal('autoUpdater'); const autoUpdater: Electron.AutoUpdater = remote.getGlobal('autoUpdater');
const konami_code_logger: string[] = []; const konami_code_logger: string[] = [];
...@@ -139,7 +137,6 @@ export class MyCardComponent implements OnInit { ...@@ -139,7 +137,6 @@ export class MyCardComponent implements OnInit {
remote.app.relaunch(); remote.app.relaunch();
remote.app.quit(); remote.app.quit();
} }
$('#settings-modal').modal('hide');
} }
// //
......
<div id="network" *ngIf="currentApp.network && currentApp.network.protocol == 'maotama'"> <div id="network" *ngIf="currentApp.network && currentApp.network.protocol == 'maotama'">
<!--<button (click)="log(appsService)">test</button>-->
<div class="input-group input-group-sm"> <div class="input-group input-group-sm">
<input *ngIf="appsService.connections.get(currentApp)" [value]="appsService.connections.get(currentApp).address || 'Loading...'" readonly type="text" class="form-control" title="address"> <input *ngIf="appsService.connections.get(currentApp)" [value]="appsService.connections.get(currentApp).address || 'Loading...'" readonly type="text" class="form-control" title="address">
<div class="input-group-btn" style="flex-direction: row"> <button i18n *ngIf="!appsService.connections.get(currentApp)" [disabled]="!appsService.allReady(currentApp)" (click)="appsService.network(currentApp, currentApp.network.servers[0])" type="button" class="btn btn-outline-secondary btn-sm">联机</button>
<button i18n *ngIf="!appsService.connections.get(currentApp)" [disabled]="!appsService.allReady(currentApp)" (click)="appsService.network(currentApp, currentApp.network.servers[0])" type="button" class="btn btn-secondary btn-sm">联机</button> <button i18n *ngIf="appsService.connections.get(currentApp)" (click)="copy(appsService.connections.get(currentApp).address)" [disabled]="!appsService.connections.get(currentApp).address" type="button" class="btn btn-outline-secondary btn-sm">复制</button>
<button i18n *ngIf="appsService.connections.get(currentApp)" (click)="copy(appsService.connections.get(currentApp).address)" [disabled]="!appsService.connections.get(currentApp).address" type="button" class="btn btn-secondary btn-sm">复制</button> <button type="button" class="btn btn-sm btn-outline-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown"></button>
<button type="button" class="btn btn-sm btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"></button> <div class="dropdown-menu" [class.dropdown-menu-right]="appsService.connections.get(currentApp)">
<div class="dropdown-menu" [class.dropdown-menu-right]="appsService.connections.get(currentApp)"> <h6 i18n class="dropdown-header">选择服务器</h6>
<h6 i18n class="dropdown-header">选择服务器</h6> <a *ngFor="let server of currentApp.network.servers" (click)="appsService.network(currentApp, server)" class="dropdown-item" href="#">{{server.id}}</a>
<a *ngFor="let server of currentApp.network.servers" (click)="appsService.network(currentApp, server)" class="dropdown-item" href="#">{{server.id}}</a> <div *ngIf="appsService.connections.get(currentApp)" class="dropdown-divider"></div>
<div *ngIf="appsService.connections.get(currentApp)" class="dropdown-divider"></div> <a i18n *ngIf="appsService.connections.get(currentApp)" (click)="appsService.connections.get(currentApp).connection.close()" class="dropdown-item" href="#">取消</a>
<a i18n *ngIf="appsService.connections.get(currentApp)" (click)="appsService.connections.get(currentApp).connection.close()" class="dropdown-item" href="#">取消</a>
</div>
</div> </div>
</div> </div>
</div> </div>
import {clipboard} from 'electron';
import {Component, Injectable, Input} from '@angular/core'; import {Component, Injectable, Input} from '@angular/core';
import {AppsService} from './apps.service'; import {AppsService} from './apps.service';
import {App} from './app'; import {App} from './app';
...@@ -14,6 +15,10 @@ export class NetworkComponent { ...@@ -14,6 +15,10 @@ export class NetworkComponent {
currentApp: App; currentApp: App;
constructor(private appsService: AppsService) { constructor(private appsService: AppsService) {
console.log( 'constructor' ); console.log('constructor');
}
copy(text: string) {
clipboard.writeText(text);
} }
} }
This diff is collapsed.
...@@ -13,9 +13,10 @@ import {App} from './app'; ...@@ -13,9 +13,10 @@ 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 * as _ from 'lodash';
import * as fg from 'fast-glob';
import WillNavigateEvent = Electron.WillNavigateEvent; import WillNavigateEvent = Electron.WillNavigateEvent;
import _ = require('lodash'); import Timer = NodeJS.Timer;
interface SystemConf { interface SystemConf {
use_d3d: string; use_d3d: string;
...@@ -125,6 +126,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -125,6 +126,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
@Output() @Output()
points: EventEmitter<Points> = new EventEmitter(); points: EventEmitter<Points> = new EventEmitter();
decks: string[] = []; decks: string[] = [];
decks_grouped: [string, string[]][];
replays: string[] = []; replays: string[] = [];
current_deck: string; current_deck: string;
system_conf: string; system_conf: string;
...@@ -136,28 +138,19 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -136,28 +138,19 @@ export class YGOProComponent implements OnInit, OnDestroy {
@ViewChild('youtube') @ViewChild('youtube')
youtube: ElementRef; youtube: ElementRef;
// points: Points;
get windbot() {
return this.currentServer.windbot;
}
// points: Points;
servers: Server[]; servers: Server[];
selectableServers: Server[]; selectableServers: Server[];
// selectingServerId: string; // selectingServerId: string;
currentServer: Server; currentServer: Server;
// tslint:disable-next-line:member-ordering
rooms_loading = true;
/*reloadCurrentServer() { /*reloadCurrentServer() {
this.currentServer = this.servers.find(s => s.id === this.selectingServerId); this.currentServer = this.servers.find(s => s.id === this.selectingServerId);
}*/ }*/
// tslint:disable-next-line:member-ordering
rooms_loading = true;
lastDeckFormat: RegExp; lastDeckFormat: RegExp;
default_options: Options = { default_options: Options = {
mode: 1, mode: 1,
rule: this.settingsService.getLocale().startsWith('zh') ? 0 : 1, rule: this.settingsService.getLocale().startsWith('zh') ? 0 : 1,
...@@ -172,12 +165,9 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -172,12 +165,9 @@ export class YGOProComponent implements OnInit, OnDestroy {
time_limit: 180, time_limit: 180,
auto_death: false auto_death: false
}; };
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[] = [];
rooms_show: Room[]; rooms_show: Room[];
connections: WebSocket[] = []; connections: WebSocket[] = [];
replay_connections: WebSocket[] = []; replay_connections: WebSocket[] = [];
replay_rooms: Room[] = []; replay_rooms: Room[] = [];
...@@ -190,13 +180,11 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -190,13 +180,11 @@ export class YGOProComponent implements OnInit, OnDestroy {
tag: true, tag: true,
windbot: false windbot: false
}; };
matching: ISubscription | undefined; matching: ISubscription | undefined;
matching_arena: string | undefined; matching_arena: string | undefined;
match_time: string; match_time: string;
match_cancelable: boolean; match_cancelable: boolean;
match_interval: Timer | undefined; match_interval: Timer | undefined;
join_password: string; join_password: string;
host_password = (this.loginService.user.external_id ^ 0x54321).toString(); host_password = (this.loginService.user.external_id ^ 0x54321).toString();
...@@ -242,6 +230,10 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -242,6 +230,10 @@ export class YGOProComponent implements OnInit, OnDestroy {
} }
} }
get windbot() {
return this.currentServer.windbot;
}
refresh_rooms() { refresh_rooms() {
this.rooms_show = this.rooms.filter((room) => room.server === this.currentServer); this.rooms_show = this.rooms.filter((room) => room.server === this.currentServer);
} }
...@@ -416,7 +408,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -416,7 +408,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
let watchDropdownMenu = $('#watch-filter'); let watchDropdownMenu = $('#watch-filter');
watchDropdownMenu.on("change", "input[type='checkbox']", (event) => { watchDropdownMenu.on('change', 'input[type=\'checkbox\']', (event) => {
// $(event.target).closest("label").toggleClass("active", (<HTMLInputElement> event.target).checked); // $(event.target).closest("label").toggleClass("active", (<HTMLInputElement> event.target).checked);
this.refresh_replay_rooms(); this.refresh_replay_rooms();
}); });
...@@ -440,6 +432,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -440,6 +432,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
async refresh(init?: boolean) { async refresh(init?: boolean) {
this.decks = await this.get_decks(); this.decks = await this.get_decks();
this.decks_grouped = this.deckGroup();
if (this.lastDeckFormat) { if (this.lastDeckFormat) {
const systemConfString = await this.load_system_conf(); const systemConfString = await this.load_system_conf();
...@@ -484,37 +477,17 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -484,37 +477,17 @@ export class YGOProComponent implements OnInit, OnDestroy {
async get_decks(): Promise<string[]> { async get_decks(): Promise<string[]> {
try { try {
/* return fg.sync('**/*.ydk', {cwd: this.app.ygoproDeckPath});
const deckPath = this.app.ygoproDeckPath;
let result: string[] = [];
const files: string[] = await fs.readdir(deckPath);
for (const file of files) {
if (file.startsWith('.git')) { // fuck
continue;
}
if (path.extname(file) === '.ydk') {
result.push(path.basename(file, '.ydk'));
} else {
const fullPath = path.join(deckPath, file);
const stat = await fs.stat(fullPath);
if (stat.isDirectory()) {
const innerDecks = (await fs.readdir(fullPath))
.filter((iFile) => path.extname(iFile) === '.ydk')
.map((iFile) => path.join(file, path.basename(iFile, '.ydk')));
result = result.concat(innerDecks);
}
}
}
return result;
*/
let files: string[] = await fs.readdir(this.app.ygoproDeckPath);
return files.filter(file => path.extname(file) === '.ydk').map(file => path.basename(file, '.ydk'));
} catch (error) { } catch (error) {
console.error(`Load deck fail: ${error.toString()}`); console.error(`Load deck fail: ${error.toString()}`);
return []; return [];
} }
} }
deckGroup() {
return Object.entries(_.mapValues(_.groupBy(this.decks, p => path.dirname(p)), g => g.map(p => path.basename(p, '.ydk'))));
}
async get_replays(): Promise<string[]> { async get_replays(): Promise<string[]> {
try { try {
let files: string[] = await fs.readdir(this.app.ygoproReplayPath); let files: string[] = await fs.readdir(this.app.ygoproReplayPath);
...@@ -568,7 +541,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -568,7 +541,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
// console.log(`Loading system conf from ${this.system_conf}`) // console.log(`Loading system conf from ${this.system_conf}`)
let data = await fs.readFile(this.system_conf, {encoding: 'utf-8'}); let data = await fs.readFile(this.system_conf, {encoding: 'utf-8'});
return data; return data;
} catch(e) { } catch (e) {
return null; return null;
} }
}; };
...@@ -598,7 +571,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -598,7 +571,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
system_conf.lastdeck = deck; system_conf.lastdeck = deck;
await this.save_system_conf(system_conf);*/ await this.save_system_conf(system_conf);*/
// return this.start_game(['-d', deck]); // return this.start_game(['-d', deck]);
return this.start_game('deck', { deck }) return this.start_game('deck', {deck})
} }
async watch_replay(replay: string) { async watch_replay(replay: string) {
...@@ -606,7 +579,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -606,7 +579,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
await this.fix_fonts(system_conf); await this.fix_fonts(system_conf);
await this.save_system_conf(system_conf);*/ await this.save_system_conf(system_conf);*/
// return this.start_game(['-r', path.join('replay', replay + '.yrp')]); // return this.start_game(['-r', path.join('replay', replay + '.yrp')]);
return this.start_game('replay', { replay: path.join(this.app.ygoproReplayPath, `${replay}.yrp`) }); return this.start_game('replay', {replay: path.join(this.app.ygoproReplayPath, `${replay}.yrp`)});
} }
join_windbot(name?: string) { join_windbot(name?: string) {
...@@ -899,7 +872,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -899,7 +872,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
avatar_fallback(event) { avatar_fallback(event) {
if (!event.target.getAttribute('fallback')) { if (!event.target.getAttribute('fallback')) {
event.target.src = "images/noavatar.png"; event.target.src = 'images/noavatar.png';
event.target.setAttribute('fallback', true); event.target.setAttribute('fallback', true);
} }
} }
......
This diff is collapsed.
...@@ -36,13 +36,14 @@ ...@@ -36,13 +36,14 @@
"@types/uuid": "^3.0.0", "@types/uuid": "^3.0.0",
"angular-in-memory-web-api": "0.3.2", "angular-in-memory-web-api": "0.3.2",
"aria2": "3.0.0", "aria2": "3.0.0",
"bootstrap": "4.0.0-alpha.6", "bootstrap": "^5.1.0",
"candy": "https://github.com/moecube/candy/releases/download/v2.2.0/candy.tar.gz", "candy": "https://github.com/moecube/candy/releases/download/v2.2.0/candy.tar.gz",
"candy-shop": "candy-chat/candy-plugins", "candy-shop": "candy-chat/candy-plugins",
"core-js": "2.4.1", "core-js": "2.4.1",
"electron-is-dev": "latest", "electron-is-dev": "latest",
"electron-sudo": "moecube/electron-sudo#998b7f19b123a6f2f469f79a2027ebb7b0223f9d", "electron-sudo": "moecube/electron-sudo#998b7f19b123a6f2f469f79a2027ebb7b0223f9d",
"electron-updater": "4.3.8", "electron-updater": "4.3.8",
"fast-glob": "^3.2.7",
"font-awesome": "4.7.0", "font-awesome": "4.7.0",
"fs-extra": "3.0.1", "fs-extra": "3.0.1",
"glob": "7.1.2", "glob": "7.1.2",
...@@ -64,7 +65,6 @@ ...@@ -64,7 +65,6 @@
"strophejs-plugin-roster": "^1.1.0", "strophejs-plugin-roster": "^1.1.0",
"systemjs": "0.20.15", "systemjs": "0.20.15",
"systemjs-plugin-text": "0.0.11", "systemjs-plugin-text": "0.0.11",
"tether": "latest",
"typeahead.js": "0.11.1", "typeahead.js": "0.11.1",
"uuid": "3.1.0", "uuid": "3.1.0",
"vue": "2.3.4", "vue": "2.3.4",
...@@ -81,7 +81,6 @@ ...@@ -81,7 +81,6 @@
"@types/marked": "latest", "@types/marked": "latest",
"@types/mustache": "^4.1.2", "@types/mustache": "^4.1.2",
"@types/node": "^14.0.1", "@types/node": "^14.0.1",
"@types/tether": "latest",
"@types/typeahead": "latest", "@types/typeahead": "latest",
"electron": "^4.2.12", "electron": "^4.2.12",
"electron-builder": "latest", "electron-builder": "latest",
......
...@@ -75,13 +75,11 @@ System.config({ ...@@ -75,13 +75,11 @@ System.config({
"aria2": "@node/aria2", "aria2": "@node/aria2",
"electron-sudo": "@node/electron-sudo", "electron-sudo": "@node/electron-sudo",
'fs-extra': '@node/fs-extra', 'fs-extra': '@node/fs-extra',
'fast-glob': '@node/fast-glob',
'jquery': 'npm:jquery/dist/jquery.min.js', 'jquery': 'npm:jquery/dist/jquery.min.js',
'tether': 'npm:tether/dist/js/tether.min.js', 'bootstrap': 'npm:bootstrap/dist/js/bootstrap.bundle.min.js',
'bootstrap': 'npm:bootstrap/dist/js/bootstrap.min.js',
'reconnecting-websocket': 'npm:reconnecting-websocket/dist/index.js', 'reconnecting-websocket': 'npm:reconnecting-websocket/dist/index.js',
'popper.js': 'npm:popper.js/dist/umd/popper.min.js',
// 'typeahead.js': '@node/typeahead.js'
'raven-js': 'npm:raven-js', 'raven-js': 'npm:raven-js',
'strophe.js': 'npm:strophe.js/dist/strophe.umd.js', 'strophe.js': 'npm:strophe.js/dist/strophe.umd.js',
...@@ -105,12 +103,12 @@ System.config({ ...@@ -105,12 +103,12 @@ System.config({
main: 'dist/raven.js' main: 'dist/raven.js'
} }
}, },
meta: { // meta: {
bootstrap: { // bootstrap: {
globals: { // globals: {
jQuery: 'jquery', // jQuery: 'jquery',
Tether: 'tether' // Tether: 'tether'
} // }
} // }
} // }
}); });
...@@ -13,10 +13,11 @@ ...@@ -13,10 +13,11 @@
], ],
"suppressImplicitAnyIndexErrors": true, "suppressImplicitAnyIndexErrors": true,
"strict": false, "strict": false,
"skipLibCheck": true "skipLibCheck": true,
"skipDefaultLibCheck": true
}, },
"exclude": [ "exclude": [
"node_modules/*", "node_modules",
"**/*-aot.ts" "**/*-aot.ts"
] ]
} }
\ No newline at end of file
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