From 47241e6debeaebab38e10f15f6f871755c8b6529 Mon Sep 17 00:00:00 2001 From: lon9 <815882449@qq.com> Date: Wed, 24 Jul 2024 16:01:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E5=A4=9A=E5=8D=B3=E6=97=B6=E9=80=9A?= =?UTF-8?q?=E8=AE=AF=E6=9E=B6=E6=9E=84=E5=92=8C=E6=8E=A5=E5=8F=A3=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 0 bytes LICENSE | 78 ------------------ README.md | 6 -- common/base/hvigorfile.ts | 4 +- common/base/src/main/ets/pages/Index.ets | 25 ------ common/base/src/main/module.json5 | 7 +- features/home/hvigorfile.ts | 4 +- features/home/src/main/module.json5 | 7 +- features/socialCircle/hvigorfile.ts | 4 +- features/socialCircle/src/main/module.json5 | 7 +- oh-package.json5 | 1 - .../main/ets/entryability/EntryAbility.ets | 24 +++++- 12 files changed, 34 insertions(+), 133 deletions(-) delete mode 100644 .DS_Store delete mode 100644 LICENSE delete mode 100755 common/base/src/main/ets/pages/Index.ets diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 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/common/base/hvigorfile.ts b/common/base/hvigorfile.ts index 64fa6f9..436f2ee 100755 --- a/common/base/hvigorfile.ts +++ b/common/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/common/base/src/main/ets/pages/Index.ets b/common/base/src/main/ets/pages/Index.ets deleted file mode 100755 index fa1e3f6..0000000 --- a/common/base/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 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 { StandardIcon } from '../views/image/StandardIcon'; - -@Entry -@Component -struct Index { - build() { - Column() { - StandardIcon({ icon: $r("app.media.app_icon") }) - } - } -} \ No newline at end of file diff --git a/common/base/src/main/module.json5 b/common/base/src/main/module.json5 index 0e0f4fe..169b18e 100755 --- a/common/base/src/main/module.json5 +++ b/common/base/src/main/module.json5 @@ -1,14 +1,11 @@ { "module": { "name": "base", - "type": "shared", - "description": "$string:shared_desc", + "type": "har", "deviceTypes": [ "phone", "tablet", "2in1" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" + ] } } \ No newline at end of file diff --git a/features/home/hvigorfile.ts b/features/home/hvigorfile.ts index 64fa6f9..436f2ee 100755 --- 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/module.json5 b/features/home/src/main/module.json5 index 9e3688b..4748740 100755 --- a/features/home/src/main/module.json5 +++ b/features/home/src/main/module.json5 @@ -1,14 +1,11 @@ { "module": { "name": "home", - "type": "shared", - "description": "$string:shared_desc", + "type": "har", "deviceTypes": [ "phone", "tablet", "2in1" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" + ] } } \ No newline at end of file diff --git a/features/socialCircle/hvigorfile.ts b/features/socialCircle/hvigorfile.ts index 64fa6f9..436f2ee 100755 --- a/features/socialCircle/hvigorfile.ts +++ b/features/socialCircle/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/socialCircle/src/main/module.json5 b/features/socialCircle/src/main/module.json5 index b60959b..e8d301a 100755 --- a/features/socialCircle/src/main/module.json5 +++ b/features/socialCircle/src/main/module.json5 @@ -1,14 +1,11 @@ { "module": { "name": "socialCircle", - "type": "shared", - "description": "$string:shared_desc", + "type": "har", "deviceTypes": [ "phone", "tablet", "2in1" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" + ] } } \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 index c7a24fc..d7bfa36 100755 --- a/oh-package.json5 +++ b/oh-package.json5 @@ -2,7 +2,6 @@ "modelVersion": "5.0.0", "license": "", "devDependencies": { - "@ohos/hypium": "1.0.15" }, "author": "", "name": "MultiDeviceCommunication", diff --git a/products/phone/src/main/ets/entryability/EntryAbility.ets b/products/phone/src/main/ets/entryability/EntryAbility.ets index 6a215df..9f226fc 100755 --- a/products/phone/src/main/ets/entryability/EntryAbility.ets +++ b/products/phone/src/main/ets/entryability/EntryAbility.ets @@ -15,12 +15,14 @@ import { UIAbility } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { KeyboardAvoidMode, window } from '@kit.ArkUI'; +import { display, KeyboardAvoidMode, window } from '@kit.ArkUI'; import { BusinessError } from '@kit.BasicServicesKit'; -import { BaseConstants } from '@ohos/base/Index'; +import { BaseConstants, BreakpointConstants } from '@ohos/base/Index'; import { deviceInfo } from '@kit.BasicServicesKit'; export default class EntryAbility extends UIAbility { + private windowObj?: window.Window; + onCreate(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); } @@ -33,6 +35,11 @@ export default class EntryAbility extends UIAbility { // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); windowStage.getMainWindow((err: BusinessError, data) => { + this.windowObj = data; + this.updateBreakpoint(this.windowObj.getWindowProperties().windowRect.width); + this.windowObj.on('windowSizeChange', (windowSize: window.Size) => { + this.updateBreakpoint(windowSize.width); + }) if (err.code) { hilog.info(0x0000, 'testTag', '%{public}s', 'getMainWindow failed'); return; @@ -53,6 +60,19 @@ export default class EntryAbility extends UIAbility { }); } + private updateBreakpoint(windowWidth: number): void { + let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; + let curBp: string = ''; + if (windowWidthVp < BreakpointConstants.BREAKPOINT_SCOPE[1]) { + curBp = BreakpointConstants.BREAKPOINT_SM; + } else if (windowWidthVp < BreakpointConstants.BREAKPOINT_SCOPE[2]) { + curBp = BreakpointConstants.BREAKPOINT_MD; + } else { + curBp = BreakpointConstants.BREAKPOINT_LG; + } + AppStorage.setOrCreate('currentBreakpoint', curBp); + } + onWindowStageDestroy(): void { // Main window is destroyed, release UI related resources hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); -- Gitee