diff --git a/README.md b/README.md index f1f13e0d0430e062ed51f36ca6c0b2d81ff0c505..8d49a197d3833238587ef5e1ef1c77fa5ac6e7ea 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 一多开发实例-购物比价 +# 优秀实践-一多开发实例-购物比价 ### 简介 @@ -51,8 +51,3 @@ 2. HarmonyOS系统:HarmonyOS NEXT Developer Beta1及以上。 3. DevEco Studio版本:DevEco Studio NEXT Developer Beta1及以上。 4. HarmonyOS SDK版本:HarmonyOS NEXT Developer Beta1 SDK及以上。 - -### 注意 - -运行时需设置引用所有HSP模块。点击Run > Edit Configurations,选择Deploy Multi Hap标签页,勾选Deploy Multi Hap Packages, 选择使用方模块(phone)和所有HSP模块,点击OK。单击Run > Run “模块名称”(如Run ”entry“)或![](screenshots/device/run.png)来启动应用/服务的编译构建。 -![](screenshots/device/config.png) \ No newline at end of file diff --git a/commons/base/hvigorfile.ts b/commons/base/hvigorfile.ts index d993120bd71f5f5dfe04480be9dc5f73c00c2599..42187071482d292588ad40babeda74f7b8d97a23 100644 --- a/commons/base/hvigorfile.ts +++ b/commons/base/hvigorfile.ts @@ -1,6 +1,6 @@ -import { hspTasks } from '@ohos/hvigor-ohos-plugin'; +import { harTasks } from '@ohos/hvigor-ohos-plugin'; export default { - system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ } diff --git a/commons/base/src/main/ets/constants/CommonConstants.ets b/commons/base/src/main/ets/constants/CommonConstants.ets index 0264295af8c7e6ed26f7692f17b00b33035cd982..b836e7893b63dd09a3dc65db52c16277a48614c8 100644 --- a/commons/base/src/main/ets/constants/CommonConstants.ets +++ b/commons/base/src/main/ets/constants/CommonConstants.ets @@ -144,11 +144,6 @@ export class CommonConstants { */ static readonly LIVE_VIDEO_NAME: string = 'live.mp4'; - /** - * Detail hsp name. - */ - static readonly DETAIL_HSP: string = 'detail'; - /** * Pip window util. */ diff --git a/commons/base/src/main/ets/utils/AvPlayerUtil.ets b/commons/base/src/main/ets/utils/AvPlayerUtil.ets index f05dc3c74905f7cdabcd489a7701159e19a41506..2234b0c4f1da50875818ea8a6380b57e694ce6dd 100644 --- a/commons/base/src/main/ets/utils/AvPlayerUtil.ets +++ b/commons/base/src/main/ets/utils/AvPlayerUtil.ets @@ -41,8 +41,7 @@ export class AvPlayerUtil { } switch (state) { case CommonConstants.AV_PLAYER_IDLE_STATE: - this.url = await this.context.createModuleContext(CommonConstants.DETAIL_HSP).resourceManager - .getRawFd(CommonConstants.LIVE_VIDEO_NAME); + this.url = await this.context.resourceManager.getRawFd(CommonConstants.LIVE_VIDEO_NAME); this.avPlayer.fdSrc = this.url; Logger.info('AVPlayer state idle called.'); break; @@ -106,8 +105,7 @@ export class AvPlayerUtil { this.surfaceId = surfaceId; Logger.info('Created AvPlayer successfully.'); // Entering idle state. - this.url = await this.context.createModuleContext(CommonConstants.DETAIL_HSP).resourceManager - .getRawFd(CommonConstants.LIVE_VIDEO_NAME); + this.url = await this.context.resourceManager.getRawFd(CommonConstants.LIVE_VIDEO_NAME); this.avPlayer.fdSrc = this.url; this.setAVPlayerCallback(); } else { diff --git a/commons/base/src/main/module.json5 b/commons/base/src/main/module.json5 index ad5984bb3d7fc6709aaff853d4efc620696e0fa6..292befa72c1dddac76f95da69a67dc9274bd559f 100644 --- a/commons/base/src/main/module.json5 +++ b/commons/base/src/main/module.json5 @@ -1,13 +1,12 @@ { "module": { "name": "base", - "type": "shared", + "type": "har", "description": "$string:shared_desc", "deviceTypes": [ "phone", "2in1", "tablet" - ], - "deliveryWithInstall": true + ] } } \ No newline at end of file diff --git a/features/detail/Index.ets b/features/detail/Index.ets index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a4ce6458be749f6b4bf400c4e86689f817019c10 100644 --- a/features/detail/Index.ets +++ b/features/detail/Index.ets @@ -0,0 +1,4 @@ +export { ProductHome } from './src/main/ets/view/ProductHome'; +export { LiveHome } from './src/main/ets/view/LiveHome'; +export { ProductMoreDetail } from './src/main/ets/view/ProductMoreDetail'; +export { DetailConstants } from './src/main/ets/constants/DetailConstants'; \ No newline at end of file diff --git a/features/detail/hvigorfile.ts b/features/detail/hvigorfile.ts index d993120bd71f5f5dfe04480be9dc5f73c00c2599..42187071482d292588ad40babeda74f7b8d97a23 100644 --- a/features/detail/hvigorfile.ts +++ b/features/detail/hvigorfile.ts @@ -1,6 +1,6 @@ -import { hspTasks } from '@ohos/hvigor-ohos-plugin'; +import { harTasks } from '@ohos/hvigor-ohos-plugin'; export default { - system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ } diff --git a/features/detail/src/main/ets/constants/DetailConstants.ets b/features/detail/src/main/ets/constants/DetailConstants.ets index ee303934b3f34004d3b23a85c797d88f1701f72d..aaf1d7d0b944427d488cc2d44a84e629071275a3 100644 --- a/features/detail/src/main/ets/constants/DetailConstants.ets +++ b/features/detail/src/main/ets/constants/DetailConstants.ets @@ -162,9 +162,4 @@ export class DetailConstants { * Navigation id. */ static readonly NAVIGATION_ID: string = 'navId'; - - /** - * Page info list. - */ - static readonly PAGE_INFO_LIST: string[] = ['liveIndex', 'moreDetail']; } \ No newline at end of file diff --git a/features/detail/src/main/ets/view/Live.ets b/features/detail/src/main/ets/view/Live.ets index 1f41dc27f9641bc7b4bfe31cdf6183d8cafc726c..9ef9d26313ba70c436cd3be712331ff8e3c04dcc 100644 --- a/features/detail/src/main/ets/view/Live.ets +++ b/features/detail/src/main/ets/view/Live.ets @@ -29,7 +29,6 @@ export struct Live { @Builder shopCarBuilder() {}; @Builder liveCloseBuilder() {}; @BuilderParam shopCarButton: () => void = this.shopCarBuilder; - @BuilderParam liveCloseButton: () => void = this.liveCloseBuilder; @Consume('pageInfos') pageInfos: NavPathStack; private pipWindowUtil: PipWindowUtil | undefined = PipWindowUtil.getPipWindowUtil(); private surfaceId: string = ''; @@ -71,7 +70,7 @@ export struct Live { .alignItems(HorizontalAlign.Center) Column() { - LiverHeader({ liveCloseButton: (): void => { this.liveCloseButton() }}) + LiverHeader() LiveMaskLayer({ currentBreakpoint:this.currentBreakpoint, detailType:this.detailType, diff --git a/features/detail/src/main/ets/pages/LiveIndex.ets b/features/detail/src/main/ets/view/LiveHome.ets similarity index 92% rename from features/detail/src/main/ets/pages/LiveIndex.ets rename to features/detail/src/main/ets/view/LiveHome.ets index a405c84ae52acab4ede5416aece162055611ca0e..f0b522a7650fe00fe9af495ad6e4fc01c4ed4d98 100644 --- a/features/detail/src/main/ets/pages/LiveIndex.ets +++ b/features/detail/src/main/ets/view/LiveHome.ets @@ -16,15 +16,15 @@ import { display } from '@kit.ArkUI'; import { Callback, deviceInfo } from '@kit.BasicServicesKit'; import { BreakpointConstants, BreakpointType, CommonConstants, Logger, ResourceUtil } from '@ohos/commons'; -import { Live } from '../view/Live'; -import { ShopBag } from '../view/ShopBag'; +import { Live } from './Live'; +import { ShopBag } from './ShopBag'; import { LiveConstants } from '../constants/LiveConstants'; -import { PayCard } from '../view/PayCard'; -import { ProductUtilView } from '../view/ProductUtilView'; -import { ProductInfo, ProductPicture } from '../view/ProductDetail'; +import { PayCard } from './PayCard'; +import { ProductUtilView } from './ProductUtilView'; +import { ProductInfo, ProductPicture } from './ProductDetail'; @Component -export struct LiveIndex { +export struct LiveHome { @StorageLink('currentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_LG; @StorageLink('topRectHeight') topRectHeight: number = 0; @State isMoreDetail: boolean = false; @@ -34,8 +34,6 @@ export struct LiveIndex { @State utilShoppingBag: boolean = false; @State utilCustomerService: boolean = false; @Consume('pageInfos') pageInfos: NavPathStack; - @Builder liveCloseBuilder() {}; - @BuilderParam liveCloseButton: () => void = this.liveCloseBuilder; private onFoldStatusChange: Callback = (data: display.FoldStatus) => { if (data === display.FoldStatus.FOLD_STATUS_FOLDED && this.detailType === CommonConstants.BIND_SHEET_PAGE_TYPES[2]) { @@ -123,7 +121,6 @@ export struct LiveIndex { Column() { Live({ shopCarButton: (): void => { this.shopCarButton() }, - liveCloseButton: (): void => { this.liveCloseButton() }, currentBreakpoint: this.isMoreDetail ? new BreakpointType(BreakpointConstants.BREAKPOINT_SM, BreakpointConstants.BREAKPOINT_SM, BreakpointConstants.BREAKPOINT_MD).getValue(this.currentBreakpoint) : this.currentBreakpoint, @@ -152,8 +149,7 @@ export struct LiveIndex { Column() { Scroll() { Column() { - ProductPicture({ pageBreakpoint: BreakpointConstants.BREAKPOINT_SM, isMoreLiveDetail: $isMoreDetail, - isNav: true }) + ProductPicture({ pageBreakpoint: BreakpointConstants.BREAKPOINT_SM, isMoreLiveDetail: $isMoreDetail }) ProductInfo({ pageBreakpoint: BreakpointConstants.BREAKPOINT_SM }) } .padding({ bottom: deviceInfo.deviceType !== CommonConstants.DEVICE_TYPES[0] ? diff --git a/features/detail/src/main/ets/view/LiverHeader.ets b/features/detail/src/main/ets/view/LiverHeader.ets index 1875b3de05430b96431964bd1cccd563c414f050..c9baf697c45637ce47a9d428013e1fe419358889 100644 --- a/features/detail/src/main/ets/view/LiverHeader.ets +++ b/features/detail/src/main/ets/view/LiverHeader.ets @@ -13,7 +13,9 @@ * limitations under the License. */ -import { BreakpointConstants, CommonConstants,ResourceUtil } from '@ohos/commons'; +import { deviceInfo } from '@kit.BasicServicesKit'; +import { BreakpointConstants, CommonConstants, PipWindowUtil,ResourceUtil } from '@ohos/commons'; +import { DetailConstants } from '../constants/DetailConstants'; @Component export struct LiverHeader { @@ -21,6 +23,7 @@ export struct LiverHeader { @Consume('pageInfos') pageInfos: NavPathStack; @Builder liveCloseBuilder() {}; @BuilderParam liveCloseButton: () => void = this.liveCloseBuilder; + private pipWindowUtil: PipWindowUtil | undefined = PipWindowUtil.getPipWindowUtil(); build() { Row() { @@ -44,7 +47,20 @@ export struct LiverHeader { .backgroundColor($r('app.color.store_background_color')) .border({ radius: $r('app.float.store_border_radius') }) - this.liveCloseButton() + Image($r('app.media.icon_close_3')) + .width(ResourceUtil.getCommonImgSize()[0]) + .height(ResourceUtil.getCommonImgSize()[0]) + .onClick(() => { + if (deviceInfo.deviceType !== CommonConstants.DEVICE_TYPES[0]) { + if (this.pipWindowUtil === undefined) { + return; + } + this.pipWindowUtil.startPip(DetailConstants.NAVIGATION_ID, this.pipWindowUtil.getXComponentController(), + getContext(this), this.pageInfos); + } else { + this.pageInfos.pop(); + } + }) } .width(CommonConstants.FULL_PERCENT) .height($r('app.float.store_height')) diff --git a/features/detail/src/main/ets/view/ProductDetail.ets b/features/detail/src/main/ets/view/ProductDetail.ets index a8f9e2963c65dbc5c2cf526cb67ef3f6ac6539ab..651345f39383153c2694a72ab4774588b7063f02 100644 --- a/features/detail/src/main/ets/view/ProductDetail.ets +++ b/features/detail/src/main/ets/view/ProductDetail.ets @@ -14,13 +14,13 @@ */ import { BusinessError, deviceInfo } from '@kit.BasicServicesKit'; -import { router } from '@kit.ArkUI'; +import { AbilityConstant, common, StartOptions, Want } from '@kit.AbilityKit'; +import { ClassifyConstants } from '@ohos/home'; import { BreakpointConstants, BreakpointType, CommonConstants, Logger, PipWindowUtil, ResourceUtil } from '@ohos/commons'; import { DetailConstants } from '../constants/DetailConstants'; import { ProductPrice } from './ProductPrice'; import { ProductDiscount } from './ProductDiscount'; import { ProductConfig, UserComments } from './ProductConfig'; -import { AbilityConstant, common, StartOptions, Want } from '@kit.AbilityKit'; @Component export struct ProductPicture { @@ -31,7 +31,6 @@ export struct ProductPicture { @Prop pageBreakpoint: string; @Link isMoreLiveDetail: boolean; @Consume('pageInfos') pageInfos: NavPathStack; - private isNav: boolean = false; private pipWindowUtil: PipWindowUtil | undefined = PipWindowUtil.getPipWindowUtil(); private abilityName: string = (getContext(this) as common.UIAbilityContext).abilityInfo.name; @@ -75,11 +74,7 @@ export struct ProductPicture { if (this.isMoreLiveDetail) { this.isMoreLiveDetail = false; } else { - if (this.isNav) { - this.pageInfos.pop(); - } else { - router.back(); - } + this.pageInfos.pop(); } }) Image($r('app.media.ic_zoom_out')) @@ -143,15 +138,15 @@ export struct ProductPicture { } if (this.pipWindowUtil.getIsShowingPip()) { this.pipWindowUtil.stopPip().then(() => { - this.pageInfos.pushPath({ name: DetailConstants.PAGE_INFO_LIST[0] }); + this.pageInfos.pushPath({ name: ClassifyConstants.PAGE_INFO_LIST[0] }); }).catch((err: BusinessError) => { Logger.error(`Failed to stop pip. Cause: ${err.code}, message: ${err.message}`); }); } else { - this.pageInfos.pushPath({ name: DetailConstants.PAGE_INFO_LIST[0] }); + this.pageInfos.pushPath({ name: ClassifyConstants.PAGE_INFO_LIST[0] }); } } else { - this.pageInfos.pushPath({ name: DetailConstants.PAGE_INFO_LIST[0] }); + this.pageInfos.pushPath({ name: ClassifyConstants.PAGE_INFO_LIST[0] }); } }) .margin({ diff --git a/features/detail/src/main/ets/pages/Index.ets b/features/detail/src/main/ets/view/ProductHome.ets similarity index 82% rename from features/detail/src/main/ets/pages/Index.ets rename to features/detail/src/main/ets/view/ProductHome.ets index 83ef00f83cfb7b68dffe642c2d574d0019c545bd..20049dacb3c60b5cce3e98815ef9112c109f98ad 100644 --- a/features/detail/src/main/ets/pages/Index.ets +++ b/features/detail/src/main/ets/view/ProductHome.ets @@ -16,17 +16,13 @@ import { deviceInfo } from '@kit.BasicServicesKit'; import { AbilityConstant, common, StartOptions, Want } from '@kit.AbilityKit'; import { BreakpointConstants, CommonConstants, PipWindowUtil, ResourceUtil } from '@ohos/commons'; -import { ProductInfo, ProductPicture } from '../view/ProductDetail'; -import { ProductUtilView } from '../view/ProductUtilView'; -import { DetailTopIcon } from '../view/CommonView'; -import { AllComments } from '../view/ProductConfig'; -import { LiveIndex } from './LiveIndex'; -import { ProductMoreDetail } from './ProductMoreDetail'; -import { DetailConstants } from '../constants/DetailConstants'; +import { ProductInfo, ProductPicture } from './ProductDetail'; +import { ProductUtilView } from './ProductUtilView'; +import { DetailTopIcon } from './CommonView'; +import { AllComments } from './ProductConfig'; -@Entry @Component -struct Index { +export struct ProductHome { @StorageLink('currentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_LG; @StorageLink('topRectHeight') topRectHeight: number = 0; @StorageLink('windowWidth') windowWidth: number = 0; @@ -38,8 +34,7 @@ struct Index { @State isDialogOpen: boolean = false; @State detailType: string = CommonConstants.BIND_SHEET_PAGE_TYPES[3]; @State isLiveMoreDetail: boolean = false; - @Provide('pageInfos') pageInfos: NavPathStack = new NavPathStack(); - private navId: string = DetailConstants.NAVIGATION_ID; + @Consume('pageInfos') pageInfos: NavPathStack; private pipWindowUtil: PipWindowUtil | undefined = PipWindowUtil.getPipWindowUtil(); aboutToDisappear(): void { @@ -51,36 +46,8 @@ struct Index { } } - @Builder - PageMap(name: string) { - if (name === DetailConstants.PAGE_INFO_LIST[0]) { - LiveIndex({ liveCloseButton: (): void => { this.LiveClose() } }) - } - if (name === DetailConstants.PAGE_INFO_LIST[1]) { - ProductMoreDetail() - } - } - - @Builder - LiveClose() { - Image($r('app.media.icon_close_3')) - .width(ResourceUtil.getCommonImgSize()[0]) - .height(ResourceUtil.getCommonImgSize()[0]) - .onClick(() => { - if (deviceInfo.deviceType !== CommonConstants.DEVICE_TYPES[0]) { - if (this.pipWindowUtil === undefined) { - return; - } - this.pipWindowUtil.startPip(this.navId, this.pipWindowUtil.getXComponentController(), getContext(this), - this.pageInfos); - } else { - this.pageInfos.pop(); - } - }) - } - build() { - Navigation(this.pageInfos) { + NavDestination() { SideBarContainer() { Column() { Image($r('app.media.icon_close_4')) @@ -198,9 +165,6 @@ struct Index { .maxSideBarWidth(px2vp(this.windowWidth) / CommonConstants.THREE) .autoHide(false) } - .navDestination(this.PageMap) - .mode(NavigationMode.Stack) - .id(this.navId) .hideTitleBar(true) } } \ No newline at end of file diff --git a/features/detail/src/main/ets/pages/ProductMoreDetail.ets b/features/detail/src/main/ets/view/ProductMoreDetail.ets similarity index 91% rename from features/detail/src/main/ets/pages/ProductMoreDetail.ets rename to features/detail/src/main/ets/view/ProductMoreDetail.ets index 84f56a19a36f5e92ca5f7309ca595544cab8e79d..9afa64a05818486b75beeab667ccd03c9199484c 100644 --- a/features/detail/src/main/ets/pages/ProductMoreDetail.ets +++ b/features/detail/src/main/ets/view/ProductMoreDetail.ets @@ -15,10 +15,10 @@ import { deviceInfo } from '@kit.BasicServicesKit'; import { BreakpointConstants, BreakpointType, CommonConstants, ResourceUtil } from '@ohos/commons'; -import { DetailShoppingBagView } from '@ohos/home'; -import { CustomerServiceView } from '../view/CustomerServiceView'; -import { ProductInfo, ProductPicture } from '../view/ProductDetail'; -import { ProductUtilView } from '../view/ProductUtilView'; +import { ClassifyConstants, DetailShoppingBagView } from '@ohos/home'; +import { CustomerServiceView } from './CustomerServiceView'; +import { ProductInfo, ProductPicture } from './ProductDetail'; +import { ProductUtilView } from './ProductUtilView'; import { DetailConstants } from '../constants/DetailConstants'; @Component @@ -32,7 +32,7 @@ export struct ProductMoreDetail { @Consume('pageInfos') pageInfos: NavPathStack; aboutToAppear(): void { - let navParams: string = JSON.stringify(this.pageInfos.getParamByName(DetailConstants.PAGE_INFO_LIST[1])); + let navParams: string = JSON.stringify(this.pageInfos.getParamByName(ClassifyConstants.PAGE_INFO_LIST[1])); if (navParams.includes(DetailConstants.PARAM_STRING_LIST[0])) { this.isShoppingBag = true; } @@ -55,8 +55,7 @@ export struct ProductMoreDetail { ProductPicture({ pageBreakpoint: new BreakpointType(BreakpointConstants.BREAKPOINT_SM, BreakpointConstants.BREAKPOINT_SM, BreakpointConstants.BREAKPOINT_MD).getValue(this.currentBreakpoint), - isMoreLiveDetail: $isLiveMoreDetail, - isNav: true + isMoreLiveDetail: $isLiveMoreDetail }) ProductInfo({ pageBreakpoint: new BreakpointType(BreakpointConstants.BREAKPOINT_SM, diff --git a/features/detail/src/main/ets/view/ProductUtilView.ets b/features/detail/src/main/ets/view/ProductUtilView.ets index ff1468767d1b2bab1e3133b6d92ea77274d4c817..ece8d3f0237ce2e41e3235d2d6f0ab9490c6ca41 100644 --- a/features/detail/src/main/ets/view/ProductUtilView.ets +++ b/features/detail/src/main/ets/view/ProductUtilView.ets @@ -14,6 +14,7 @@ */ import { deviceInfo } from '@kit.BasicServicesKit'; +import { ClassifyConstants } from '@ohos/home'; import { BreakpointConstants, CommonConstants, ResourceUtil } from '@ohos/commons'; import { DetailConstants } from '../constants/DetailConstants'; import { PayCard } from './PayCard'; @@ -80,7 +81,7 @@ export struct ProductUtilView { this.isCustomerService = true; this.isShoppingBag = false; } else { - this.pageInfos.pushPathByName(DetailConstants.PAGE_INFO_LIST[1], + this.pageInfos.pushPathByName(ClassifyConstants.PAGE_INFO_LIST[1], new NavParams(DetailConstants.PARAM_STRING_LIST[1])); } }) @@ -92,7 +93,7 @@ export struct ProductUtilView { this.isShoppingBag = true; this.isCustomerService = false; } else { - this.pageInfos.pushPathByName(DetailConstants.PAGE_INFO_LIST[1], + this.pageInfos.pushPathByName(ClassifyConstants.PAGE_INFO_LIST[1], new NavParams(DetailConstants.PARAM_STRING_LIST[0])); } }) diff --git a/features/detail/src/main/module.json5 b/features/detail/src/main/module.json5 index ecd562413902130d3ef609875134fda8fb8d4b03..be0ff174b2ab5784cb2979702660f0958dfcb60b 100644 --- a/features/detail/src/main/module.json5 +++ b/features/detail/src/main/module.json5 @@ -1,14 +1,12 @@ { "module": { "name": "detail", - "type": "shared", + "type": "har", "description": "$string:shared_desc", "deviceTypes": [ "phone", "2in1", "tablet" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" + ] } } \ No newline at end of file diff --git a/features/detail/src/main/resources/base/profile/main_pages.json b/features/detail/src/main/resources/base/profile/main_pages.json deleted file mode 100644 index 55c3f007f87b7ce5206d325f968cc56f2f79441f..0000000000000000000000000000000000000000 --- a/features/detail/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} \ No newline at end of file diff --git a/features/home/Index.ets b/features/home/Index.ets index 5f4484170e252505af22b29f6eb5c787b77b9d97..1ac3f1d0a4b0c85d3649f10c230fce10139e9f9d 100644 --- a/features/home/Index.ets +++ b/features/home/Index.ets @@ -1,2 +1,3 @@ export { Home } from './src/main/ets/view/Home'; -export { DetailShoppingBagView } from './src/main/ets/view/ShoppingBagContent'; \ No newline at end of file +export { DetailShoppingBagView } from './src/main/ets/view/ShoppingBagContent'; +export { ClassifyConstants } from './src/main/ets/constants/ClassifyConstants'; \ No newline at end of file diff --git a/features/home/hvigorfile.ts b/features/home/hvigorfile.ts index d993120bd71f5f5dfe04480be9dc5f73c00c2599..42187071482d292588ad40babeda74f7b8d97a23 100644 --- a/features/home/hvigorfile.ts +++ b/features/home/hvigorfile.ts @@ -1,6 +1,6 @@ -import { hspTasks } from '@ohos/hvigor-ohos-plugin'; +import { harTasks } from '@ohos/hvigor-ohos-plugin'; export default { - system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ } diff --git a/features/home/src/main/ets/constants/ClassifyConstants.ets b/features/home/src/main/ets/constants/ClassifyConstants.ets index 0f6bf384a0f934ceac37afab8b999d8b73fdedce..dfb6dc417e49eb9c041086f1c5e87c9fba92a425 100644 --- a/features/home/src/main/ets/constants/ClassifyConstants.ets +++ b/features/home/src/main/ets/constants/ClassifyConstants.ets @@ -84,7 +84,7 @@ export class ClassifyConstants { static readonly GRID_ROW_GUTTERS: number[] = [24, 8, 16, 12]; /** - * Router urls. + * Page info list. */ - static readonly ROUTER_URLS: string[] = ['@bundle:com.huawei.multishoppingpricecomparison/detail/ets/pages/Index']; + static readonly PAGE_INFO_LIST: string[] = ['liveHome', 'moreDetail', 'productHome']; } \ No newline at end of file diff --git a/features/home/src/main/ets/pages/Index.ets b/features/home/src/main/ets/pages/Index.ets deleted file mode 100644 index 97fc7cc9c4046c69dd58aa759e6fb34468c2daa8..0000000000000000000000000000000000000000 --- a/features/home/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 { CommonConstants } from '@ohos/commons/Index'; -import { Home } from '../view/Home'; - -@Entry -@Component -struct Index { - build() { - Column() { - Home() - } - .width(CommonConstants.FULL_PERCENT) - .height(CommonConstants.FULL_PERCENT) - } -} \ No newline at end of file diff --git a/features/home/src/main/ets/view/ClassifyShopList.ets b/features/home/src/main/ets/view/ClassifyShopList.ets index 2e5e0d9359c24b50825b9ea8e2542bab73af0fce..c587324a694e29d31fbae4637f8bea4d21479e4a 100644 --- a/features/home/src/main/ets/view/ClassifyShopList.ets +++ b/features/home/src/main/ets/view/ClassifyShopList.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import { router } from '@kit.ArkUI'; import { BreakpointConstants, BreakpointType, CommonConstants, ResourceUtil } from '@ohos/commons'; import { ClassifyConstants } from '../constants/ClassifyConstants'; import { ShopListViewModel, ShopListItem, ShopItem } from '../viewmodel/ShopListViewModel'; @@ -21,6 +20,7 @@ import { ShopListViewModel, ShopListItem, ShopItem } from '../viewmodel/ShopList @Component export struct ClassifyShopList { @StorageLink('currentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_LG; + @Consume('pageInfos') pageInfos: NavPathStack; private shopList: ShopListViewModel = new ShopListViewModel(); build() { @@ -62,7 +62,7 @@ export struct ClassifyShopList { .textOverflow({ overflow: TextOverflow.Ellipsis }) } .onClick(() => { - router.pushUrl({ url: ClassifyConstants.ROUTER_URLS[0] }); + this.pageInfos.pushPath({ name: ClassifyConstants.PAGE_INFO_LIST[2] }); }) } }, (item: ShopItem, index: number) => JSON.stringify(item) + index) diff --git a/features/home/src/main/module.json5 b/features/home/src/main/module.json5 index a58d299534056c94a9c105228e1e3e9b2c674a62..a911a60e0b36d765f8ba54364fc1d7df4089603b 100644 --- a/features/home/src/main/module.json5 +++ b/features/home/src/main/module.json5 @@ -1,14 +1,12 @@ { "module": { "name": "home", - "type": "shared", + "type": "har", "description": "$string:shared_desc", "deviceTypes": [ "phone", "2in1", "tablet" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" + ] } } \ No newline at end of file diff --git a/features/home/src/main/resources/base/profile/main_pages.json b/features/home/src/main/resources/base/profile/main_pages.json deleted file mode 100644 index 1898d94f58d6128ab712be2c68acc7c98e9ab9ce..0000000000000000000000000000000000000000 --- a/features/home/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} diff --git a/products/phone/oh-package.json5 b/products/phone/oh-package.json5 index 996db70c6b2666cceb495205c4f15eca5d2cca8f..741122e9fa48e20702dfb3c8cc77c32051885ce6 100644 --- a/products/phone/oh-package.json5 +++ b/products/phone/oh-package.json5 @@ -9,6 +9,7 @@ "dynamicDependencies": {}, "dependencies": { "@ohos/commons": "file:../../commons/base", - "@ohos/home": "file:../../features/home" + "@ohos/home": "file:../../features/home", + "@ohos/detail": "file:../../features/detail" } } diff --git a/products/phone/src/main/ets/entryability/EntryAbility.ets b/products/phone/src/main/ets/entryability/EntryAbility.ets index bfb494117d17d6246c99f08c14f614e1702c63d3..a43263c0509f044a5677ee8561af29003d4885d4 100644 --- a/products/phone/src/main/ets/entryability/EntryAbility.ets +++ b/products/phone/src/main/ets/entryability/EntryAbility.ets @@ -22,7 +22,6 @@ import { CommonConstants, Logger, WindowUtil } from '@ohos/commons'; export default class EntryAbility extends UIAbility { private windowObj?: window.Window; private windowUtil?: WindowUtil; - private mainWindow?: window.Window; private onWindowSizeChange: (windowSize: window.Size) => void = (windowSize: window.Size) => { this.windowUtil?.updateBreakpoint(windowSize.width); AppStorage.setOrCreate('windowWidth', windowSize.width); @@ -39,19 +38,6 @@ export default class EntryAbility extends UIAbility { onDestroy(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - if (this.windowUtil === undefined) { - return; - } - this.mainWindow = this.windowUtil.getMainWindow(); - if (this.mainWindow === undefined) { - return; - } - try { - this.mainWindow.off('windowSizeChange'); - this.mainWindow.off('windowStatusChange'); - } catch (exception) { - Logger.error('Failed to unregister the window callback. Code: ' + JSON.stringify(exception)); - } } async onWindowStageCreate(windowStage: window.WindowStage): Promise { diff --git a/products/phone/src/main/ets/pages/Index.ets b/products/phone/src/main/ets/pages/Index.ets index f47e37f5e5b6c17d688d6528f8afce5878692fa4..8bf43fc8f814089480985cc1f9ec26945952069a 100644 --- a/products/phone/src/main/ets/pages/Index.ets +++ b/products/phone/src/main/ets/pages/Index.ets @@ -13,17 +13,64 @@ * limitations under the License. */ -import { CommonConstants } from '@ohos/commons/Index'; +import { window } from '@kit.ArkUI'; +import { CommonConstants, Logger, WindowUtil } from '@ohos/commons/Index'; +import { DetailConstants, ProductHome } from '@ohos/detail/Index'; +import { ProductMoreDetail } from '@ohos/detail/Index'; +import { LiveHome } from '@ohos/detail/Index'; import { Home } from '@ohos/home/Index'; +import { ClassifyConstants } from '@ohos/home/Index'; @Entry @Component struct Index { + @Provide('pageInfos') pageInfos: NavPathStack = new NavPathStack(); + @StorageLink('isSplitMode') isSplitMode: boolean = false; + private windowUtil?: WindowUtil; + private mainWindow?: window.Window; + + aboutToAppear(): void { + if (this.isSplitMode) { + this.pageInfos.pushPath({ name: ClassifyConstants.PAGE_INFO_LIST[2] }) + } + } + + aboutToDisappear(): void { + if (this.windowUtil === undefined) { + return; + } + this.mainWindow = this.windowUtil.getMainWindow(); + if (this.mainWindow === undefined) { + return; + } + try { + this.mainWindow.off('windowSizeChange'); + this.mainWindow.off('windowStatusChange'); + } catch (exception) { + Logger.error('Failed to unregister the window callback. Code: ' + JSON.stringify(exception)); + } + } + + @Builder + PageMap(name: string) { + if (name === ClassifyConstants.PAGE_INFO_LIST[0]) { + LiveHome() + } else if (name === ClassifyConstants.PAGE_INFO_LIST[1]) { + ProductMoreDetail() + } else { + ProductHome() + } + } + build() { - Column() { + Navigation(this.pageInfos) { Home() } .width(CommonConstants.FULL_PERCENT) .height(CommonConstants.FULL_PERCENT) + .navDestination(this.PageMap) + .mode(NavigationMode.Stack) + .id(DetailConstants.NAVIGATION_ID) + .hideTitleBar(true) } } \ No newline at end of file diff --git a/products/phone/src/main/ets/secondability/SecondAbility.ets b/products/phone/src/main/ets/secondability/SecondAbility.ets index a28c4e6579f95b81af0d59a168b6e00a9eb1eead..82b806067f72e59ea6e7c7f6730d06e5d5285f52 100644 --- a/products/phone/src/main/ets/secondability/SecondAbility.ets +++ b/products/phone/src/main/ets/secondability/SecondAbility.ets @@ -80,7 +80,7 @@ export default class SecondAbility extends UIAbility { } } - windowStage.loadContent('@bundle:com.huawei.multishoppingpricecomparison/detail/ets/pages/Index', (err, data) => { + windowStage.loadContent('pages/Index', (err, data) => { if (err.code) { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; diff --git a/screenshots/device/config.png b/screenshots/device/config.png deleted file mode 100644 index 13b3a81dfbd46254c388b6136abcf671760f2958..0000000000000000000000000000000000000000 Binary files a/screenshots/device/config.png and /dev/null differ diff --git a/screenshots/device/run.png b/screenshots/device/run.png deleted file mode 100644 index 7655fa7e041bb067e028029d820bd2d320e2cd83..0000000000000000000000000000000000000000 Binary files a/screenshots/device/run.png and /dev/null differ