From 1f9183546679a555d0a4122b23fa3535cdd14a5c Mon Sep 17 00:00:00 2001 From: "OWNEROR-41FNVD0\\lenovo" Date: Sat, 24 May 2025 14:40:46 +0800 Subject: [PATCH 1/5] =?UTF-8?q?componentPrebuildByOnIdle=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customreusablepool/build-profile.json5 | 25 ++++++ .../customreusablepool/oh-package.json5 | 2 +- .../main/ets/entryability/EntryAbility.ets | 80 +++++++++++++++++++ .../src/main/ets/view/SecureRandom.ets | 11 +++ .../src/main/ets/view/TabNode.ets | 1 + .../entry/src/main/module.json5 | 2 +- 6 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/build-profile.json5 create mode 100644 GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/entryability/EntryAbility.ets create mode 100644 GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/view/SecureRandom.ets diff --git a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/build-profile.json5 b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/build-profile.json5 new file mode 100644 index 00000000..0311b505 --- /dev/null +++ b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/build-profile.json5 @@ -0,0 +1,25 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + } + ] +} \ No newline at end of file diff --git a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/oh-package.json5 b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/oh-package.json5 index de407df4..2e1631d4 100644 --- a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/oh-package.json5 +++ b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/oh-package.json5 @@ -2,7 +2,7 @@ "name": "customreusablepool", "version": "1.0.0", "description": "Please describe the basic information.", - "main": "Index.ets", + "main": "", "author": "", "license": "Apache-2.0", "packageType": "InterfaceHar", diff --git a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/entryability/EntryAbility.ets b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 00000000..73af86a9 --- /dev/null +++ b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,80 @@ +/* + * 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 { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { WindowUtil } from '../common/utils/WindowUtil'; + +export default class EntryAbility extends UIAbility { + private windowObj?: window.Window; + private windowUtil?: WindowUtil = WindowUtil.getInstance(); + private onWindowSizeChange: (windowSize: window.Size) => void = (windowSize: window.Size) => { + this.windowUtil!.updateHeightBp(); + this.windowUtil!.updateWidthBp(); + AppStorage.setOrCreate('windowWidth', windowSize.width); + } + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + this.windowUtil!.setWindowStage(windowStage); + + windowStage.getMainWindow().then((data: window.Window) => { + if (data === undefined) { + return; + } + this.windowObj = data; + this.windowUtil!.updateWidthBp(); + this.windowUtil!.updateHeightBp(); + AppStorage.setOrCreate('windowWidth', data.getWindowProperties().windowRect.width); + this.windowObj.on('windowSizeChange', this.onWindowSizeChange); + }) + + 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; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + let uiContext: UIContext | undefined = windowStage.getMainWindowSync().getUIContext() + AppStorage.setOrCreate('uiContext', uiContext); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/view/SecureRandom.ets b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/view/SecureRandom.ets new file mode 100644 index 00000000..3c65942c --- /dev/null +++ b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/view/SecureRandom.ets @@ -0,0 +1,11 @@ + + +export class SecureRandom { + int: number = 0 + constructor() { + this.int = 1 + } + nextInt(int: number): number { + return int + 1 + } +} \ No newline at end of file diff --git a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/view/TabNode.ets b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/view/TabNode.ets index b893cb54..2ecd766f 100644 --- a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/view/TabNode.ets +++ b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/view/TabNode.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +import { SecureRandom } from '../view/SecureRandom' // [Start flow_item_node] import { flowItemBuilder, FlowItemNode } from './FlowItemNode'; import { ViewItem } from '../data/ViewItem'; diff --git a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/entry/src/main/module.json5 b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/entry/src/main/module.json5 index c076329c..b3fc1a84 100644 --- a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/entry/src/main/module.json5 +++ b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/entry/src/main/module.json5 @@ -37,7 +37,7 @@ "extensionAbilities": [ { "name": "EntryBackupAbility", - "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "srcEntry": "./ets/entryability/EntryAbility.ets", "type": "backup", "exported": false, "metadata": [ -- Gitee From f1b68285b91657cc86bbbb099376c329d500f8f5 Mon Sep 17 00:00:00 2001 From: "OWNEROR-41FNVD0\\lenovo" Date: Sat, 24 May 2025 15:51:27 +0800 Subject: [PATCH 2/5] =?UTF-8?q?customReusablePool=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customreusablepool/oh-package.json5 | 2 +- .../main/ets/entryability/EntryAbility.ets | 44 +++++++++++++++++++ .../src/main/ets/view/SecureRandom.ets | 11 +++++ .../src/main/ets/view/TabNode.ets | 2 +- .../entry/src/main/module.json5 | 2 +- 5 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/entryability/EntryAbility.ets create mode 100644 GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/view/SecureRandom.ets diff --git a/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/oh-package.json5 b/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/oh-package.json5 index de407df4..2e1631d4 100644 --- a/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/oh-package.json5 +++ b/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/oh-package.json5 @@ -2,7 +2,7 @@ "name": "customreusablepool", "version": "1.0.0", "description": "Please describe the basic information.", - "main": "Index.ets", + "main": "", "author": "", "license": "Apache-2.0", "packageType": "InterfaceHar", diff --git a/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/entryability/EntryAbility.ets b/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 00000000..8c0cad41 --- /dev/null +++ b/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,44 @@ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class PrivacyAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/view/SecureRandom.ets b/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/view/SecureRandom.ets new file mode 100644 index 00000000..3c65942c --- /dev/null +++ b/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/view/SecureRandom.ets @@ -0,0 +1,11 @@ + + +export class SecureRandom { + int: number = 0 + constructor() { + this.int = 1 + } + nextInt(int: number): number { + return int + 1 + } +} \ No newline at end of file diff --git a/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/view/TabNode.ets b/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/view/TabNode.ets index bb9a2576..7328979f 100644 --- a/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/view/TabNode.ets +++ b/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/view/TabNode.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +import { SecureRandom } from '../view/SecureRandom' import { flowItemBuilder, FlowItemNode } from './FlowItemNode'; import { ViewItem } from '../data/ViewItem'; import { WaterFlowDataSource } from '../data/WaterFlowDataSource'; diff --git a/GlobalCustomComponentReuse/ComponentPrebuild/entry/src/main/module.json5 b/GlobalCustomComponentReuse/ComponentPrebuild/entry/src/main/module.json5 index c076329c..b3fc1a84 100644 --- a/GlobalCustomComponentReuse/ComponentPrebuild/entry/src/main/module.json5 +++ b/GlobalCustomComponentReuse/ComponentPrebuild/entry/src/main/module.json5 @@ -37,7 +37,7 @@ "extensionAbilities": [ { "name": "EntryBackupAbility", - "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "srcEntry": "./ets/entryability/EntryAbility.ets", "type": "backup", "exported": false, "metadata": [ -- Gitee From 580e2ecfda81737c3d2ae5b2b67ceb9ee4eed137 Mon Sep 17 00:00:00 2001 From: "OWNEROR-41FNVD0\\lenovo" Date: Sat, 24 May 2025 16:07:55 +0800 Subject: [PATCH 3/5] =?UTF-8?q?RationalUseOfFrontEndResources=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B=E6=8A=A5=E9=94=99=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entry/src/main/cpp/CMakeLists.txt | 15 ++++++ .../entry/src/main/cpp/napi_init.cpp | 53 +++++++++++++++++++ .../src/main/cpp/types/libentry/index.d.ts | 1 + .../main/cpp/types/libentry/oh-package.json5 | 6 +++ .../entry/src/main/ets/pages/Index.ets | 23 ++++++++ .../resources/base/profile/main_pages.json | 1 + .../entry/src/mock/mock-config.json5 | 2 - .../src/ohosTest/ets/test/Ability.test.ets | 35 ------------ .../entry/src/ohosTest/ets/test/List.test.ets | 5 -- .../entry/src/ohosTest/module.json5 | 13 ----- .../entry/src/test/List.test.ets | 5 -- .../entry/src/test/LocalUnit.test.ets | 33 ------------ 12 files changed, 99 insertions(+), 93 deletions(-) create mode 100644 RationalUseOfFrontEndResources/entry/src/main/cpp/CMakeLists.txt create mode 100644 RationalUseOfFrontEndResources/entry/src/main/cpp/napi_init.cpp create mode 100644 RationalUseOfFrontEndResources/entry/src/main/cpp/types/libentry/index.d.ts create mode 100644 RationalUseOfFrontEndResources/entry/src/main/cpp/types/libentry/oh-package.json5 create mode 100644 RationalUseOfFrontEndResources/entry/src/main/ets/pages/Index.ets delete mode 100644 RationalUseOfFrontEndResources/entry/src/mock/mock-config.json5 delete mode 100644 RationalUseOfFrontEndResources/entry/src/ohosTest/ets/test/Ability.test.ets delete mode 100644 RationalUseOfFrontEndResources/entry/src/ohosTest/ets/test/List.test.ets delete mode 100644 RationalUseOfFrontEndResources/entry/src/ohosTest/module.json5 delete mode 100644 RationalUseOfFrontEndResources/entry/src/test/List.test.ets delete mode 100644 RationalUseOfFrontEndResources/entry/src/test/LocalUnit.test.ets diff --git a/RationalUseOfFrontEndResources/entry/src/main/cpp/CMakeLists.txt b/RationalUseOfFrontEndResources/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 00000000..1acd3ec1 --- /dev/null +++ b/RationalUseOfFrontEndResources/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,15 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(CppCrash) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/RationalUseOfFrontEndResources/entry/src/main/cpp/napi_init.cpp b/RationalUseOfFrontEndResources/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 00000000..85330e3e --- /dev/null +++ b/RationalUseOfFrontEndResources/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,53 @@ +#include "napi/native_api.h" + +static napi_value Add(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + + napi_get_cb_info(env, info, &argc, args , nullptr, nullptr); + + napi_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; + +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/RationalUseOfFrontEndResources/entry/src/main/cpp/types/libentry/index.d.ts b/RationalUseOfFrontEndResources/entry/src/main/cpp/types/libentry/index.d.ts new file mode 100644 index 00000000..e44f3615 --- /dev/null +++ b/RationalUseOfFrontEndResources/entry/src/main/cpp/types/libentry/index.d.ts @@ -0,0 +1 @@ +export const add: (a: number, b: number) => number; \ No newline at end of file diff --git a/RationalUseOfFrontEndResources/entry/src/main/cpp/types/libentry/oh-package.json5 b/RationalUseOfFrontEndResources/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 00000000..17f2fec2 --- /dev/null +++ b/RationalUseOfFrontEndResources/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -0,0 +1,6 @@ +{ + "name": "libentry.so", + "types": "./index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/RationalUseOfFrontEndResources/entry/src/main/ets/pages/Index.ets b/RationalUseOfFrontEndResources/entry/src/main/ets/pages/Index.ets new file mode 100644 index 00000000..8e2d24ad --- /dev/null +++ b/RationalUseOfFrontEndResources/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,23 @@ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/RationalUseOfFrontEndResources/entry/src/main/resources/base/profile/main_pages.json b/RationalUseOfFrontEndResources/entry/src/main/resources/base/profile/main_pages.json index 1612af3c..1898d94f 100644 --- a/RationalUseOfFrontEndResources/entry/src/main/resources/base/profile/main_pages.json +++ b/RationalUseOfFrontEndResources/entry/src/main/resources/base/profile/main_pages.json @@ -1,4 +1,5 @@ { "src": [ + "pages/Index" ] } diff --git a/RationalUseOfFrontEndResources/entry/src/mock/mock-config.json5 b/RationalUseOfFrontEndResources/entry/src/mock/mock-config.json5 deleted file mode 100644 index 7a73a41b..00000000 --- a/RationalUseOfFrontEndResources/entry/src/mock/mock-config.json5 +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/RationalUseOfFrontEndResources/entry/src/ohosTest/ets/test/Ability.test.ets b/RationalUseOfFrontEndResources/entry/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100644 index 85c78f67..00000000 --- a/RationalUseOfFrontEndResources/entry/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,35 +0,0 @@ -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; - -export default function abilityTest() { - describe('ActsAbilityTest', () => { - // Defines a test suite. Two parameters are supported: test suite name and test suite function. - beforeAll(() => { - // Presets an action, which is performed only once before all test cases of the test suite start. - // This API supports only one parameter: preset action function. - }) - beforeEach(() => { - // Presets an action, which is performed before each unit test case starts. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: preset action function. - }) - afterEach(() => { - // Presets a clear action, which is performed after each unit test case ends. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: clear action function. - }) - afterAll(() => { - // Presets a clear action, which is performed after all test cases of the test suite end. - // This API supports only one parameter: clear action function. - }) - it('assertContain', 0, () => { - // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. - hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); - let a = 'abc'; - let b = 'b'; - // Defines a variety of assertion methods, which are used to declare expected boolean conditions. - expect(a).assertContain(b); - expect(a).assertEqual(a); - }) - }) -} \ No newline at end of file diff --git a/RationalUseOfFrontEndResources/entry/src/ohosTest/ets/test/List.test.ets b/RationalUseOfFrontEndResources/entry/src/ohosTest/ets/test/List.test.ets deleted file mode 100644 index 794c7dc4..00000000 --- a/RationalUseOfFrontEndResources/entry/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/RationalUseOfFrontEndResources/entry/src/ohosTest/module.json5 b/RationalUseOfFrontEndResources/entry/src/ohosTest/module.json5 deleted file mode 100644 index 55725a92..00000000 --- a/RationalUseOfFrontEndResources/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/RationalUseOfFrontEndResources/entry/src/test/List.test.ets b/RationalUseOfFrontEndResources/entry/src/test/List.test.ets deleted file mode 100644 index bb5b5c37..00000000 --- a/RationalUseOfFrontEndResources/entry/src/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import localUnitTest from './LocalUnit.test'; - -export default function testsuite() { - localUnitTest(); -} \ No newline at end of file diff --git a/RationalUseOfFrontEndResources/entry/src/test/LocalUnit.test.ets b/RationalUseOfFrontEndResources/entry/src/test/LocalUnit.test.ets deleted file mode 100644 index 165fc161..00000000 --- a/RationalUseOfFrontEndResources/entry/src/test/LocalUnit.test.ets +++ /dev/null @@ -1,33 +0,0 @@ -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; - -export default function localUnitTest() { - describe('localUnitTest', () => { - // Defines a test suite. Two parameters are supported: test suite name and test suite function. - beforeAll(() => { - // Presets an action, which is performed only once before all test cases of the test suite start. - // This API supports only one parameter: preset action function. - }); - beforeEach(() => { - // Presets an action, which is performed before each unit test case starts. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: preset action function. - }); - afterEach(() => { - // Presets a clear action, which is performed after each unit test case ends. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: clear action function. - }); - afterAll(() => { - // Presets a clear action, which is performed after all test cases of the test suite end. - // This API supports only one parameter: clear action function. - }); - it('assertContain', 0, () => { - // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. - let a = 'abc'; - let b = 'b'; - // Defines a variety of assertion methods, which are used to declare expected boolean conditions. - expect(a).assertContain(b); - expect(a).assertEqual(a); - }); - }); -} \ No newline at end of file -- Gitee From 15212e44d52df55f2d22d6759b01c0f0581d3dba Mon Sep 17 00:00:00 2001 From: "OWNEROR-41FNVD0\\lenovo" Date: Sat, 24 May 2025 19:00:36 +0800 Subject: [PATCH 4/5] =?UTF-8?q?componentPrebuildByOnIdle=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customreusablepool/Index.ets | 1 + .../customreusablepool/oh-package.json5 | 2 +- .../src/main/ets/components/MainPage.ets | 18 ++++++++++++++++++ .../src/main/ets/entryability/EntryAbility.ets | 13 +------------ .../main/resources/base/element/string.json | 3 +++ 5 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/Index.ets create mode 100644 GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/components/MainPage.ets diff --git a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/Index.ets b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/Index.ets new file mode 100644 index 00000000..42bf4161 --- /dev/null +++ b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/Index.ets @@ -0,0 +1 @@ +export { MainPage } from './src/main/ets/components/MainPage'; diff --git a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/oh-package.json5 b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/oh-package.json5 index 2e1631d4..de407df4 100644 --- a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/oh-package.json5 +++ b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/oh-package.json5 @@ -2,7 +2,7 @@ "name": "customreusablepool", "version": "1.0.0", "description": "Please describe the basic information.", - "main": "", + "main": "Index.ets", "author": "", "license": "Apache-2.0", "packageType": "InterfaceHar", diff --git a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/components/MainPage.ets b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/components/MainPage.ets new file mode 100644 index 00000000..8e526db6 --- /dev/null +++ b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/components/MainPage.ets @@ -0,0 +1,18 @@ +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/entryability/EntryAbility.ets b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/entryability/EntryAbility.ets index 73af86a9..dc54eaa6 100644 --- a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/entryability/EntryAbility.ets +++ b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/ets/entryability/EntryAbility.ets @@ -16,15 +16,10 @@ import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; import { window } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { WindowUtil } from '../common/utils/WindowUtil'; export default class EntryAbility extends UIAbility { - private windowObj?: window.Window; - private windowUtil?: WindowUtil = WindowUtil.getInstance(); private onWindowSizeChange: (windowSize: window.Size) => void = (windowSize: window.Size) => { - this.windowUtil!.updateHeightBp(); - this.windowUtil!.updateWidthBp(); - AppStorage.setOrCreate('windowWidth', windowSize.width); + } onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { @@ -39,17 +34,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'); - this.windowUtil!.setWindowStage(windowStage); windowStage.getMainWindow().then((data: window.Window) => { if (data === undefined) { return; } - this.windowObj = data; - this.windowUtil!.updateWidthBp(); - this.windowUtil!.updateHeightBp(); - AppStorage.setOrCreate('windowWidth', data.getWindowProperties().windowRect.width); - this.windowObj.on('windowSizeChange', this.onWindowSizeChange); }) windowStage.loadContent('pages/Index', (err, data) => { diff --git a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/resources/base/element/string.json b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/resources/base/element/string.json index c161518b..1a4024c3 100644 --- a/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/resources/base/element/string.json +++ b/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/customreusablepool/src/main/resources/base/element/string.json @@ -15,6 +15,9 @@ },{ "name": "customreusablepool_water_flow_background_color", "value": "#FAEEE0" + },{ + "name": "shared_desc", + "value": "file" } ] } \ No newline at end of file -- Gitee From c55f35ab3242518d48aa3b4c57ab66708e25ed52 Mon Sep 17 00:00:00 2001 From: "OWNEROR-41FNVD0\\lenovo" Date: Sat, 24 May 2025 19:05:52 +0800 Subject: [PATCH 5/5] =?UTF-8?q?customReusablePool=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customreusablepool/Index.ets | 1 + .../src/main/ets/components/MainPage.ets | 18 ++++++++++++++++++ .../main/resources/base/element/string.json | 3 +++ 3 files changed, 22 insertions(+) create mode 100644 GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/Index.ets create mode 100644 GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/components/MainPage.ets diff --git a/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/Index.ets b/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/Index.ets new file mode 100644 index 00000000..42bf4161 --- /dev/null +++ b/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/Index.ets @@ -0,0 +1 @@ +export { MainPage } from './src/main/ets/components/MainPage'; diff --git a/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/components/MainPage.ets b/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/components/MainPage.ets new file mode 100644 index 00000000..8e526db6 --- /dev/null +++ b/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/components/MainPage.ets @@ -0,0 +1,18 @@ +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/resources/base/element/string.json b/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/resources/base/element/string.json index c161518b..c1422ec6 100644 --- a/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/resources/base/element/string.json +++ b/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/resources/base/element/string.json @@ -15,6 +15,9 @@ },{ "name": "customreusablepool_water_flow_background_color", "value": "#FAEEE0" + },{ + "name": "shared_desc", + "value": "ff" } ] } \ No newline at end of file -- Gitee