Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Encaik/wanjie
Browse files Browse the repository at this point in the history
  • Loading branch information
Encaik committed Sep 30, 2024
2 parents dfd2372 + a1f6abd commit 00929af
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 46 deletions.
31 changes: 18 additions & 13 deletions src/app/components/init-modal/init-modal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
</nz-steps>

<div class="my-4 relative">
<nz-spin [nzSpinning]="!characters.length || !envs.length">
@if (current === 0) {
<div class="h-full grid grid-cols-2 md:grid-cols-4 gap-4 overflow-auto border rounded p-4 bg-slate-100">
@if (current === 0) {
<nz-spin [nzSpinning]="!characters.length">
<div class="h-full min-h-96 grid grid-cols-2 md:grid-cols-4 gap-4 overflow-auto border rounded p-4 bg-slate-100">
@for (item of characters; track $index) {
<div
[ngClass]="[item.baseInfo.gender === '男' ? ' border-blue-300 bg-blue-100' : ' border-red-300 bg-red-100']"
Expand All @@ -32,9 +32,11 @@
</div>
}
</div>
}
@if (current === 1) {
<div class="h-full grid grid-cols-1 sm:grid-cols-2 gap-4 overflow-auto border rounded p-4 bg-slate-100">
</nz-spin>
}
@if (current === 1) {
<nz-spin [nzSpinning]="!envs.length">
<div class="h-full min-h-96 grid grid-cols-1 sm:grid-cols-2 gap-4 overflow-auto border rounded p-4 bg-slate-100">
@for (item of envs; track $index) {
<div
class="flex flex-col justify-center items-center text-center p-4 rounded cursor-pointer hover:shadow-lg w-full bg-white"
Expand All @@ -57,11 +59,14 @@
</div>
}
</div>
}
</nz-spin>
<nz-spin [nzSpinning]="!story">
@if (current === 2) {
<p>{{ story }}</p>
}
</nz-spin>
</nz-spin>
}
@if (current === 2) {
<nz-spin [nzSpinning]="!story">
<div class="flex flex-col gap-2 justify-center align-middle border rounded p-4 bg-slate-100">
<p class="min-h-96 whitespace-pre-wrap text-lg">{{ story }}</p>
<button class="mt-2" nz-button nzSize="large" nzType="primary" (click)="onSubmitClick()">开始旅程</button>
</div>
</nz-spin>
}
</div>
22 changes: 16 additions & 6 deletions src/app/components/init-modal/init-modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,29 @@ import { CommonModule, KeyValuePipe } from '@angular/common';
import { Component, inject, OnInit } from '@angular/core';
import { Env, InitCharacter } from '@models';
import { EnvService } from '@services';
import { GenerateService } from '@shared';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzDescriptionsModule } from 'ng-zorro-antd/descriptions';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { NzSpinModule } from 'ng-zorro-antd/spin';
import { NzStepsModule } from 'ng-zorro-antd/steps';
import { NzTagModule } from 'ng-zorro-antd/tag';

import { LevelMapViewComponent } from '../level-map-view/level-map-view.component';
import { GenerateService } from '@shared';
import { NzSpinModule } from 'ng-zorro-antd/spin';

@Component({
selector: 'app-init-modal',
standalone: true,
imports: [CommonModule, NzDescriptionsModule, NzStepsModule, NzTagModule, KeyValuePipe, LevelMapViewComponent, NzSpinModule],
imports: [
CommonModule,
NzButtonModule,
NzDescriptionsModule,
NzStepsModule,
NzTagModule,
KeyValuePipe,
LevelMapViewComponent,
NzSpinModule
],
templateUrl: './init-modal.component.html'
})
export class InitModalComponent implements OnInit {
Expand Down Expand Up @@ -59,10 +69,10 @@ export class InitModalComponent implements OnInit {
}

onEnvClick(item: Env) {
// this.current = 2;
this.current = 2;
this.selectEnv = item;
// this.getStory(this.selectCharacter!, this.selectEnv!);
this.onSubmitClick();
this.getStory(this.selectCharacter!, this.selectEnv!);
// this.onSubmitClick();
}

onSubmitClick() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/interceptors/api-interceptor.interceptor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TestBed } from '@angular/core/testing';
import { HttpInterceptorFn } from '@angular/common/http';
import { TestBed } from '@angular/core/testing';

import { apiInterceptor } from './api-interceptor.interceptor';

Expand Down
10 changes: 5 additions & 5 deletions src/app/pages/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Component, inject, OnInit } from '@angular/core';
import { LogType, LogLevel, BattleCharacter, CharacterEventOperate, EventType, EventRes } from '@models';
import { CharacterService, LogService, RuntimeService, BattleService, EnvService, BackpackService, EventService } from '@services';
import { GenerateService } from '@shared';
import { Generate } from '@utils/generate';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzDividerModule } from 'ng-zorro-antd/divider';
import { NzModalModule } from 'ng-zorro-antd/modal';
import { NzTypographyModule } from 'ng-zorro-antd/typography';

import { BackpackComponent } from './components/backpack/backpack.component';
import { GenerateService } from '@shared';

@Component({
selector: 'app-home',
Expand Down Expand Up @@ -39,10 +39,10 @@ export class HomeComponent implements OnInit {
this.isUpgrade = this.characterSrv.canUpgrade;
}

getEnemyList(){
this.generateSrv.getEnemyList(8,this.characterSrv.levelInfo.level).subscribe(res=>{
this.enemys = res
})
getEnemyList() {
this.generateSrv.getEnemyList(8, this.characterSrv.levelInfo.level).subscribe(res => {
this.enemys = res;
});
}

onCultivationClick() {
Expand Down
8 changes: 4 additions & 4 deletions src/app/shared/models/http.model.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export enum ResStatus {
Success = 200,
AuthError = 400,
ServerError = 500,
ServerError = 500
}

export interface Res<T=any>{
export interface Res<T = any> {
status: ResStatus;
msg:string;
data:T
msg: string;
data: T;
}
32 changes: 16 additions & 16 deletions src/app/shared/services/generate.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { TestBed } from '@angular/core/testing';

import { GenerateService } from './generate.service';

describe('GenerateService', () => {
let service: GenerateService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(GenerateService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
});
import { TestBed } from '@angular/core/testing';

import { GenerateService } from './generate.service';

describe('GenerateService', () => {
let service: GenerateService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(GenerateService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
});
2 changes: 1 addition & 1 deletion src/app/shared/services/generate.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class GenerateService {
if (!environment.aiEnable) return of('开发环境,跳过故事生成');
return this.http.post<Res<string>>('/api/generate/story', { character, env }).pipe(
map(res => {
return res.status === ResStatus.Success ? res.data : '';
return res.status === ResStatus.Success ? res.data : '故事生成失败';
})
);
}
Expand Down

1 comment on commit 00929af

@vercel
Copy link

@vercel vercel bot commented on 00929af Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

wanjie – ./

wanjie-git-main-encaiks-projects.vercel.app
wanjie.vercel.app
wanjie-encaiks-projects.vercel.app

Please sign in to comment.