diff --git a/src/app/shared/services/generate.service.ts b/src/app/shared/services/generate.service.ts index a1c1a04..ead0952 100644 --- a/src/app/shared/services/generate.service.ts +++ b/src/app/shared/services/generate.service.ts @@ -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' @@ -62,6 +63,7 @@ export class GenerateService { } getStory(character: InitCharacter, env: Env): Observable { + if (!environment.aiEnable) return of('开发环境,跳过故事生成'); return this.http.post>('/api/generate/story', { character, env }).pipe( map(res => { return res.status === ResStatus.Success ? res.data : ''; diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 3c00a0f..39e2616 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,4 +1,5 @@ export const environment = { production: true, - apiUrl: 'https://wanjie-api.vercel.app' + apiUrl: 'https://wanjie-api.vercel.app', + aiEnable: true }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index c46aeaa..6752fc8 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,4 +1,5 @@ export const environment = { production: false, - apiUrl: '' + apiUrl: '', + aiEnable: false };