Commit 1277a247 authored by 神楽坂玲奈's avatar 神楽坂玲奈

maybe works

parent 3c91aebc
...@@ -27,15 +27,24 @@ ...@@ -27,15 +27,24 @@
<div class="col-sm-8 input-group input-group-sm"> <div class="col-sm-8 input-group input-group-sm">
<label i18n class="input-group-text" id="basic-addon1">卡组</label> <label i18n class="input-group-text" id="basic-addon1">卡组</label>
<select class="form-select form-select-sm" id="exampleSelect1" name="deck" [(ngModel)]="current_deck"> <select class="form-select form-select-sm" id="exampleSelect1" name="deck" [(ngModel)]="current_deck">
<option *ngFor="let deck of group[1]" [value]="group[0] + '/' + deck">{{deck}}</option> <option *ngFor="let deck of decks_grouped['.']" [value]="deck">{{deck}}</option>
<ng-container *ngFor="let group of deckGroup()"> <ng-container *ngFor="let group of decks_grouped | keyvalue">
<ng-container *ngIf="group[0] == '.'; else #x"> <optgroup *ngIf="group.key !== '.'" [label]='group.key'>
<option *ngFor="let deck of group.value" [value]="group.key + '/' + deck">{{deck}}</option>
</ng-container> </optgroup>
<ng-template #elseBlock>Content to render when condition is false.</ng-template>
<optgroup [label]="group[0]"></optgroup>
<option *ngFor="let deck of group[1]" [value]="group[0] + '/' + deck">{{deck}}</option>
</ng-container> </ng-container>
<!-- <option *ngFor="let deck of group[1]" [value]="group[0] + '/' + deck">{{deck}}</option>-->
<!-- -->
<!-- <ng-container *ngFor="let group of deck_grouped | keyvalue">-->
<!-- <ng-container *ngIf="group[0] == '.'; else #x">-->
<!-- </ng-container>-->
<!-- <ng-template #elseBlock>Content to render when condition is false.</ng-template>-->
<!-- <optgroup [label]="group[0]"></optgroup>-->
<!-- <option *ngFor="let deck of group[1]" [value]="group[0] + '/' + deck">{{deck}}</option>-->
<!-- </ng-container>-->
</select> </select>
<span class="input-group-btn"> <span class="input-group-btn">
<button id="edit_deck_button" i18n [disabled]="!appsService.allReady(app)" class="btn btn-secondary btn-sm" (click)="edit_deck(current_deck)">编辑</button> <button id="edit_deck_button" i18n [disabled]="!appsService.allReady(app)" class="btn btn-secondary btn-sm" (click)="edit_deck(current_deck)">编辑</button>
......
...@@ -137,7 +137,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -137,7 +137,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
@Output() @Output()
points: EventEmitter<any> = new EventEmitter(); points: EventEmitter<any> = new EventEmitter();
decks: string[] = []; decks: string[] = [];
decks_grouped: Record<string, string[]>; decks_grouped: Record<string, string[]> = {};
replays: string[] = []; replays: string[] = [];
current_deck: string; current_deck: string;
system_conf?: string; system_conf?: string;
...@@ -492,6 +492,8 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -492,6 +492,8 @@ export class YGOProComponent implements OnInit, OnDestroy {
} else if (init) { } else if (init) {
this.current_deck = this.decks[0]; this.current_deck = this.decks[0];
} }
console.log(this.current_deck)
} }
this.replays = await this.get_replays(); this.replays = await this.get_replays();
...@@ -513,7 +515,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -513,7 +515,7 @@ 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 }); return (await fg('**/*.ydk', { cwd: this.app.ygoproDeckPath })).map(d => d.slice(0, -4));
} catch (error) { } catch (error) {
console.error(`Load deck fail: ${error.toString()}`); console.error(`Load deck fail: ${error.toString()}`);
return []; return [];
......
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