From f1b68285b91657cc86bbbb099376c329d500f8f5 Mon Sep 17 00:00:00 2001 From: "OWNEROR-41FNVD0\\lenovo" Date: Sat, 24 May 2025 15:51:27 +0800 Subject: [PATCH 1/2] =?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 c55f35ab3242518d48aa3b4c57ab66708e25ed52 Mon Sep 17 00:00:00 2001 From: "OWNEROR-41FNVD0\\lenovo" Date: Sat, 24 May 2025 19:05:52 +0800 Subject: [PATCH 2/2] =?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