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

切换账号警告

parent d5ed1549
{ {
"name": "mycard-mobile", "name": "mycard-mobile",
"version": "1.0.31", "version": "1.0.32",
"license": "UNLISENCED", "license": "UNLISENCED",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
......
...@@ -40,6 +40,7 @@ import { HttpClientModule } from '@angular/common/http'; ...@@ -40,6 +40,7 @@ import { HttpClientModule } from '@angular/common/http';
import * as Raven from 'raven-js'; import * as Raven from 'raven-js';
import { DecksComponent } from './decks/decks.component'; import { DecksComponent } from './decks/decks.component';
import { ConfirmDialogComponent } from './confirm-dialog/confirm-dialog.component'; import { ConfirmDialogComponent } from './confirm-dialog/confirm-dialog.component';
import { LogoutDialogComponent } from './logout-dialog/logout-dialog.component';
export class RavenErrorHandler implements ErrorHandler { export class RavenErrorHandler implements ErrorHandler {
handleError(err: any): void { handleError(err: any): void {
...@@ -67,7 +68,8 @@ if (environment.production) { ...@@ -67,7 +68,8 @@ if (environment.production) {
ToolbarComponent, ToolbarComponent,
ResultDialogComponent, ResultDialogComponent,
DecksComponent, DecksComponent,
ConfirmDialogComponent ConfirmDialogComponent,
LogoutDialogComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
...@@ -96,6 +98,6 @@ if (environment.production) { ...@@ -96,6 +98,6 @@ if (environment.production) {
], ],
providers: [YGOProService, StorageService, ...sentry], providers: [YGOProService, StorageService, ...sentry],
bootstrap: [AppComponent], bootstrap: [AppComponent],
entryComponents: [MatchDialogComponent, ResultDialogComponent, ConfirmDialogComponent] entryComponents: [MatchDialogComponent, ResultDialogComponent, ConfirmDialogComponent, LogoutDialogComponent]
}) })
export class AppModule {} export class AppModule {}
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<mat-icon>add</mat-icon> <mat-icon>add</mat-icon>
</button> </button>
<mat-menu #menu="matMenu"> <mat-menu #menu="matMenu">
<a [href]="login.logout()" mat-menu-item>切换用户</a> <a (click)="logout()" mat-menu-item>切换用户</a>
<button mat-menu-item>大厅版本 {{version}}</button> <button mat-menu-item>大厅版本 {{version}}</button>
<button mat-menu-item *ngIf="build">应用版本 {{build.version_name}}</button> <button mat-menu-item *ngIf="build">应用版本 {{build.version_name}}</button>
</mat-menu> </mat-menu>
......
...@@ -8,6 +8,8 @@ import { YGOProService } from '../ygopro.service'; ...@@ -8,6 +8,8 @@ import { YGOProService } from '../ygopro.service';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { distinctUntilChanged, filter, map, switchMap } from 'rxjs/internal/operators'; import { distinctUntilChanged, filter, map, switchMap } from 'rxjs/internal/operators';
import { MatDialog } from '@angular/material';
import { LogoutDialogComponent } from '../logout-dialog/logout-dialog.component';
@Component({ @Component({
selector: 'app-lobby', selector: 'app-lobby',
...@@ -34,7 +36,13 @@ export class LobbyComponent { ...@@ -34,7 +36,13 @@ export class LobbyComponent {
arena_url: string; arena_url: string;
constructor(public login: LoginService, public ygopro: YGOProService, private http: HttpClient, public storage: StorageService) { constructor(
public login: LoginService,
public ygopro: YGOProService,
private http: HttpClient,
public storage: StorageService,
private dialog: MatDialog
) {
const arena_url = new URL('https://mycard.moe/ygopro/arena'); const arena_url = new URL('https://mycard.moe/ygopro/arena');
arena_url.searchParams.set('sso', login.token); arena_url.searchParams.set('sso', login.token);
this.arena_url = arena_url.toString(); this.arena_url = arena_url.toString();
...@@ -54,6 +62,17 @@ export class LobbyComponent { ...@@ -54,6 +62,17 @@ export class LobbyComponent {
url.searchParams.set('key', key); url.searchParams.set('key', key);
open(url.toString()); open(url.toString());
} }
async logout() {
if (
await this.dialog
.open(LogoutDialogComponent)
.afterClosed()
.toPromise()
) {
location.href = this.login.logout();
}
}
} }
interface BuildConfig { interface BuildConfig {
......
<h2 mat-dialog-title>切换账号</h2>
<mat-dialog-content>
您当前的卡组绑定着当前的帐号。切换帐号后,卡组列表将只会有您新帐号所绑定的卡组。
</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-button mat-dialog-close>取消</button>
<button mat-button [mat-dialog-close]="true">切换账号</button>
</mat-dialog-actions>
import { Component } from '@angular/core';
@Component({
selector: 'app-logout-dialog',
templateUrl: './logout-dialog.component.html',
styleUrls: ['./logout-dialog.component.css']
})
export class LogoutDialogComponent {}
...@@ -8,9 +8,6 @@ mat-dialog-content { ...@@ -8,9 +8,6 @@ mat-dialog-content {
display: flex; display: flex;
overflow: hidden; overflow: hidden;
} }
mat-dialog-actions {
justify-content: flex-end
}
ul { ul {
margin: 0; margin: 0;
} }
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
<dd>{{actual_wait | async | date: 'mm:ss'}}</dd> <dd>{{actual_wait | async | date: 'mm:ss'}}</dd>
</ul> </ul>
</mat-dialog-content> </mat-dialog-content>
<mat-dialog-actions> <mat-dialog-actions align="end">
<button mat-button mat-dialog-close>取消</button> <button mat-button mat-dialog-close>取消</button>
</mat-dialog-actions> </mat-dialog-actions>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</mat-list-item> </mat-list-item>
</mat-list> </mat-list>
</mat-dialog-content> </mat-dialog-content>
<mat-dialog-actions> <mat-dialog-actions align="end">
<button mat-button mat-dialog-close>关闭</button> <button mat-button mat-dialog-close>关闭</button>
<button mat-button [mat-dialog-close]="true">再来一局</button> <button mat-button [mat-dialog-close]="true">再来一局</button>
</mat-dialog-actions> </mat-dialog-actions>
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