diff --git a/OpenHarmony/entry/oh-package-lock.json5 b/OpenHarmony/entry/oh-package-lock.json5 index 58b063e..7a70d1f 100644 --- a/OpenHarmony/entry/oh-package-lock.json5 +++ b/OpenHarmony/entry/oh-package-lock.json5 @@ -5,15 +5,16 @@ "lockfileVersion": 3, "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", "specifiers": { - "@ohos-rs/ability@^0.0.1": "@ohos-rs/ability@0.0.1", - "libentry.so@src/main/cpp/types/libentry": "libentry.so@src/main/cpp/types/libentry" + "@ohos-rs/ability@^0.0.2": "@ohos-rs/ability@0.0.2", + "libentry.so@src/main/cpp/types/libentry": "libentry.so@src/main/cpp/types/libentry", + "libwgpu_in_app.so@src/main/cpp/types/libwgpu_in_app": "libwgpu_in_app.so@src/main/cpp/types/libwgpu_in_app" }, "packages": { - "@ohos-rs/ability@0.0.1": { + "@ohos-rs/ability@0.0.2": { "name": "@ohos-rs/ability", - "version": "0.0.1", - "integrity": "sha512-vSghUZqg18oHdH4w2yEU2GRYC6vSFXVAk1RN40Xh/HhY/TWCIyFRglJPHCxk7vQ3aTJaavGVOACjJax3E47rfw==", - "resolved": "https://repo.harmonyos.com/ohpm/@ohos-rs/ability/-/ability-0.0.1.har", + "version": "0.0.2", + "integrity": "sha512-gGlp+xkAgITSgqSM5cz8c8pyFsLIXnOJttjkJENeIZQW+NPCf/W32MkU11cQqnM/OToRyplHLa9Y1HPBFmPqBw==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos-rs/ability/-/ability-0.0.2.har", "registryType": "ohpm" }, "libentry.so@src/main/cpp/types/libentry": { @@ -21,6 +22,12 @@ "version": "1.0.0", "resolved": "src/main/cpp/types/libentry", "registryType": "local" + }, + "libwgpu_in_app.so@src/main/cpp/types/libwgpu_in_app": { + "name": "libwgpu_in_app.so", + "version": "1.0.0", + "resolved": "src/main/cpp/types/libwgpu_in_app", + "registryType": "local" } } } \ No newline at end of file diff --git a/OpenHarmony/entry/oh-package.json5 b/OpenHarmony/entry/oh-package.json5 index eec2905..812506d 100644 --- a/OpenHarmony/entry/oh-package.json5 +++ b/OpenHarmony/entry/oh-package.json5 @@ -7,7 +7,8 @@ "license": "", "dependencies": { "libentry.so": "file:./src/main/cpp/types/libentry", - "@ohos-rs/ability": "^0.0.1" + "libwgpu_in_app.so": "file:./src/main/cpp/types/libwgpu_in_app", + "@ohos-rs/ability": "^0.0.2" }, "devDependencies": {}, "dynamicDependencies": {} diff --git a/OpenHarmony/entry/src/main/cpp/types/libwgpu_in_app/Index.d.ts b/OpenHarmony/entry/src/main/cpp/types/libwgpu_in_app/Index.d.ts new file mode 100644 index 0000000..121a0e3 --- /dev/null +++ b/OpenHarmony/entry/src/main/cpp/types/libwgpu_in_app/Index.d.ts @@ -0,0 +1,25 @@ +/* auto-generated by OHOS-RS */ +/* eslint-disable */ +import { NodeContent } from "@kit.ArkUI" + +export interface ApplicationLifecycle { + environmentCallback: EnvironmentCallback + windowStageEventCallback: WindowStageEventCallback +} + +export interface EnvironmentCallback { + onConfigurationUpdated: () => void + onMemoryLevel: () => void +} + +export interface WindowStageEventCallback { + onWindowStageCreate: () => void + onWindowStageDestroy: () => void + onAbilityCreate: () => void + onAbilityDestroy: () => void + onAbilitySaveState: () => void +} + +export declare function init(slot: NodeContent): ApplicationLifecycle; + +export declare function changeRender(index: number): void \ No newline at end of file diff --git a/OpenHarmony/entry/src/main/cpp/types/libwgpu_in_app/oh-package.json5 b/OpenHarmony/entry/src/main/cpp/types/libwgpu_in_app/oh-package.json5 new file mode 100644 index 0000000..0005402 --- /dev/null +++ b/OpenHarmony/entry/src/main/cpp/types/libwgpu_in_app/oh-package.json5 @@ -0,0 +1,6 @@ +{ + "name": "libwgpu_in_app.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/OpenHarmony/entry/src/main/ets/entryability/EntryAbility.ets b/OpenHarmony/entry/src/main/ets/entryability/EntryAbility.ets index 1588a77..bc58474 100644 --- a/OpenHarmony/entry/src/main/ets/entryability/EntryAbility.ets +++ b/OpenHarmony/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,11 +1,18 @@ import { RustAbility } from '@ohos-rs/ability' import Want from '@ohos.app.ability.Want' import { AbilityConstant } from '@kit.AbilityKit'; +import window from '@ohos.window'; export default class EntryAbility extends RustAbility { public moduleName: string = "wgpu_in_app" + public defaultPage: boolean = false; async onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): Promise { super.onCreate(want, launchParam); } + + async onWindowStageCreate(windowStage: window.WindowStage): Promise { + super.onWindowStageCreate(windowStage); + await windowStage.loadContent('pages/Index'); + } } diff --git a/OpenHarmony/entry/src/main/ets/pages/Index.ets b/OpenHarmony/entry/src/main/ets/pages/Index.ets index a6aa1f5..3a89f3d 100644 --- a/OpenHarmony/entry/src/main/ets/pages/Index.ets +++ b/OpenHarmony/entry/src/main/ets/pages/Index.ets @@ -1,20 +1,29 @@ -import { hilog } from '@kit.PerformanceAnalysisKit'; -import testNapi from 'libentry.so'; +import { DefaultXComponent } from "@ohos-rs/ability" +import { ItemRestriction, SegmentButton, SegmentButtonOptions, SegmentButtonTextItem } from '@kit.ArkUI'; +import { changeRender } from "libwgpu_in_app.so" @Entry @Component struct Index { - @State message: string = 'Hello World'; + @State tabOptions: SegmentButtonOptions = SegmentButtonOptions.capsule({ + buttons: [{ text: 'boids' }, + { text: 'MSAA line' }, + { text: 'cube' }, + { text: "water" }, + { text: "shadow" }] as ItemRestriction, + backgroundBlurStyle: BlurStyle.BACKGROUND_THICK, + }) + @State @Watch("handleChange") tabSelectedIndexes: number[] = [0] + + handleChange() { + changeRender(this.tabSelectedIndexes[0]) + } build() { Row() { Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - .onClick(() => { - hilog.info(0x0000, 'testTag', 'Test NAPI 2 + 3 = %{public}d', testNapi.add(2, 3)); - }) + SegmentButton({ options: this.tabOptions, selectedIndexes: $tabSelectedIndexes }) + DefaultXComponent() } .width('100%') }