From d99a566bfec363082fc2b253446ab442bfefc442 Mon Sep 17 00:00:00 2001 From: luoxi Date: Fri, 30 May 2025 11:41:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=96=99=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luoxi --- .../entry/src/main/ets/pages/common/Index.ets | 13 ++++++++++++- .../pages/navPathStackExtend/template1/PageOne.ets | 5 +++-- .../main/ets/pages/navigation/template3/Index.ets | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/common/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/common/Index.ets index 02c5c6b987..31b7114eab 100644 --- a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/common/Index.ets +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/common/Index.ets @@ -20,4 +20,15 @@ export interface Route { export interface RouteGroup extends Route { children: Route[]; -} \ No newline at end of file +} + +export class P2PManager { + public resourceToString(resource: Resource): string { + return getContext(this).resourceManager.getStringSync(resource); + } +} + +// 默认导出let +let p2pManager = new P2PManager(); + +export default p2pManager as P2PManager; \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navPathStackExtend/template1/PageOne.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navPathStackExtend/template1/PageOne.ets index 425a821bbe..15fcd5b2be 100644 --- a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navPathStackExtend/template1/PageOne.ets +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navPathStackExtend/template1/PageOne.ets @@ -13,6 +13,7 @@ * limitations under the License. */ import { uiObserver } from '@kit.ArkUI'; +import resource from '../../common/Index'; @Builder export function PageOneBuilder() { @@ -35,7 +36,7 @@ export struct PageOneComponent { this.navDesInfo = this.queryNavDestinationInfo(true); this.text = JSON.stringify(this.navDesInfo?.name); }) - Text($r('app.string.navStackTemp1PageOne_text2') + this.text) + Text(resource.resourceToString($r('app.string.navStackTemp1PageOne_text2')) + this.text) .width('80%') .height(50) .margin(50) @@ -63,7 +64,7 @@ struct MyComponent { this.navDesInfo = this.queryNavDestinationInfo(false); this.text = JSON.stringify(this.navDesInfo?.name); }) - Text($r('app.string.navStackTemp1PageOne_text4') + this.text) + Text(resource.resourceToString($r('app.string.navStackTemp1PageOne_text4')) + this.text) .width('80%') .height(50) .margin(50) diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/Index.ets index 55602c33da..e2dc00b88c 100644 --- a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/Index.ets +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/Index.ets @@ -23,7 +23,7 @@ export struct NavigationExample3 { if (this.pageInfos === undefined) { this.pageInfos = new NavPathStack(); } - this.pageInfos.pushPath({ name: 'temp3-pageTwo', param: CustomTransition.getInstance().getAnimationId() }); + this.pageInfos.pushPath({ name: 'temp3-pageOne', param: CustomTransition.getInstance().getAnimationId() }); } build() { -- Gitee