From cfa9678ba122ab643a995c4d26e6fd171e13f3b3 Mon Sep 17 00:00:00 2001 From: ZhangQ <17366354960@163.com> Date: Fri, 16 Jan 2026 07:20:23 +0000 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E6=94=AF=E6=8C=812in1=E8=AE=BE?= =?UTF-8?q?=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ZhangQ <12903047+zq-kexin@user.noreply.gitee.com> --- README.en.md | 4 ++-- README.md | 4 ++-- common/base/src/main/ets/constants/BaseConstants.ets | 7 +++---- common/base/src/main/module.json5 | 3 +-- features/home/src/main/ets/pages/ContactsDetail.ets | 2 +- features/home/src/main/ets/pages/ConversationDetail.ets | 2 +- features/home/src/main/ets/pages/ConversationList.ets | 2 +- features/home/src/main/ets/pages/Index.ets | 8 ++++---- .../ets/views/Conversation/ConversationDetailNone.ets | 2 +- .../views/Conversation/ConversationDetailTopSearch.ets | 2 +- features/home/src/main/ets/views/common/HomeTopSearch.ets | 2 +- features/home/src/main/module.json5 | 3 +-- features/socialCircle/src/main/ets/pages/Index.ets | 2 +- features/socialCircle/src/main/module.json5 | 3 +-- products/phone/build-profile.json5 | 3 +-- products/phone/src/main/ets/entryability/EntryAbility.ets | 2 +- products/phone/src/main/module.json5 | 3 +-- 17 files changed, 24 insertions(+), 30 deletions(-) diff --git a/README.en.md b/README.en.md index c982f45..8219c33 100644 --- a/README.en.md +++ b/README.en.md @@ -6,7 +6,7 @@ Learn to implement an instant messaging app based on the adaptive layout and res #### Description -This codelab implements an instant messaging app based on the adaptive layout and responsive layout, achieving one-time development for multi-device deployment. It uses the three-layer project architecture for code reuse and tailors the pages to different device sizes such as mobile phones, foldable phones, and PC/2-in-1 devices. +This codelab implements an instant messaging app based on the adaptive layout and responsive layout, achieving one-time development for multi-device deployment. It uses the three-layer project architecture for code reuse and tailors the pages to different device sizes such as mobile phones, foldable phones, and table devices. The following figure shows the effect on the mobile phone: ![](screenshots/device/phone_EN.png) @@ -15,7 +15,7 @@ The following figure shows the effect on the foldable phone in unfolded state: ![](screenshots/device/foldable_EN.png) -The following figure shows the effect on the PC/2-in-1 device: +The following figure shows the effect on the table device: ![](screenshots/device/pad_EN.png) diff --git a/README.md b/README.md index cb2a076..e6cd662 100755 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ #### 介绍 -本篇Codelab基于自适应布局和响应式布局,实现一次开发,多端部署的即时通讯页面。通过“三层工程架构”实现代码复用,并根据手机、折叠屏以及PC/2in1不同的设备尺寸设计对应页面。 +本篇Codelab基于自适应布局和响应式布局,实现一次开发,多端部署的即时通讯页面。通过“三层工程架构”实现代码复用,并根据手机、折叠屏以及平板不同的设备尺寸设计对应页面。 手机效果如图所示: ![](screenshots/device/phone.png) @@ -15,7 +15,7 @@ ![](screenshots/device/foldable.png) -PC/2in1效果如图所示: +平板效果如图所示: ![](screenshots/device/pad.png) diff --git a/common/base/src/main/ets/constants/BaseConstants.ets b/common/base/src/main/ets/constants/BaseConstants.ets index d7dce33..df5bdc8 100755 --- a/common/base/src/main/ets/constants/BaseConstants.ets +++ b/common/base/src/main/ets/constants/BaseConstants.ets @@ -104,9 +104,9 @@ export class BaseConstants { static readonly DEVICE_GRID_COLUMNS: string[] = ['1fr 1fr', '1fr 1fr 1fr', '1fr 1fr 1fr 1fr', '1fr 1fr 1fr 1fr 1fr', '1fr 1fr 1fr 1fr 1fr 1fr 1fr']; /** - * Device PC/2in1. + * Device tablet. */ - static readonly DEVICE_2IN1: string = '2in1'; + static readonly DEVICE_TABLET: string = 'tablet'; } /** @@ -130,6 +130,5 @@ export enum CurrentPage { export enum DeviceTypes { PHONE = 'phone', - TABLET = 'tablet', - "2IN1" = '2in1', + TABLET = 'tablet' } \ No newline at end of file diff --git a/common/base/src/main/module.json5 b/common/base/src/main/module.json5 index 169b18e..d0ded38 100755 --- a/common/base/src/main/module.json5 +++ b/common/base/src/main/module.json5 @@ -4,8 +4,7 @@ "type": "har", "deviceTypes": [ "phone", - "tablet", - "2in1" + "tablet" ] } } \ No newline at end of file diff --git a/features/home/src/main/ets/pages/ContactsDetail.ets b/features/home/src/main/ets/pages/ContactsDetail.ets index f1bf0da..6393a5e 100755 --- a/features/home/src/main/ets/pages/ContactsDetail.ets +++ b/features/home/src/main/ets/pages/ContactsDetail.ets @@ -45,7 +45,7 @@ export struct ContactsDetail { .height(BaseConstants.FULL_HEIGHT) .backgroundColor($r('app.color.background_color_pink')) .padding({ - top: deviceInfo.deviceType === BaseConstants.DEVICE_2IN1 ? $r('app.float.zero') : $r('app.float.device_padding_top') + top: deviceInfo.deviceType === BaseConstants.DEVICE_TABLET ? $r('app.float.zero') : $r('app.float.device_padding_top') }) Image(this.currentContactUserIcon) diff --git a/features/home/src/main/ets/pages/ConversationDetail.ets b/features/home/src/main/ets/pages/ConversationDetail.ets index 2b22103..1073c66 100755 --- a/features/home/src/main/ets/pages/ConversationDetail.ets +++ b/features/home/src/main/ets/pages/ConversationDetail.ets @@ -58,7 +58,7 @@ export struct ConversationDetail { .width('100%') .backgroundColor($r('app.color.background_color_grey')) .padding({ - bottom: deviceInfo.deviceType !== '2in1' ? '28vp' : '0vp' + bottom: deviceInfo.deviceType !== 'tablet' ? '28vp' : '0vp' }) } .hideTitleBar(true) diff --git a/features/home/src/main/ets/pages/ConversationList.ets b/features/home/src/main/ets/pages/ConversationList.ets index 73aac46..f7631be 100755 --- a/features/home/src/main/ets/pages/ConversationList.ets +++ b/features/home/src/main/ets/pages/ConversationList.ets @@ -54,7 +54,7 @@ export struct ConversationList { } // [End conversation_list] .padding({ - bottom: deviceInfo.deviceType !== '2in1' && this.currentBreakpoint === 'lg' ? '28vp' : '0vp' + bottom: deviceInfo.deviceType !== 'tablet' && this.currentBreakpoint === 'lg' ? '28vp' : '0vp' }) .backgroundColor(Color.White) .width('100%') diff --git a/features/home/src/main/ets/pages/Index.ets b/features/home/src/main/ets/pages/Index.ets index 8e2e63f..eeab418 100755 --- a/features/home/src/main/ets/pages/Index.ets +++ b/features/home/src/main/ets/pages/Index.ets @@ -93,7 +93,7 @@ export struct Index { .visibility(this.currentBreakpoint !== 'lg' ? Visibility.Visible : Visibility.None) } .padding({ - bottom: deviceInfo.deviceType !== '2in1' && this.currentBreakpoint !== 'lg' ? '28vp' : '0vp' + bottom: deviceInfo.deviceType !== 'tablet' && this.currentBreakpoint !== 'lg' ? '28vp' : '0vp' }) .height('100%') } else if (this.currentPageIndex === 1) { @@ -112,7 +112,7 @@ export struct Index { } .height('100%') .padding({ - bottom: deviceInfo.deviceType !== '2in1' && this.currentBreakpoint !== 'lg' ? '28vp' : '0vp' + bottom: deviceInfo.deviceType !== 'tablet' && this.currentBreakpoint !== 'lg' ? '28vp' : '0vp' }) } } @@ -177,8 +177,8 @@ export struct Index { .visibility(this.currentPageIndex === CurrentPage.ME && this.currentBreakpoint !== 'lg' ? Visibility.Visible : Visibility.None) .padding({ - top: deviceInfo.deviceType === '2in1' ? $r('app.float.zero') : $r('app.float.device_padding_top'), - bottom: deviceInfo.deviceType !== '2in1' + top: deviceInfo.deviceType === 'tablet' ? $r('app.float.zero') : $r('app.float.device_padding_top'), + bottom: deviceInfo.deviceType !== 'tablet' && this.currentBreakpoint !== 'lg' ? $r('app.float.tab_content_pb') : $r('app.float.zero') }) diff --git a/features/home/src/main/ets/views/Conversation/ConversationDetailNone.ets b/features/home/src/main/ets/views/Conversation/ConversationDetailNone.ets index f8c0bec..6c9d751 100755 --- a/features/home/src/main/ets/views/Conversation/ConversationDetailNone.ets +++ b/features/home/src/main/ets/views/Conversation/ConversationDetailNone.ets @@ -29,7 +29,7 @@ export default struct ConversationDetailNone { .height(BaseConstants.FULL_HEIGHT) } .padding({ - top: deviceInfo.deviceType === BaseConstants.DEVICE_2IN1 ? $r('app.float.zero') : $r('app.float.device_padding_top') + top: deviceInfo.deviceType === BaseConstants.DEVICE_TABLET ? $r('app.float.zero') : $r('app.float.device_padding_top') }) .hideTitleBar(true) } diff --git a/features/home/src/main/ets/views/Conversation/ConversationDetailTopSearch.ets b/features/home/src/main/ets/views/Conversation/ConversationDetailTopSearch.ets index a971d28..33e60f4 100755 --- a/features/home/src/main/ets/views/Conversation/ConversationDetailTopSearch.ets +++ b/features/home/src/main/ets/views/Conversation/ConversationDetailTopSearch.ets @@ -46,6 +46,6 @@ export struct ConversationDetailTopSearch { } .width(BaseConstants.FULL_WIDTH) .height(BaseConstants.FULL_HEIGHT) - .padding({ left: $r('app.float.icon_margin_two'), right: $r('app.float.icon_margin_two'),top: deviceInfo.deviceType === BaseConstants.DEVICE_2IN1 ? $r('app.float.zero') : $r('app.float.device_padding_top') }) + .padding({ left: $r('app.float.icon_margin_two'), right: $r('app.float.icon_margin_two'),top: deviceInfo.deviceType === BaseConstants.DEVICE_TABLET ? $r('app.float.zero') : $r('app.float.device_padding_top') }) } } \ No newline at end of file diff --git a/features/home/src/main/ets/views/common/HomeTopSearch.ets b/features/home/src/main/ets/views/common/HomeTopSearch.ets index 2fe1d65..9355e0a 100755 --- a/features/home/src/main/ets/views/common/HomeTopSearch.ets +++ b/features/home/src/main/ets/views/common/HomeTopSearch.ets @@ -53,7 +53,7 @@ export struct HomeTopSearch { .width(BaseConstants.FULL_WIDTH) .height(BaseConstants.FULL_HEIGHT) .backgroundColor(Color.White) - .padding({ left: $r('app.float.phone_icon_left'),top: deviceInfo.deviceType === BaseConstants.DEVICE_2IN1 ? $r('app.float.zero') : $r('app.float.device_padding_top') }) + .padding({ left: $r('app.float.phone_icon_left'),top: deviceInfo.deviceType === BaseConstants.DEVICE_TABLET ? $r('app.float.zero') : $r('app.float.device_padding_top') }) } @Builder diff --git a/features/home/src/main/module.json5 b/features/home/src/main/module.json5 index 4748740..d734380 100755 --- a/features/home/src/main/module.json5 +++ b/features/home/src/main/module.json5 @@ -4,8 +4,7 @@ "type": "har", "deviceTypes": [ "phone", - "tablet", - "2in1" + "tablet" ] } } \ No newline at end of file diff --git a/features/socialCircle/src/main/ets/pages/Index.ets b/features/socialCircle/src/main/ets/pages/Index.ets index 8475576..109a64b 100755 --- a/features/socialCircle/src/main/ets/pages/Index.ets +++ b/features/socialCircle/src/main/ets/pages/Index.ets @@ -55,7 +55,7 @@ export struct SocialCircle { .height(BaseConstants.FULL_HEIGHT) .width(BaseConstants.FULL_WIDTH) .padding({ - top: deviceInfo.deviceType === BaseConstants.DEVICE_2IN1 ? $r('app.float.zero') : $r('app.float.device_padding_top') + top: deviceInfo.deviceType === BaseConstants.DEVICE_TABLET ? $r('app.float.zero') : $r('app.float.device_padding_top') }) } diff --git a/features/socialCircle/src/main/module.json5 b/features/socialCircle/src/main/module.json5 index e8d301a..1002c4a 100755 --- a/features/socialCircle/src/main/module.json5 +++ b/features/socialCircle/src/main/module.json5 @@ -4,8 +4,7 @@ "type": "har", "deviceTypes": [ "phone", - "tablet", - "2in1" + "tablet" ] } } \ No newline at end of file diff --git a/products/phone/build-profile.json5 b/products/phone/build-profile.json5 index 49ebe7a..883adbb 100755 --- a/products/phone/build-profile.json5 +++ b/products/phone/build-profile.json5 @@ -27,8 +27,7 @@ "config": { "deviceType": [ "phone", - "tablet", - "2in1" + "tablet" ] }, "source": { diff --git a/products/phone/src/main/ets/entryability/EntryAbility.ets b/products/phone/src/main/ets/entryability/EntryAbility.ets index 818263a..59e9d19 100755 --- a/products/phone/src/main/ets/entryability/EntryAbility.ets +++ b/products/phone/src/main/ets/entryability/EntryAbility.ets @@ -44,7 +44,7 @@ export default class EntryAbility extends UIAbility { hilog.info(0x0000, 'testTag', '%{public}s', 'getMainWindow failed'); return; } - if (deviceInfo.deviceType !== BaseConstants.DEVICE_2IN1) { + if (deviceInfo.deviceType !== BaseConstants.DEVICE_TABLET) { data.setWindowLayoutFullScreen(true); } }) diff --git a/products/phone/src/main/module.json5 b/products/phone/src/main/module.json5 index 8e3d887..756223c 100755 --- a/products/phone/src/main/module.json5 +++ b/products/phone/src/main/module.json5 @@ -6,8 +6,7 @@ "mainElement": "EntryAbility", "deviceTypes": [ "phone", - "tablet", - "2in1" + "tablet" ], "deliveryWithInstall": true, "installationFree": false, -- Gitee