From a00f899ea9248411f53145d17c1c11962605aba2 Mon Sep 17 00:00:00 2001 From: liuxianghui <519646741@qq.com> Date: Sat, 27 Nov 2021 14:08:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9F=B3=E9=A2=91=E6=92=AD=E6=94=BE=E4=B8=8E?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E7=AD=89=E5=BE=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../events/event-loading-change.ts | 29 +++++++++++++++++++ src/app/babylon/tool/load-tool.ts | 3 ++ src/app/babylon/tool/speaking-tool.ts | 27 ++++++++++++++++- .../babylon/view/mark-window/mark-window.ts | 1 + 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/app/babylon/controller/event-manager/events/event-loading-change.ts diff --git a/src/app/babylon/controller/event-manager/events/event-loading-change.ts b/src/app/babylon/controller/event-manager/events/event-loading-change.ts new file mode 100644 index 0000000..bc18520 --- /dev/null +++ b/src/app/babylon/controller/event-manager/events/event-loading-change.ts @@ -0,0 +1,29 @@ +import { Event_Base } from "../event-base"; +import { EventManager } from "../event-manager"; + +/** + * 加载状态 发生变化 (loading遮罩) + */ +export class Event_LoadingChange extends Event_Base { + + /** + * loading中 + */ + static isLoading: boolean = false; + + /** + * 显示loading条 + */ + showLoading: boolean; + + /** + * 派发事件 + * @param showLoading 显示loading条 + */ + static dispatch(showLoading: boolean) { + let eventData = new Event_LoadingChange(); + eventData.showLoading = showLoading; + EventManager.dispatch(Event_LoadingChange, eventData); + Event_LoadingChange.isLoading = showLoading; + } +} \ No newline at end of file diff --git a/src/app/babylon/tool/load-tool.ts b/src/app/babylon/tool/load-tool.ts index a92efea..12f267b 100644 --- a/src/app/babylon/tool/load-tool.ts +++ b/src/app/babylon/tool/load-tool.ts @@ -1,4 +1,5 @@ import { PlanComponent } from "src/app/pages/plan/plan.component"; +import { Event_LoadingChange } from "../controller/event-manager/events/event-loading-change"; /** * 加载管理器 @@ -52,6 +53,7 @@ export class LoadTool { static onStart() { // console.log("开始加载"); PlanComponent.instance.showLoading(true); + Event_LoadingChange.dispatch(true); } /** @@ -60,6 +62,7 @@ export class LoadTool { static onEnd() { // console.log("结束加载"); PlanComponent.instance.showLoading(false); + Event_LoadingChange.dispatch(false); } } \ No newline at end of file diff --git a/src/app/babylon/tool/speaking-tool.ts b/src/app/babylon/tool/speaking-tool.ts index 2516888..9784ed9 100644 --- a/src/app/babylon/tool/speaking-tool.ts +++ b/src/app/babylon/tool/speaking-tool.ts @@ -1,3 +1,5 @@ +import { EventManager } from "../controller/event-manager/event-manager"; +import { Event_LoadingChange } from "../controller/event-manager/events/event-loading-change"; /** * 语音工具 @@ -10,9 +12,25 @@ export class SpeakingTool { if (SpeakingTool.instance == null) { SpeakingTool.instance = new SpeakingTool(); } + EventManager.addListener(Event_LoadingChange, (eventInfo) => { + SpeakingTool.instance.onChangeLoading(eventInfo); + }); return SpeakingTool.instance; } + /** + * loading状态改变时 + * @param eventInfo + */ + onChangeLoading(eventInfo: Event_LoadingChange) { + if (eventInfo.showLoading) { + this.pause(); + } + else { + this.resume(); + } + } + /** * 阅读一段文字 @@ -34,6 +52,10 @@ export class SpeakingTool { speakMsg.pitch = 1.5; window.speechSynthesis.speak(speakMsg); + if (Event_LoadingChange.isLoading) { + this.pause(); + } + return speakMsg; } } @@ -73,4 +95,7 @@ export class SpeakingTool { return false; } -} \ No newline at end of file +} + + + diff --git a/src/app/babylon/view/mark-window/mark-window.ts b/src/app/babylon/view/mark-window/mark-window.ts index 43e3d4f..03bca52 100644 --- a/src/app/babylon/view/mark-window/mark-window.ts +++ b/src/app/babylon/view/mark-window/mark-window.ts @@ -7,6 +7,7 @@ import { DataManager } from "../../controller/data-manager"; import { EventManager } from "../../controller/event-manager/event-manager"; import { Event_GetAllMarkPlanData } from "../../controller/event-manager/events/event-get-markplandata-success"; import { Event_KeyboardInput } from "../../controller/event-manager/events/event-keyboard-input"; +import { Event_LoadingChange } from "../../controller/event-manager/events/event-loading-change"; import { Event_MarkInfoChange, MarkInfoChangeType } from "../../controller/event-manager/events/event-mark-info-change"; import { InputController } from "../../controller/inputController"; import { SceneManager } from "../../controller/scene-manager";