diff --git a/README.md b/README.md index e21c8499a76701d097757d6c15840c8e43863a22..0b264a7057c92b30ddcae49822a50fe2967bd1d8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 一次开发,多端部署-社区评论 +# 优秀实践-一次开发,多端部署-社区评论 ### 简介 @@ -43,9 +43,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 ”phone“)或![](screenshots/device/run.PNG)来启动应用/服务的编译构建。 - -![](screenshots/device/config.PNG) diff --git a/build-profile.json5 b/build-profile.json5 index d55e553f66c8efd3a7b8c1f2c23f80b6e82817ee..6ac8dea98076f3316fc795fa2adc44bd52772eae 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -1,6 +1,7 @@ { "app": { - "signingConfigs": [], + "signingConfigs": [ + ], "products": [ { "name": "default", diff --git a/commons/base/BuildProfile.ets b/commons/base/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/commons/base/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ 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/BreakpointConstants.ets b/commons/base/src/main/ets/constants/BreakpointConstants.ets index ba57fe8b835f1525d8fccaa4f94b37e981904d0f..aa093f5584b7d327985e1f195bc7fb0580e6d309 100644 --- a/commons/base/src/main/ets/constants/BreakpointConstants.ets +++ b/commons/base/src/main/ets/constants/BreakpointConstants.ets @@ -41,4 +41,9 @@ export class BreakpointConstants { * Grid column span list. */ static readonly GRID_COLUMN_SPANS: number[] = [12, 6, 7, 5, 3, 4, 2]; + + /** + * Breakpoint ranges. + */ + static readonly BREAKPOINT_RANGES: number[] = [320, 600, 840]; } \ No newline at end of file diff --git a/commons/base/src/main/ets/constants/CommonConstants.ets b/commons/base/src/main/ets/constants/CommonConstants.ets index 90e4036bc5752e01a540e1008e9a71a0ec39ba79..643aa362f44728a3002eb22475a061107c191949 100644 --- a/commons/base/src/main/ets/constants/CommonConstants.ets +++ b/commons/base/src/main/ets/constants/CommonConstants.ets @@ -37,22 +37,6 @@ export class CommonConstants { */ static readonly FONT_WEIGHT_700: number = 700; - /** - * Picture detail path. - */ - static readonly PICTURE_DETAIL_PATH :string = - '@bundle:com.huawei.multicommunityapplication/picture/ets/pages/PictureDetail'; - - /** - * Detail page path. - */ - static readonly DETAIL_PAGE_PATH: string = '@bundle:com.huawei.multicommunityapplication/detail/ets/pages/DetailPage'; - - /** - * Hot rank page path. - */ - static readonly HOT_RANK_PAGE_PATH: string = '@bundle:com.huawei.multicommunityapplication/rank/ets/pages/HotRankPage'; - /** * Rank title List. */ diff --git a/commons/base/src/main/ets/model/CardListModel.ets b/commons/base/src/main/ets/model/CardListModel.ets index e64bdfb3657c14e0495a9429444df74fea0a2ee4..e135b60d6ddd5fd6b1e63f69390b35d8be4ca317 100644 --- a/commons/base/src/main/ets/model/CardListModel.ets +++ b/commons/base/src/main/ets/model/CardListModel.ets @@ -22,74 +22,86 @@ export interface CardItemInterface { export const CARD_LIST: CardItemInterface[] = [ { - icon : $r('app.media.ic_icon_1'), - name : '小鱼儿', - authorType : '环保领域作者', - content : '亲近大海,领悟海,体会到了海的心声,海自然与你共鸣,无需可以强求,也无需费力搜寻,海,始终都会以潮声与你相亲,已其海色伴你舒适。' + icon: $r('app.media.ic_icon_1'), + name: '小鱼儿', + authorType: '环保领域作者', + content: '亲近大海,领悟海,体会到了海的心声,海自然与你共鸣,无需可以强求,也无需费力搜寻,海,始终都会以潮声与你相亲,已其海色伴你舒适。' + + '亲近大海,领悟海,体会到了海的心声,海自然与你共鸣,无需可以强求,也无需费力搜寻,海,始终都会以潮声与你相亲,已其海色伴你舒适。' }, { - icon : $r('app.media.ic_icon_2'), - name : '熊猫大人', - authorType : '环保领域作者', - content : '野生动物与宠物动物,可爱的动物人人都喜欢。' + icon: $r('app.media.ic_icon_2'), + name: '熊猫大人', + authorType: '环保领域作者', + content: '野生动物与宠物动物,可爱的动物人人都喜欢。野生动物与宠物动物,可爱的动物人人都喜欢。野生动物与宠物动物,可爱的动物人人都喜欢。' + + '野生动物与宠物动物,可爱的动物人人都喜欢。野生动物与宠物动物,可爱的动物人人都喜欢。' }, { - icon : $r('app.media.ic_icon_2'), - name : '熊猫大人', - authorType : '环保领域作者', - content : '君不见,黄河之水天上来,奔流到海不复回。君不见,高堂明镜悲白发,朝如青丝暮成雪。人生得意须尽欢,莫使金樽空对月。' + + icon: $r('app.media.ic_icon_2'), + name: '熊猫大人', + authorType: '环保领域作者', + content: '君不见,黄河之水天上来,奔流到海不复回。君不见,高堂明镜悲白发,朝如青丝暮成雪。人生得意须尽欢,莫使金樽空对月。' + '天生我材必有用,千金散尽还复来。烹羊宰牛且为乐,会须一饮三百杯。岑夫子,丹丘生,将进酒,杯莫停。与君歌一曲,请君为我倾耳听。' + '钟鼓馔玉不足贵,但愿长醉不愿醒。古来圣贤皆寂寞,惟有饮者留其名。陈王昔时宴平乐,斗酒十千恣欢谑。主人何为言少钱,径须沽取对君酌。' + '五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。' }, { - icon : $r('app.media.ic_icon_3'), - name : '飞行日记', - authorType : '科技领域作者', - content : '群鸟,仿佛从大地的心窝飞起的音符。旋风似的从田野腾空而起。小鸟的头部两侧镶嵌着一双宝石般的小眼睛,嘴巴长长的,上面是它的小鼻子。' + icon: $r('app.media.ic_icon_3'), + name: '飞行日记', + authorType: '科技领域作者', + content: '群鸟,仿佛从大地的心窝飞起的音符。旋风似的从田野腾空而起。小鸟的头部两侧镶嵌着一双宝石般的小眼睛,嘴巴长长的,上面是它的小鼻子。' + + '群鸟,仿佛从大地的心窝飞起的音符。旋风似的从田野腾空而起。小鸟的头部两侧镶嵌着一双宝石般的小眼睛,嘴巴长长的,上面是它的小鼻子。' }, { - icon : $r('app.media.ic_icon_4'), - name : '江湖旅客', - authorType : '旅行领域作者', - content : '伫立于河流两岸的山峦,如同沉默无言的僧侣,眺望着远方。' + icon: $r('app.media.ic_icon_4'), + name: '江湖旅客', + authorType: '旅行领域作者', + content: '伫立于河流两岸的山峦,如同沉默无言的僧侣,眺望着远方。伫立于河流两岸的山峦,如同沉默无言的僧侣,眺望着远方。' + + '伫立于河流两岸的山峦,如同沉默无言的僧侣,眺望着远方。伫立于河流两岸的山峦,如同沉默无言的僧侣,眺望着远方。' }, { - icon : $r('app.media.ic_icon_2'), - name : '摄影D叔', - authorType : '风景摄影领域作者', - content : '九如山的山,删删相连,连绵起伏。山腰盘旋的那曲折险峻的实木栈道,如缕缕飘带缠绕在绿水青山之中,成为一道独特的亮丽风景;' + + icon: $r('app.media.ic_icon_2'), + name: '摄影D叔', + authorType: '风景摄影领域作者', + content: '九如山的山,删删相连,连绵起伏。山腰盘旋的那曲折险峻的实木栈道,如缕缕飘带缠绕在绿水青山之中,成为一道独特的亮丽风景;' + + '幽深的小谷之中,升腾着鬼神莫测的云雾。' + + '九如山的山,删删相连,连绵起伏。山腰盘旋的那曲折险峻的实木栈道,如缕缕飘带缠绕在绿水青山之中,成为一道独特的亮丽风景;' + '幽深的小谷之中,升腾着鬼神莫测的云雾。' }, { - icon : $r('app.media.ic_icon_1'), - name : '小鱼儿', - authorType : '环保领域作者', - content : '亲近大海,领悟海,体会到了海的心声,海自然与你共鸣,无需可以强求,也无需费力搜寻,海,始终都会以潮声与你相亲,已其海色伴你舒适。' + icon: $r('app.media.ic_icon_1'), + name: '小鱼儿', + authorType: '环保领域作者', + content: '亲近大海,领悟海,体会到了海的心声,海自然与你共鸣,无需可以强求,也无需费力搜寻,海,始终都会以潮声与你相亲,已其海色伴你舒适。' + + '亲近大海,领悟海,体会到了海的心声,海自然与你共鸣,无需可以强求,也无需费力搜寻,海,始终都会以潮声与你相亲,已其海色伴你舒适。' }, { - icon : $r('app.media.ic_icon_2'), - name : '熊猫大人', - authorType : '环保领域作者', - content : '野生动物与宠物动物,可爱的动物人人都喜欢。' + icon: $r('app.media.ic_icon_2'), + name: '熊猫大人', + authorType: '环保领域作者', + content: '野生动物与宠物动物,可爱的动物人人都喜欢。野生动物与宠物动物,可爱的动物人人都喜欢。野生动物与宠物动物,可爱的动物人人都喜欢。' + + '野生动物与宠物动物,可爱的动物人人都喜欢。野生动物与宠物动物,可爱的动物人人都喜欢。野生动物与宠物动物,可爱的动物人人都喜欢。' }, { - icon : $r('app.media.ic_icon_3'), - name : '飞行日记', - authorType : '科技领域作者', - content : '群鸟,仿佛从大地的心窝飞起的音符。旋风似的从田野腾空而起。小鸟的头部两侧镶嵌着一双宝石般的小眼睛,嘴巴长长的,上面是它的小鼻子。' + icon: $r('app.media.ic_icon_3'), + name: '飞行日记', + authorType: '科技领域作者', + content: '群鸟,仿佛从大地的心窝飞起的音符。旋风似的从田野腾空而起。小鸟的头部两侧镶嵌着一双宝石般的小眼睛,嘴巴长长的,上面是它的小鼻子。' + + '群鸟,仿佛从大地的心窝飞起的音符。旋风似的从田野腾空而起。小鸟的头部两侧镶嵌着一双宝石般的小眼睛,嘴巴长长的,上面是它的小鼻子。' }, { - icon : $r('app.media.ic_icon_4'), - name : '江湖旅客', - authorType : '旅行领域作者', - content : '伫立于河流两岸的山峦,如同沉默无言的僧侣,眺望着远方。' + icon: $r('app.media.ic_icon_4'), + name: '江湖旅客', + authorType: '旅行领域作者', + content: '伫立于河流两岸的山峦,如同沉默无言的僧侣,眺望着远方。伫立于河流两岸的山峦,如同沉默无言的僧侣,眺望着远方。' + + '伫立于河流两岸的山峦,如同沉默无言的僧侣,眺望着远方。伫立于河流两岸的山峦,如同沉默无言的僧侣,眺望着远方。' }, { - icon : $r('app.media.ic_icon_2'), - name : '摄影D叔', - authorType : '风景摄影领域作者', - content : '九如山的山,删删相连,连绵起伏。山腰盘旋的那曲折险峻的实木栈道,如缕缕飘带缠绕在绿水青山之中,成为一道独特的亮丽风景;' + + icon: $r('app.media.ic_icon_2'), + name: '摄影D叔', + authorType: '风景摄影领域作者', + content: '九如山的山,删删相连,连绵起伏。山腰盘旋的那曲折险峻的实木栈道,如缕缕飘带缠绕在绿水青山之中,成为一道独特的亮丽风景;' + + '幽深的小谷之中,升腾着鬼神莫测的云雾。' + + '九如山的山,删删相连,连绵起伏。山腰盘旋的那曲折险峻的实木栈道,如缕缕飘带缠绕在绿水青山之中,成为一道独特的亮丽风景;' + '幽深的小谷之中,升腾着鬼神莫测的云雾。' }, ] \ No newline at end of file diff --git a/commons/base/src/main/module.json5 b/commons/base/src/main/module.json5 index 40fd8642bdc6e8d48b988a51b6d97b7505a8e2ed..9c4d9041e0ff8174abb8f746e862ef89b1459a97 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", "tablet", "2in1" - ], - "deliveryWithInstall": true, + ] } } \ No newline at end of file diff --git a/features/detail/BuildProfile.ets b/features/detail/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/features/detail/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/features/detail/Index.ets b/features/detail/Index.ets index 18769fb107ca3874d2ea27ac08150b0e2d41b6d4..f7e4e71f1d25398916b2d4efa7ad1acf50289916 100644 --- a/features/detail/Index.ets +++ b/features/detail/Index.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -export { DetailPage } from './src/main/ets/pages/DetailPage'; +export { DetailPage } from './src/main/ets/view/DetailPage'; export { CommentBarView } from './src/main/ets/view/CommentBarView'; 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/pages/DetailPage.ets b/features/detail/src/main/ets/view/DetailPage.ets similarity index 94% rename from features/detail/src/main/ets/pages/DetailPage.ets rename to features/detail/src/main/ets/view/DetailPage.ets index db65232084c25a02e8cb0605c87ea21c3f17a480..b6ed6aebdcf75caf904117c718ce02243e7a29a6 100644 --- a/features/detail/src/main/ets/pages/DetailPage.ets +++ b/features/detail/src/main/ets/view/DetailPage.ets @@ -14,18 +14,17 @@ */ import { BreakpointConstants as Breakpoint, CommonConstants as Common, BreakpointType } from '@ohos/base'; -import { DetailTitleView } from '../view/DetailTitleView'; -import { MircoBlogView } from '../view/MircoBlogView'; -import { CommentListView } from '../view/CommentListView'; -import { CommentBarView } from '../view/CommentBarView'; -import { CommentInputView } from '../view/CommentInputView'; +import { DetailTitleView } from './DetailTitleView'; +import { MircoBlogView } from './MircoBlogView'; +import { CommentListView } from './CommentListView'; +import { CommentBarView } from './CommentBarView'; +import { CommentInputView } from './CommentInputView'; import { CardArray } from '../viewmodel/CardArrayViewModel'; import { CardItem } from '../viewmodel/CardViewModel'; import CardArrayViewModel from '../viewmodel/CardArrayViewModel'; const KEY_BACKGROUND: string = 'background'; -@Entry @Component export struct DetailPage { @StorageLink('currentBreakpoint') currentBreakpoint: string = Breakpoint.BREAKPOINT_SM; @@ -103,9 +102,6 @@ export struct DetailPage { .height(Common.FULL_PERCENT) .width(Common.FULL_PERCENT) } - .onBreakpointChange((breakPoints) => { - this.currentBreakpoint = breakPoints; - }) } .layoutWeight(1) .visibility(this.currentBreakpoint === Breakpoint.BREAKPOINT_LG ? Visibility.None : Visibility.Visible) diff --git a/features/detail/src/main/ets/view/DetailTitleView.ets b/features/detail/src/main/ets/view/DetailTitleView.ets index 9b88e51dd23caa9d9b9032be9f93de5899e83191..48fc05a5ee4782c6392b8c4dad1ca2bee0afb817 100644 --- a/features/detail/src/main/ets/view/DetailTitleView.ets +++ b/features/detail/src/main/ets/view/DetailTitleView.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import { router } from '@kit.ArkUI'; import { deviceInfo } from '@kit.BasicServicesKit'; import { BreakpointConstants as Breakpoint, BreakpointType, CommonConstants as BaseCommon } from '@ohos/base'; @@ -21,6 +20,7 @@ import { BreakpointConstants as Breakpoint, BreakpointType, CommonConstants as B export struct DetailTitleView { @StorageLink('currentBreakpoint') @Watch('checkFoldable') currentBreakpoint: string = Breakpoint.BREAKPOINT_LG; @StorageLink('isFoldHorizontal') isFoldHorizontal: boolean = true; + @StorageLink('pageInfos') pageInfos: NavPathStack = new NavPathStack(); @State foldable: boolean = this.currentBreakpoint === Breakpoint.BREAKPOINT_MD; isShowedButton?: boolean = true; @@ -55,7 +55,8 @@ export struct DetailTitleView { .width($r('app.float.card_detail_back_width')) .aspectRatio(1) .onClick(() => { - router.back(); + this.pageInfos.pop(); + AppStorage.setOrCreate('isDetailPage', false); }) Image(this.isFoldHorizontal ? $r('app.media.ic_fold_horizontal') : $r('app.media.ic_fold_vertical')) diff --git a/features/detail/src/main/ets/view/MircoBlogView.ets b/features/detail/src/main/ets/view/MircoBlogView.ets index 8cbbd7975da7d30756e4da4e81c704e62bae223b..acb9310b94aebfd3579961cad0fe46d04bf6d268 100644 --- a/features/detail/src/main/ets/view/MircoBlogView.ets +++ b/features/detail/src/main/ets/view/MircoBlogView.ets @@ -13,12 +13,7 @@ * limitations under the License. */ -import { router } from '@kit.ArkUI'; -import { - CardItemInterface, - BreakpointConstants as Breakpoint, - CommonConstants as BaseCommon -} from '@ohos/base'; +import { CardItemInterface, BreakpointConstants as Breakpoint, CommonConstants as BaseCommon } from '@ohos/base'; import { CardItem } from '../viewmodel/CardViewModel'; import { CommonConstants as Common } from '../constants/CommonConstants'; @@ -39,6 +34,7 @@ export struct MircoBlogView { @StorageProp('currentBreakpoint') currentBreakpoint: string = Breakpoint.BREAKPOINT_LG; @StorageLink('isDetailPage') isDetailPage: boolean = false; @StorageLink('isPictureDetail') isPictureDetail: boolean = false; + @StorageLink('pageInfos') pageInfos: NavPathStack = new NavPathStack(); @State index: number = 0; @State cardItem: CardItem = new CardItem({} as CardItemInterface, 0); @State showPicture: boolean = true; @@ -55,19 +51,9 @@ export struct MircoBlogView { jump(index: number) { AppStorage.setOrCreate('selectCardIndex', this.index); if (this.isDetailPage) { - router.replaceUrl({ - url: BaseCommon.PICTURE_DETAIL_PATH, - params: { - index: index - } - }); + this.pageInfos.replacePath({ name: 'pictureDetail', param: index }); } else { - router.pushUrl({ - url: BaseCommon.PICTURE_DETAIL_PATH, - params: { - index: index - } - }); + this.pageInfos.pushPath({ name: 'pictureDetail', param: index }); } } diff --git a/features/detail/src/main/module.json5 b/features/detail/src/main/module.json5 index 84280e737d1245dd5f1f03f762ab0fe77ee8a927..e31989607abace49b9a3a5d8b3f4db87609e2c49 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", "tablet", "2in1" - ], - "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 300dc30dfd3ea55ad3444cf7606e0308b16f452c..0000000000000000000000000000000000000000 --- a/features/detail/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/DetailPage" - ] -} diff --git a/features/hot/Index.ets b/features/hot/Index.ets index 3b01f5bdb75465244b383c72d462a698bccb82b2..9ccf5e689b35c16fc50a28ca2eb94554ff4ceb11 100644 --- a/features/hot/Index.ets +++ b/features/hot/Index.ets @@ -13,4 +13,4 @@ * limitations under the License. */ -export { HotPointPage } from './src/main/ets/pages/HotPointPage'; +export { HotPointPage } from './src/main/ets/view/HotPointPage'; diff --git a/features/hot/hvigorfile.ts b/features/hot/hvigorfile.ts index d993120bd71f5f5dfe04480be9dc5f73c00c2599..42187071482d292588ad40babeda74f7b8d97a23 100644 --- a/features/hot/hvigorfile.ts +++ b/features/hot/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/hot/src/main/ets/view/CardItemView.ets b/features/hot/src/main/ets/view/CardItemView.ets index 68f1973da1cdb395d2442f79b545af14e3c8f98a..1a97423ca23c2e4a90bba9986286565a4d160fdd 100644 --- a/features/hot/src/main/ets/view/CardItemView.ets +++ b/features/hot/src/main/ets/view/CardItemView.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +import { App as app } from '@kit.ArkUI'; import { BreakpointConstants as Breakpoint, CommonConstants as BaseCommon, BreakpointType } from '@ohos/base'; import { CommonConstants as Common } from '../constants/CommonConstants' import { FollowItemInterface, FOLLOW_LIST, TITLE_DETAIL_LIST } from '../model/FollowModel'; @@ -25,6 +26,11 @@ export struct CardItemView { item: FollowItemInterface = FOLLOW_LIST[0]; name: string = ''; + aboutToAppear(): void { + app.setImageRawDataCacheSize(1024*1024*100); + app.setImageCacheCount(100); + } + build() { Column() { Row() { @@ -33,6 +39,7 @@ export struct CardItemView { .width($r('app.float.follow_item_icon_width')) .aspectRatio(1) .borderRadius($r('app.float.follow_item_icon_br')) + .autoResize(true) Column() { Text(this.index === 0 ? this.item.name : TITLE_DETAIL_LIST[this.index].name) diff --git a/features/hot/src/main/ets/view/FollowView.ets b/features/hot/src/main/ets/view/FollowView.ets index 82832606f4af9b06c9e4f6ebb8b20845873b4e4a..e732692ffd04d56f0562c13aa427cbb09f1ec197 100644 --- a/features/hot/src/main/ets/view/FollowView.ets +++ b/features/hot/src/main/ets/view/FollowView.ets @@ -109,7 +109,7 @@ export struct FollowView { this.indexSelected = index + 1; this.listScroller.scrollToIndex(this.indexSelected); this.pageInfo.clear(); - this.pageInfo.pushPath(new NavPathInfo(`${index}`, '')); + this.pageInfo.pushPath(new NavPathInfo(`${index}`, ''), false); }) }, (item: TitleDetailInterface, index: number) => index + JSON.stringify(item)) } @@ -138,7 +138,7 @@ export struct FollowView { this.listScroller.scrollToIndex(0); this.pageInfo.clear(); - this.pageInfo.pushPath(new NavPathInfo(`${this.indexSelected}`, '')); + this.pageInfo.pushPath(new NavPathInfo(`${this.indexSelected}`, ''), false); }) } .width(BaseCommon.FULL_PERCENT) @@ -203,7 +203,7 @@ export struct FollowView { this.indexTitleSelected = index - 1; this.listTitleScroller.scrollToIndex(this.indexTitleSelected < 0 ? 0 : this.indexTitleSelected); this.pageInfo.clear(); - this.pageInfo.pushPath(new NavPathInfo(`${index}`, '')); + this.pageInfo.pushPath(new NavPathInfo(`${index}`, ''), false); }) } }, (item: TitleDetailInterface, index: number) => index + JSON.stringify(item)) diff --git a/features/hot/src/main/ets/view/FoundView.ets b/features/hot/src/main/ets/view/FoundView.ets index c8e002ef363cee9295345ec72f8bf03ebb6a4cf1..782c43ffd2afd0bfcbfc74cdfabbddc4a08983b1 100644 --- a/features/hot/src/main/ets/view/FoundView.ets +++ b/features/hot/src/main/ets/view/FoundView.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import { router } from '@kit.ArkUI'; import { BreakpointConstants as Breakpoint, CommonConstants as BaseCommon, BreakpointType } from '@ohos/base'; import { CommentBarView, MircoBlogView } from '@ohos/detail'; import { CardArrayViewModel, CardArray } from '@ohos/detail'; @@ -25,12 +24,11 @@ import { HotColumnView } from '../view/HotColumnView'; export struct FoundView { @StorageLink('currentBreakpoint') currentBreakpoint: string = Breakpoint.BREAKPOINT_SM; @StorageLink('cardArrayViewModel') cardArrayViewModel: CardArray = CardArrayViewModel.getInstance(); + @StorageLink('pageInfos') pageInfos: NavPathStack = new NavPathStack(); @State tabIndexSelected: number = 0; jumpDetail() { - router.pushUrl({ - url: BaseCommon.DETAIL_PAGE_PATH - }); + this.pageInfos.pushPath({name : 'detailPage'}); } @Builder diff --git a/features/hot/src/main/ets/pages/HotPointPage.ets b/features/hot/src/main/ets/view/HotPointPage.ets similarity index 55% rename from features/hot/src/main/ets/pages/HotPointPage.ets rename to features/hot/src/main/ets/view/HotPointPage.ets index abf84d32280a963e12b10a40b0f6b0d2f9752933..96fd1587a4cca8bde1f1e8953b8a8e1fc3743ef2 100644 --- a/features/hot/src/main/ets/pages/HotPointPage.ets +++ b/features/hot/src/main/ets/view/HotPointPage.ets @@ -13,65 +13,36 @@ * limitations under the License. */ -import { router } from '@kit.ArkUI'; import { deviceInfo } from '@kit.BasicServicesKit'; -import { BreakpointConstants as Breakpoint, CommonConstants as BaseCommon } from '@ohos/base'; -import { FoundView } from '../view/FoundView'; -import { FollowView } from '../view/FollowView'; -import { HotTitleView } from '../view/HotTitleView'; +import { BreakpointConstants as Breakpoint, CommonConstants as BaseCommon } from '@ohos/base/'; +import { FoundView } from './FoundView'; +import { FollowView } from './FollowView'; +import { HotTitleView } from './HotTitleView'; -@Entry @Component export struct HotPointPage { @StorageLink('currentBreakpoint') currentBreakpoint: string = Breakpoint.BREAKPOINT_SM; @StorageLink('isFoundSelected') isFoundSelected: boolean = true; @StorageLink('isShowHotTitle') isShowHotTitle: boolean = true; - jumpDetail() { - router.pushUrl({ - url: BaseCommon.DETAIL_PAGE_PATH - }); - } - build() { Column() { - GridRow({ - columns: { - sm: Breakpoint.GRID_ROW_COLUMNS[2], - md: Breakpoint.GRID_ROW_COLUMNS[0], - lg: Breakpoint.GRID_ROW_COLUMNS[0] + Column() { + if (this.isShowHotTitle) { + HotTitleView() } - }) { - GridCol({ - span: { - sm: Breakpoint.GRID_COLUMN_SPANS[5], - md: Breakpoint.GRID_COLUMN_SPANS[0], - lg: Breakpoint.GRID_COLUMN_SPANS[0] - } - }) { - Column() { - if (this.isShowHotTitle) { - HotTitleView() - } - if (this.isFoundSelected) { - FoundView() - } - else { - Column() { - FollowView() - } - .layoutWeight(1) - } + if (this.isFoundSelected) { + FoundView() + } else { + Column() { + FollowView() } + .layoutWeight(1) } - .layoutWeight(1) } .height(BaseCommon.FULL_PERCENT) .width(BaseCommon.FULL_PERCENT) - .onBreakpointChange((breakPoints) => { - this.currentBreakpoint = breakPoints; - }) } .padding({ top: deviceInfo.deviceType === BaseCommon.DEVICE_2IN1 ? $r('app.float.zero') : $r('app.float.device_padding_top') diff --git a/features/hot/src/main/ets/view/ToRankView.ets b/features/hot/src/main/ets/view/ToRankView.ets index b3321f48b79864212d8b3d18ea6c110a538e41e2..d2be1f7cdcffc9134cbe4dd08d11c472344b2dac 100644 --- a/features/hot/src/main/ets/view/ToRankView.ets +++ b/features/hot/src/main/ets/view/ToRankView.ets @@ -13,12 +13,12 @@ * limitations under the License. */ -import { router } from '@kit.ArkUI'; -import { CommonConstants as BaseCommon } from '@ohos/base'; import { CommonConstants as Common } from '../constants/CommonConstants' @Component export struct ToRankView { + @StorageLink('pageInfos') pageInfos: NavPathStack = new NavPathStack(); + build() { Row() { Text($r('app.string.read_total_rank')) @@ -36,9 +36,7 @@ export struct ToRankView { .alignItems(VerticalAlign.Center) .margin({ top: $r('app.float.read_total_rank_mt') }) .onClick(() => { - router.pushUrl({ - url: BaseCommon.HOT_RANK_PAGE_PATH - }); + this.pageInfos.pushPath({ name: 'rankPage' }); }) } } \ No newline at end of file diff --git a/features/hot/src/main/module.json5 b/features/hot/src/main/module.json5 index 4019a4623b26f0be89a314a978e99fa2a472cb9e..2b99b58f6d584627a4225282e094914115a387ab 100644 --- a/features/hot/src/main/module.json5 +++ b/features/hot/src/main/module.json5 @@ -1,14 +1,12 @@ { "module": { "name": "hot", - "type": "shared", + "type": "har", "description": "$string:shared_desc", "deviceTypes": [ "phone", "tablet", "2in1" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" + ] } } \ No newline at end of file diff --git a/features/hot/src/main/resources/base/profile/main_pages.json b/features/hot/src/main/resources/base/profile/main_pages.json deleted file mode 100644 index d7e57e3b6abb2caf7909daa4739ce779e7f5bc30..0000000000000000000000000000000000000000 --- a/features/hot/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/HotPointPage" - ] -} diff --git a/features/picture/Index.ets b/features/picture/Index.ets index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..22841c49eccbd332c7aaa7fa82a796ad92747c25 100644 --- a/features/picture/Index.ets +++ b/features/picture/Index.ets @@ -0,0 +1 @@ +export { PictureDetail } from './src/main/ets/view/PictureDetail'; \ No newline at end of file diff --git a/features/picture/hvigorfile.ts b/features/picture/hvigorfile.ts index d993120bd71f5f5dfe04480be9dc5f73c00c2599..42187071482d292588ad40babeda74f7b8d97a23 100644 --- a/features/picture/hvigorfile.ts +++ b/features/picture/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/picture/src/main/ets/pages/PictureDetail.ets b/features/picture/src/main/ets/view/PictureDetail.ets similarity index 85% rename from features/picture/src/main/ets/pages/PictureDetail.ets rename to features/picture/src/main/ets/view/PictureDetail.ets index defae939b0f25cfc79d360282b2e828ed60ffafc..7e0e7474957bb26e85b1f5b8815ea038e3763d01 100644 --- a/features/picture/src/main/ets/pages/PictureDetail.ets +++ b/features/picture/src/main/ets/view/PictureDetail.ets @@ -13,24 +13,23 @@ * limitations under the License. */ -import { router } from '@kit.ArkUI'; -import { BreakpointConstants as Breakpoint, CommonConstants as BaseCommon, BreakpointType } from '@ohos/base'; -import { CardArrayViewModel, CardArray, CommentInputView } from '@ohos/detail'; -import { DetailVertical } from '../view/DetailVerticalView'; +import { BreakpointConstants as Breakpoint, CommonConstants as BaseCommon, BreakpointType } from '@ohos/base/'; +import { CardArrayViewModel, CardArray, CommentInputView } from '@ohos/detail/'; +import { DetailVertical } from './DetailVerticalView'; const KEY_BACKGROUND: string = 'background'; -@Entry @Component -struct Index { +export struct PictureDetail { @StorageLink('currentBreakpoint') currentBreakpoint: string = Breakpoint.BREAKPOINT_SM; @StorageLink('cardArrayViewModel') cardArrayViewModel: CardArray = CardArrayViewModel.getInstance(); @StorageLink('selectCardIndex') selectCardIndex: number = 0; @StorageLink('isDetailPage') isDetailPage: boolean = false; @StorageLink('isShowInput') isShowInput: boolean = false; @StorageLink('isPictureDetail') isPictureDetail: boolean = true; + @StorageLink('pageInfos') pageInfos: NavPathStack = new NavPathStack(); @State picList: Resource[] = []; - @State index: number = (router.getParams() as Record).index; + index: number = 0; aboutToAppear() { this.isPictureDetail = true; @@ -77,12 +76,7 @@ struct Index { .visibility(this.selectCardIndex === 0 ? Visibility.Hidden : Visibility.Visible) .onClick(() => { AppStorage.setOrCreate('selectCardIndex', this.selectCardIndex - 1); - router.replaceUrl({ - url: BaseCommon.PICTURE_DETAIL_PATH, - params: { - index: 0 - } - }); + this.pageInfos.replacePath({ name: 'pictureDetail', param: 0 }); }) Button($r('app.string.next')) @@ -92,12 +86,7 @@ struct Index { Visibility.Hidden : Visibility.Visible) .onClick(() => { AppStorage.setOrCreate('selectCardIndex', this.selectCardIndex + 1); - router.replaceUrl({ - url: BaseCommon.PICTURE_DETAIL_PATH, - params: { - index: 0 - } - }); + this.pageInfos.replacePath({ name: 'pictureDetail', param: 0 }); }) } .width(BaseCommon.FULL_PERCENT) @@ -131,11 +120,9 @@ struct Index { .index(this.index) .onClick(() => { if (this.isDetailPage) { - router.replaceUrl({ - url: BaseCommon.DETAIL_PAGE_PATH, - }); + this.pageInfos.replacePath({ name: 'detailPage' }); } else { - router.back(); + this.pageInfos.pop(); } }) @@ -144,11 +131,9 @@ struct Index { .aspectRatio(1) .onClick(() => { if (this.isDetailPage) { - router.replaceUrl({ - url: BaseCommon.DETAIL_PAGE_PATH, - }); + this.pageInfos.replacePath({ name: 'detailPage' }); } else { - router.back(); + this.pageInfos.pop(); } }) .margin({ @@ -172,9 +157,6 @@ struct Index { } .visibility(this.currentBreakpoint === Breakpoint.BREAKPOINT_LG ? Visibility.None : Visibility.Visible) } - .onBreakpointChange((breakPoints) => { - this.currentBreakpoint = breakPoints; - }) .layoutWeight(1) DetailVertical() diff --git a/features/picture/src/main/module.json5 b/features/picture/src/main/module.json5 index 643107c8195e198ff534ca8e97e4987d4d0fdcbe..6ad428a6f5f5d82f2948cf2d1264dd156a695fde 100644 --- a/features/picture/src/main/module.json5 +++ b/features/picture/src/main/module.json5 @@ -1,14 +1,12 @@ { "module": { "name": "picture", - "type": "shared", + "type": "har", "description": "$string:shared_desc", "deviceTypes": [ "phone", "tablet", "2in1" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" + ] } } \ No newline at end of file diff --git a/features/picture/src/main/resources/base/profile/main_pages.json b/features/picture/src/main/resources/base/profile/main_pages.json deleted file mode 100644 index 9ee99f5ade0717ed824380e8cae98ee40beaa5a3..0000000000000000000000000000000000000000 --- a/features/picture/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/PictureDetail" - ] -} diff --git a/features/rank/Index.ets b/features/rank/Index.ets index a5bd5d729c83c96015684b08878f7cb893b694a5..2ed50651eb0029513bded2c946c42e27b5c8a950 100644 --- a/features/rank/Index.ets +++ b/features/rank/Index.ets @@ -14,4 +14,4 @@ */ export { HotListItemView } from './src/main/ets/view/HotListItemView'; -export { HotRankPage } from './src/main/ets/pages/HotRankPage'; \ No newline at end of file +export { HotRankPage } from './src/main/ets/view/HotRankPage'; \ No newline at end of file diff --git a/features/rank/hvigorfile.ts b/features/rank/hvigorfile.ts index d993120bd71f5f5dfe04480be9dc5f73c00c2599..42187071482d292588ad40babeda74f7b8d97a23 100644 --- a/features/rank/hvigorfile.ts +++ b/features/rank/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/rank/src/main/ets/pages/HotRankPage.ets b/features/rank/src/main/ets/view/HotRankPage.ets similarity index 91% rename from features/rank/src/main/ets/pages/HotRankPage.ets rename to features/rank/src/main/ets/view/HotRankPage.ets index df10e05be6cd90e609be33427ceaafbd13d4a636..5f55a0a5e5f73a2015fd36192c329b775aa02ae7 100644 --- a/features/rank/src/main/ets/pages/HotRankPage.ets +++ b/features/rank/src/main/ets/view/HotRankPage.ets @@ -13,18 +13,17 @@ * limitations under the License. */ -import { router } from '@kit.ArkUI'; import { BreakpointConstants as Breakpoint, CommonConstants as BaseCommon, BreakpointType } from '@ohos/base'; -import { HotListView } from '../view/HotListView'; +import { HotListView } from './HotListView'; import { CommonConstants as Common } from '../constants/CommonConstants' const MAX_MARGIN_TOP: number = 52; const MIN_MARGIN_TOP: number = 46; -@Entry @Component export struct HotRankPage { @StorageLink('currentBreakpoint') currentBreakpoint: string = Breakpoint.BREAKPOINT_SM; + @StorageLink('pageInfos') pageInfos: NavPathStack = new NavPathStack(); @State titleMarginTop: number = MAX_MARGIN_TOP; @State index: number = 0; @@ -46,7 +45,7 @@ export struct HotRankPage { Column() { Text($r('app.string.rank_title')) .fontSize(this.titleMarginTop === MIN_MARGIN_TOP ? - $r('app.float.title_normal_fs') : $r('app.float.title_max_fs')) + $r('app.float.title_normal_fs') : $r('app.float.title_max_fs')) .fontWeight(BaseCommon.FONT_WEIGHT_700) .fontColor($r('app.color.title_font_color')) Text($r('app.string.ran_sub_title')) @@ -68,10 +67,12 @@ export struct HotRankPage { groupTitle: item, index: index }) - .margin({ top: this.titleMarginTop === MIN_MARGIN_TOP ? - $r('app.float.hot_list_view_min_mt') : $r('app.float.hot_list_view_max_mt') }) + .margin({ + top: this.titleMarginTop === MIN_MARGIN_TOP ? + $r('app.float.hot_list_view_min_mt') : $r('app.float.hot_list_view_max_mt') + }) .width(this.currentBreakpoint === Breakpoint.BREAKPOINT_SM ? - BaseCommon.FULL_PERCENT : $r('app.float.zero')) + BaseCommon.FULL_PERCENT : $r('app.float.zero')) .padding({ left: new BreakpointType($r('app.float.window_padding_left_sm'), $r('app.float.window_padding_left_md'), $r('app.float.window_padding_left_lg') @@ -102,7 +103,7 @@ export struct HotRankPage { .width($r('app.float.back_icon_width')) .aspectRatio(1) .onClick(() => { - router.back(); + this.pageInfos.pop(); }) Image($r('app.media.ic_public_more')) diff --git a/features/rank/src/main/module.json5 b/features/rank/src/main/module.json5 index 74e11eb44c4a895ed7d0fdafa4d4d7ef03e0cbc8..ddda4a1dd93f4b633e7a342b9bd5d3a1e6a4c8eb 100644 --- a/features/rank/src/main/module.json5 +++ b/features/rank/src/main/module.json5 @@ -1,14 +1,12 @@ { "module": { "name": "rank", - "type": "shared", + "type": "har", "description": "$string:shared_desc", "deviceTypes": [ "phone", "tablet", "2in1" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" + ] } } \ No newline at end of file diff --git a/features/rank/src/main/resources/base/profile/main_pages.json b/features/rank/src/main/resources/base/profile/main_pages.json deleted file mode 100644 index 719a08ccc08dbcebd66c8aada3a1c161b4ac44c4..0000000000000000000000000000000000000000 --- a/features/rank/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/HotRankPage" - ] -} diff --git a/products/phone/oh-package.json5 b/products/phone/oh-package.json5 index 8ee13838c055a42b36ed6405500d9000b1ae7f9b..741d553fedc281fe79b76d89e5c6a720fc640ec0 100644 --- a/products/phone/oh-package.json5 +++ b/products/phone/oh-package.json5 @@ -10,6 +10,8 @@ "dependencies": { "@ohos/hot": "file:../../features/hot", "@ohos/base": "file:../../commons/base", - "@ohos/detail": "file:../../features/detail" + "@ohos/detail": "file:../../features/detail", + "@ohos/rank": "file:../../features/rank", + "@ohos/picture": "file:../../features/picture" } } diff --git a/products/phone/src/main/ets/entryability/EntryAbility.ets b/products/phone/src/main/ets/entryability/EntryAbility.ets index 2f6ac161c8aabc4d39974c1ef89b1c423d0e08ee..97610d8227043ad9bc9fe5d4095d88048abe0619 100644 --- a/products/phone/src/main/ets/entryability/EntryAbility.ets +++ b/products/phone/src/main/ets/entryability/EntryAbility.ets @@ -16,10 +16,11 @@ import { UIAbility, Want, AbilityConstant } from '@kit.AbilityKit'; import { BusinessError, deviceInfo } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; -import { CommonConstants as BaseCommon } from '@ohos/base' +import { window, display } from '@kit.ArkUI'; +import { CommonConstants as BaseCommon, BreakpointConstants } from '@ohos/base' export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); } @@ -40,6 +41,12 @@ export default class EntryAbility extends UIAbility { if (deviceInfo.deviceType !== BaseCommon.DEVICE_2IN1) { data.setWindowLayoutFullScreen(true); } + // 获取当前窗口尺寸对应断点 + this.updateBreakpoint(data.getWindowProperties().windowRect.width); + // 监听窗口尺寸变化,改变断点 + data.on('windowSizeChange', (windowSize: window.Size) => { + this.updateBreakpoint(windowSize.width); + }) }) windowStage.loadContent('pages/MainPage', (err, data) => { @@ -65,4 +72,17 @@ export default class EntryAbility extends UIAbility { // Ability has back to background hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); } + + private updateBreakpoint(windowWidth: number) :void{ + let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; + let curBp: string = ''; + if (windowWidthVp < BreakpointConstants.BREAKPOINT_RANGES[1]) { + curBp = BreakpointConstants.BREAKPOINT_SM; + } else if (windowWidthVp < BreakpointConstants.BREAKPOINT_RANGES[2]) { + curBp = BreakpointConstants.BREAKPOINT_MD; + } else { + curBp = BreakpointConstants.BREAKPOINT_LG; + } + AppStorage.setOrCreate('currentBreakpoint', curBp); + } } diff --git a/products/phone/src/main/ets/pages/MainPage.ets b/products/phone/src/main/ets/pages/MainPage.ets index 99db08be11977a2fcac1d22604df119d187842c4..dc35dfd1fbd9e6a47d5119c39f2d64033276682a 100644 --- a/products/phone/src/main/ets/pages/MainPage.ets +++ b/products/phone/src/main/ets/pages/MainPage.ets @@ -14,22 +14,59 @@ */ import { BreakpointConstants as Breakpoint, CommonConstants as Common } from '@ohos/base'; +import { DetailPage } from '@ohos/detail'; +import { HotRankPage } from '@ohos/rank'; +import { PictureDetail } from '@ohos/picture'; import { TabContentView } from '../view/TabContentView'; @Entry @Component struct Index { @StorageLink('currentBreakpoint') currentBreakpoint: string = Breakpoint.BREAKPOINT_LG; + @StorageLink('pageInfos') pageInfos: NavPathStack = new NavPathStack(); - onPageShow() { - AppStorage.setOrCreate('isDetailPage', false); + aboutToAppear(): void { + this.pageInfos.pushPath({ name: 'mainPage' }); } - build() { - Column() { - TabContentView() + @Builder + pageMap(name: string, param: number) { + if ('rankPage' === name) { + NavDestination() { + HotRankPage() + } + .hideTitleBar(true) + } else if ('mainPage' === name) { + NavDestination() { + Column() { + TabContentView() + } + .width(Common.FULL_PERCENT) + .height(Common.FULL_PERCENT) + } + .hideTitleBar(true) + } else if ('detailPage' === name) { + NavDestination() { + DetailPage() + } + .onBackPressed(()=>{ + AppStorage.setOrCreate('isDetailPage', false); + return false; + }) + .hideTitleBar(true) + } else if ('pictureDetail' === name) { + NavDestination() { + PictureDetail({ index: param }) + } + .hideTitleBar(true) } - .width(Common.FULL_PERCENT) - .height(Common.FULL_PERCENT) + } + + build() { + Navigation(this.pageInfos) + .hideNavBar(true) + .navDestination(this.pageMap) + .width(Common.FULL_PERCENT) + .height(Common.FULL_PERCENT) } } \ No newline at end of file diff --git a/products/phone/src/main/ets/view/TabContentView.ets b/products/phone/src/main/ets/view/TabContentView.ets index 75f3805ce06f8edf606e5acbc5aad57da99a0d3e..59b6e3ec7d9828c056ed3be15e2d60c76a626895 100644 --- a/products/phone/src/main/ets/view/TabContentView.ets +++ b/products/phone/src/main/ets/view/TabContentView.ets @@ -86,9 +86,11 @@ export struct TabContentView { .barWidth(this.currentBreakpoint === Breakpoint.BREAKPOINT_LG ? $r('app.float.tab_bar_width') : Common.FULL_PERCENT) .scrollable(false) + .height(Common.FULL_PERCENT) } .backgroundColor($r('app.color.bar_background_color')) .padding({ bottom: this.currentBreakpoint !== Breakpoint.BREAKPOINT_LG ? $r('app.float.tab_content_pb') : $r('app.float.zero') }) + .height(Common.FULL_PERCENT) } } \ No newline at end of file diff --git a/screenshots/device/config.PNG b/screenshots/device/config.PNG deleted file mode 100644 index ae76718428bff184decba545858ab12541c764e6..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