|
|
@@ -1,14 +1,25 @@
|
|
|
import { ArticleClass } from '../model/ArticleClass';
|
|
|
import { webview } from '@kit.ArkWeb';
|
|
|
+import { Speaker } from 'utils';
|
|
|
+import { emitter } from '@kit.BasicServicesKit';
|
|
|
|
|
|
@Preview
|
|
|
@Component
|
|
|
export struct ArticleDetailPage {
|
|
|
@State articleDetail: ArticleClass | null = null;
|
|
|
@Consume('articlePathStack') articlePathStack: NavPathStack;
|
|
|
+ @State isClicked: boolean = false;
|
|
|
+ speaker: Speaker = new Speaker();
|
|
|
|
|
|
aboutToAppear(): void {
|
|
|
this.articleDetail = this.articlePathStack.getParamByName('articleDetail')[0] as ArticleClass;
|
|
|
+ emitter.on("eventId", () => {
|
|
|
+ this.isClicked = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ aboutToDisappear(): void {
|
|
|
+ this.speaker?.shutdownEngine();
|
|
|
}
|
|
|
|
|
|
build() {
|
|
|
@@ -35,6 +46,18 @@ export struct ArticleDetailPage {
|
|
|
}
|
|
|
}
|
|
|
.width('80%')
|
|
|
+
|
|
|
+ Image(this.isClicked ? $r('app.media.ic_AI_read_on'))
|
|
|
+ .width(40)
|
|
|
+ .height(40)
|
|
|
+ .onClick(() => {
|
|
|
+ this.isClicked = !this.isClicked;
|
|
|
+ if (this.isClicked === true) {
|
|
|
+ this.speaker.startSpeak(this.articleDetail!.brief);
|
|
|
+ } else {
|
|
|
+ this.speaker.stopSpeak();
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
.justifyContent(FlexAlign.SpaceBetween)
|
|
|
.width('100%')
|