Commit aa0c52b6 authored by qq_38816927's avatar qq_38816927

arkts

parent dfd89616
......@@ -8,3 +8,6 @@ actual fun pirntSingleHiLog() {
actual fun pirntRandomHiLog() {
}
actual fun testArkTsToKotin() {
}
\ No newline at end of file
......@@ -8,3 +8,6 @@ expect fun pirntSingleHiLog();
//打印随机日志
expect fun pirntRandomHiLog();
expect fun testArkTsToKotin();
\ No newline at end of file
......@@ -9,3 +9,6 @@ actual fun pirntSingleHiLog() {
actual fun pirntRandomHiLog() {
}
actual fun testArkTsToKotin() {
}
\ No newline at end of file
package com.dong.demo013
import kotlinx.cinterop.ExperimentalForeignApi
import platform.ohos.OH_LOG_Print
import kotlin.experimental.ExperimentalNativeApi
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.experimental.ExperimentalNativeApi::class)
@CName("hiLogPrintMsg")
......@@ -47,3 +49,9 @@ actual fun pirntAllLevelHiLog(){
actual fun pirntRandomHiLog(){
hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "持续日志打印-高亮");
}
@OptIn(ExperimentalNativeApi::class, ExperimentalForeignApi::class)
@CName("testArkTsToKotin")
actual fun testArkTsToKotin() {
print("测试ArkTs至Kotlin单向跳转")
}
\ No newline at end of file
package com.dong.demo013
import kotlinx.cinterop.ExperimentalForeignApi
import platform.ohos.OH_LOG_Print
import kotlin.experimental.ExperimentalNativeApi
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.experimental.ExperimentalNativeApi::class)
@CName("hiLogPrintMsg")
......@@ -46,3 +48,9 @@ actual fun pirntAllLevelHiLog(){
actual fun pirntRandomHiLog(){
hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "持续日志打印-高亮");
}
@OptIn(ExperimentalNativeApi::class, ExperimentalForeignApi::class)
@CName("testArkTsToKotin")
actual fun testArkTsToKotin() {
print("测试ArkTs至Kotlin单向跳转")
}
\ No newline at end of file
......@@ -8,6 +8,6 @@
"dependencies": {
"libentry.so": "file:./src/main/cpp/types/libentry",
// 添加 compose.har 依赖
"compose": "file:./libs/compose.har",
"compose": "file:./libs/compose.har"
}
}
\ No newline at end of file
......@@ -205,6 +205,7 @@ extern void setPixelRatio(libkn_KDouble ratio);
extern void androidx_compose_ui_arkui_init(void* env, void* exports);
extern void* MainArkUIViewController(void* env);
extern libkn_KInt hiLogPrintMsg(libkn_KUInt type, libkn_KUInt level, libkn_KUInt domain, const char* tag, const char* message);
extern void testArkTsToKotin();
extern libkn_KInt kn_get_render_backend_id();
typedef struct {
......@@ -786,6 +787,7 @@ typedef struct {
void (*pirntAllLevelHiLog)();
void (*pirntRandomHiLog)();
void (*pirntSingleHiLog)();
void (*testArkTsToKotin_)();
} demo013;
} dong;
} com;
......
......@@ -84,6 +84,14 @@ static napi_value nativeRegisterNodeStatusModifyConstructor(napi_env env, napi_c
return nullptr;
}
static napi_value nativeTestArkTsToKotin(napi_env env, napi_callback_info info) {
testArkTsToKotin();
napi_value undefined;
napi_get_undefined(env, &undefined);
return undefined;
}
EXTERN_C_START
static napi_value Init(napi_env env, napi_value exports) {
androidx_compose_ui_arkui_init(env, exports);
......@@ -95,6 +103,7 @@ static napi_value Init(napi_env env, napi_value exports) {
{"nativeRegisterNodeConstructor", nullptr, nativeRegisterNodeConstructor, nullptr, nullptr, nullptr, napi_default, nullptr},
{"nativeRegisterNodeStatusModifyConstructor", nullptr, nativeRegisterNodeStatusModifyConstructor, nullptr, nullptr, nullptr, napi_default, nullptr },
{"nativeSetPixelRatio", nullptr, nativeSetPixelRatio, nullptr, nullptr, nullptr, napi_default, nullptr},
{"testArkTsToKotin", nullptr, nativeTestArkTsToKotin, nullptr, nullptr, nullptr, napi_default, nullptr},
};
napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
return exports;
......
import { ArkUIViewController } from "compose/src/main/cpp/types/libcompose_arkui_utils";
import { ArkUIViewController,testArkTsToKotin} from "compose/src/main/cpp/types/libcompose_arkui_utils";
export const MainArkUIViewController: () => ArkUIViewController
export const testArkTsToKotin:()=>void
......@@ -10,9 +10,9 @@ struct Index {
private controller: ArkUIViewController | undefined = undefined;
@State errorMessage: string = 'Native module not ready';
ab
aboutToAppear() {
//ArkTs生命周期断点处
if (nativeApi === undefined) {
hilog.error(DOMAIN, 'Compose', 'nativeApi is undefined, cannot create controller');
......@@ -20,6 +20,15 @@ struct Index {
return;
}
hilog.info(DOMAIN, 'Compose', 'nativeApi is ready');
nativeApi.testArkTsToKotin();
try {
this.controller = nativeApi.MainArkUIViewController();
const state = this.controller ? 'created' : 'not_created';
......@@ -33,6 +42,14 @@ struct Index {
}
}
// 模拟耗时操作
private loadData() {
for (let i = 0; i < 10000; i++) {
// 模拟数据处理
let temp = i * i;
}
}
build() {
Column() {
if (this.controller) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment