diff --git a/entry/src/main/ets/component/product/ProductContent.ets b/entry/src/main/ets/component/product/ProductContent.ets index b7a7ff02ac7e217013d5720758eea53b16d8f2ee..bcdc5606d6873e7cb4075a3d4f6d3da7a03a4143 100644 --- a/entry/src/main/ets/component/product/ProductContent.ets +++ b/entry/src/main/ets/component/product/ProductContent.ets @@ -24,12 +24,12 @@ import { ProductInfo, ProductPicture } from './elements/ProductDetail'; import { ProductMsg, ProductUtilView } from './elements/ProductUtilView'; interface ParamsType {} -// [Start HMRouter] +// [Start hm_router] @HMRouter({pageUrl: 'ProductContent'}) // [Start page_url] @Component export struct ProductContent { - // [StartExclude HMRouter] + // [StartExclude hm_router] // [StartExclude page_url] // [StartExclude hm_router_get_current_param] @State product: ProductMsg = @@ -37,11 +37,13 @@ export struct ProductContent { DetailConstants.PRODUCT_PRICE_NAMES[1]); // [EndExclude hm_router_get_current_param] // [EndExclude page_url] + // [EndExclude hm_router] @State param: ParamsType | null = null; aboutToAppear(): void { this.param = HMRouterMgr.getCurrentParam() as ParamsType; } + // [StartExclude hm_router] // [StartExclude page_url] // [StartExclude hm_router_get_current_param] build() { @@ -63,10 +65,10 @@ export struct ProductContent { .width('100%') .layoutWeight(1); } - // [EndExclude HMRouter] + // [EndExclude hm_router] // [EndExclude hm_router_get_current_param] // [EndExclude page_url] } -// [End HMRouter] +// [End hm_router] // [End page_url] // [End hm_router_get_current_param] \ No newline at end of file diff --git a/entry/src/main/ets/lifecycle/ExitAppLifecycle.ets b/entry/src/main/ets/lifecycle/ExitAppLifecycle.ets index f528f8115c271fcecbae579e4aed194c691ea4ce..42be9a6c871beac6468cdcd8ce74918a4b69974b 100644 --- a/entry/src/main/ets/lifecycle/ExitAppLifecycle.ets +++ b/entry/src/main/ets/lifecycle/ExitAppLifecycle.ets @@ -20,7 +20,7 @@ import { HMLifecycle, HMLifecycleContext, IHMLifecycle } from '@hadss/hmrouter'; import { CommonConstants } from '../component/common/constants/CommonConstants' -// [Start exit_app_lifecycle ] +// [Start exit_app_lifecycle] @HMLifecycle({lifecycleName: 'ExitAppLifecycle'}) export class ExitAppLifecycle implements IHMLifecycle { private lastTime: number = 0; diff --git a/entry/src/main/ets/segment/segment1.ets b/entry/src/main/ets/segment/segment1.ets new file mode 100644 index 0000000000000000000000000000000000000000..667906eecb0c97615bfd6e1417cb8e769d5bbd1b --- /dev/null +++ b/entry/src/main/ets/segment/segment1.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { HMRouterMgr } from '@hadss/hmrouter'; + +@Component +export struct ProductUtilView { + @Link product: ProductMsg; + @State param: string = '' + + build() { + Row() { + Image($r('app.media.tab_home')) + .width(24) + .margin({ + left: 16, + right: 16 + }) + .onClick(() => { + // [Start router_pop_param] + HMRouterMgr.pop({ navigationId: 'mainNavigationId', param: this.param }) + // [End router_pop_param] + }); + } + .margin({ top: 4 }); + } +} + +export class ProductMsg { + color: string; + memory: string; + price: string; + + constructor(color: string, memory: string, price: string) { + this.color = color; + this.memory = memory; + this.price = price; + } +} \ No newline at end of file