From 553c8e4520bfa66b1c16f1fc0fe17bd74e8e62d7 Mon Sep 17 00:00:00 2001 From: zywyl Date: Thu, 17 Oct 2024 10:30:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=90=8E=E8=A7=92=E6=A0=87=E4=B8=8D=E5=8F=98?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/SceneConfirm.ets | 19 +++++++++++++------ entry/src/main/ets/pages/SceneHome.ets | 16 ++++++++-------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/entry/src/main/ets/pages/SceneConfirm.ets b/entry/src/main/ets/pages/SceneConfirm.ets index 640d640..76cfaba 100644 --- a/entry/src/main/ets/pages/SceneConfirm.ets +++ b/entry/src/main/ets/pages/SceneConfirm.ets @@ -26,16 +26,15 @@ export struct SceneConfirm { @StorageLink('configSource') configSource: Array | undefined = AppStorage.get('configSource')!; private title: string | Resource = ''; private content: string | Resource = ''; - private data: Array = AppStorage.get('configSource')!; - aboutToAppear(): void { + initConfigSource() { const sceneIndex: number = AppStore.getInstance().currentSceneIndex; const stepIndex: number = AppStore.getInstance().currentStepIndex; - this.title = this.data[sceneIndex].steps[stepIndex].dialogTitle; - this.content = this.data[sceneIndex].steps[stepIndex].dialogContent; - if (this.data[sceneIndex].steps[stepIndex].service) { - const serviceName: string = this.data[sceneIndex].steps[stepIndex].service; + this.title = this.configSource![sceneIndex].steps[stepIndex].dialogTitle; + this.content = this.configSource![sceneIndex].steps[stepIndex].dialogContent; + if (this.configSource![sceneIndex].steps[stepIndex].service) { + const serviceName: string = this.configSource![sceneIndex].steps[stepIndex].service; if (!serviceName) { return; } @@ -47,6 +46,14 @@ export struct SceneConfirm { } } + aboutToAppear(): void { + this.initConfigSource(); + } + + configSourceChange() { + this.initConfigSource(); + } + build() { Stack() { Column() diff --git a/entry/src/main/ets/pages/SceneHome.ets b/entry/src/main/ets/pages/SceneHome.ets index c7b9f11..7800f21 100644 --- a/entry/src/main/ets/pages/SceneHome.ets +++ b/entry/src/main/ets/pages/SceneHome.ets @@ -47,8 +47,8 @@ export struct SceneHome { @State bestExperience: string[] = []; @State stepTips: string[] = []; @State description: string = ''; + @State private sceneIndex: number = AppStore.getInstance().currentSceneIndex; scroller: Scroller = new Scroller(); - private sceneIndex: number = AppStore.getInstance().currentSceneIndex; initConfigSource() { this.checkPoint = this.configSource![this.sceneIndex].checkPoint; @@ -90,14 +90,14 @@ export struct SceneHome { .layoutWeight(1); Column() { - Text((AppStore.getInstance().currentSceneIndex + 1) + '/13') + Text((this.sceneIndex + 1) + '/13') .margin({ top: 10, bottom: 22 }); Row() { - if (AppStore.getInstance().currentSceneIndex > 0) { + if (this.sceneIndex > 0) { Button($r('app.string.common_previous'), { type: ButtonType.Capsule, stateEffect: false }) .width('48%') .height(40) @@ -105,16 +105,16 @@ export struct SceneHome { .backgroundColor('rgba(0, 0, 0, 0.05)') .onClick(() => { AppStore.getInstance().currentSceneIndex--; + this.sceneIndex--; - const sceneIndex = AppStore.getInstance().currentSceneIndex; - const lastStepLength = AppStore.getInstance().optionRecord[sceneIndex].jumpIndex; + const lastStepLength = AppStore.getInstance().optionRecord[this.sceneIndex].jumpIndex; const stepIndex = AppStore.getInstance().currentStepIndex; let stackLength = (lastStepLength + 1 + stepIndex) * 2; - if (AppStore.getInstance().optionRecord[sceneIndex].isSkiped) { + if (AppStore.getInstance().optionRecord[this.sceneIndex].isSkiped) { stackLength = stackLength - 1; } - AppStore.getInstance().isMultiStep = this.configSource![sceneIndex].steps.length > 1; + AppStore.getInstance().isMultiStep = this.configSource![this.sceneIndex].steps.length > 1; AppStore.getInstance().currentStepIndex = 0; for (let i = 0; i < stackLength; i++) { HMRouterMgr.pop(); @@ -122,7 +122,7 @@ export struct SceneHome { }); } Button($r('app.string.common_skip'), { type: ButtonType.Capsule, stateEffect: false }) - .width(AppStore.getInstance().currentSceneIndex > 0 ? '48%' : '100%') + .width(this.sceneIndex > 0 ? '48%' : '100%') .height(40) .fontColor($r('app.color.primary_button')) .backgroundColor('rgba(0, 0, 0, 0.05)') -- Gitee From 01c6ef8de336b84ca9a3553710634a861753823e Mon Sep 17 00:00:00 2001 From: zywyl Date: Thu, 17 Oct 2024 10:39:23 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/SceneConfirm.ets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entry/src/main/ets/pages/SceneConfirm.ets b/entry/src/main/ets/pages/SceneConfirm.ets index 76cfaba..f626a1c 100644 --- a/entry/src/main/ets/pages/SceneConfirm.ets +++ b/entry/src/main/ets/pages/SceneConfirm.ets @@ -23,7 +23,7 @@ import { DataConfig } from '../common/store/DataInterface'; @HMRouter({ pageUrl: 'SceneConfirm', dialog: true }) @Component export struct SceneConfirm { - @StorageLink('configSource') configSource: Array | undefined = AppStorage.get('configSource')!; + @StorageLink('configSource') @Watch('configSourceChange') configSource: Array | undefined = AppStorage.get('configSource')!; private title: string | Resource = ''; private content: string | Resource = ''; -- Gitee