Skip to content

Commit

Permalink
feat(env): 添加环境配置字段并修改故事生成逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
Encaik committed Sep 30, 2024
1 parent 7442ef5 commit dfd2372
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/app/shared/services/generate.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { HttpClient } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
import { map, Observable } from 'rxjs';
import { map, Observable, of } from 'rxjs';
import { Res, ResStatus } from '../models/http.model';
import { BattleCharacter, Env, InitCharacter } from '@models';
import { environment } from 'environments/environment';

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -62,6 +63,7 @@ export class GenerateService {
}

getStory(character: InitCharacter, env: Env): Observable<string> {
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 : '';
Expand Down
3 changes: 2 additions & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const environment = {
production: true,
apiUrl: 'https://wanjie-api.vercel.app'
apiUrl: 'https://wanjie-api.vercel.app',
aiEnable: true
};
3 changes: 2 additions & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const environment = {
production: false,
apiUrl: ''
apiUrl: '',
aiEnable: false
};

0 comments on commit dfd2372

Please sign in to comment.