Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
TestToolChainDemo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
dsq
TestToolChainDemo
Commits
aa0c52b6
Commit
aa0c52b6
authored
Apr 01, 2026
by
qq_38816927
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
arkts
parent
dfd89616
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
59 additions
and
4 deletions
+59
-4
TestLog.android.kt
...rc/androidMain/kotlin/com.dong.demo013/TestLog.android.kt
+3
-0
TestLog.kt
composeApp/src/commonMain/kotlin/com.dong.demo013/TestLog.kt
+4
-1
TestLog.ios.kt
...oseApp/src/iosMain/kotlin/com.dong.demo013/TestLog.ios.kt
+3
-0
TestLog.ohosArm64.kt
...hosArm64Main/kotlin/com.dong.demo013/TestLog.ohosArm64.kt
+8
-0
TestLog.ohosX64.kt
...rc/ohosX64Main/kotlin/com.dong/demo013/TestLog.ohosX64.kt
+8
-0
oh-package.json5
harmonyApp/entry/oh-package.json5
+1
-1
libkn_api.h
harmonyApp/entry/src/main/cpp/include/libkn_api.h
+2
-0
napi_init.cpp
harmonyApp/entry/src/main/cpp/napi_init.cpp
+9
-0
Index.d.ts
harmonyApp/entry/src/main/cpp/types/libentry/Index.d.ts
+3
-1
Index.ets
harmonyApp/entry/src/main/ets/pages/Index.ets
+18
-1
No files found.
composeApp/src/androidMain/kotlin/com.dong.demo013/TestLog.android.kt
View file @
aa0c52b6
...
@@ -8,3 +8,6 @@ actual fun pirntSingleHiLog() {
...
@@ -8,3 +8,6 @@ actual fun pirntSingleHiLog() {
actual
fun
pirntRandomHiLog
()
{
actual
fun
pirntRandomHiLog
()
{
}
}
actual
fun
testArkTsToKotin
()
{
}
\ No newline at end of file
composeApp/src/commonMain/kotlin/com.dong.demo013/TestLog.kt
View file @
aa0c52b6
...
@@ -8,3 +8,6 @@ expect fun pirntSingleHiLog();
...
@@ -8,3 +8,6 @@ expect fun pirntSingleHiLog();
//打印随机日志
//打印随机日志
expect
fun
pirntRandomHiLog
();
expect
fun
pirntRandomHiLog
();
expect
fun
testArkTsToKotin
();
\ No newline at end of file
composeApp/src/iosMain/kotlin/com.dong.demo013/TestLog.ios.kt
View file @
aa0c52b6
...
@@ -9,3 +9,6 @@ actual fun pirntSingleHiLog() {
...
@@ -9,3 +9,6 @@ actual fun pirntSingleHiLog() {
actual
fun
pirntRandomHiLog
()
{
actual
fun
pirntRandomHiLog
()
{
}
}
actual
fun
testArkTsToKotin
()
{
}
\ No newline at end of file
composeApp/src/ohosArm64Main/kotlin/com.dong.demo013/TestLog.ohosArm64.kt
View file @
aa0c52b6
package
com.dong.demo013
package
com.dong.demo013
import
kotlinx.cinterop.ExperimentalForeignApi
import
platform.ohos.OH_LOG_Print
import
platform.ohos.OH_LOG_Print
import
kotlin.experimental.ExperimentalNativeApi
@OptIn
(
kotlinx
.
cinterop
.
ExperimentalForeignApi
::
class
,
kotlin
.
experimental
.
ExperimentalNativeApi
::
class
)
@OptIn
(
kotlinx
.
cinterop
.
ExperimentalForeignApi
::
class
,
kotlin
.
experimental
.
ExperimentalNativeApi
::
class
)
@CName
(
"hiLogPrintMsg"
)
@CName
(
"hiLogPrintMsg"
)
...
@@ -47,3 +49,9 @@ actual fun pirntAllLevelHiLog(){
...
@@ -47,3 +49,9 @@ actual fun pirntAllLevelHiLog(){
actual
fun
pirntRandomHiLog
(){
actual
fun
pirntRandomHiLog
(){
hiLogPrintMsg
(
0
u
,
6
u
,
4660
u
,
"TestTag"
,
"持续日志打印-高亮"
);
hiLogPrintMsg
(
0
u
,
6
u
,
4660
u
,
"TestTag"
,
"持续日志打印-高亮"
);
}
}
@OptIn
(
ExperimentalNativeApi
::
class
,
ExperimentalForeignApi
::
class
)
@CName
(
"testArkTsToKotin"
)
actual
fun
testArkTsToKotin
()
{
print
(
"测试ArkTs至Kotlin单向跳转"
)
}
\ No newline at end of file
composeApp/src/ohosX64Main/kotlin/com.dong/demo013/TestLog.ohosX64.kt
View file @
aa0c52b6
package
com.dong.demo013
package
com.dong.demo013
import
kotlinx.cinterop.ExperimentalForeignApi
import
platform.ohos.OH_LOG_Print
import
platform.ohos.OH_LOG_Print
import
kotlin.experimental.ExperimentalNativeApi
@OptIn
(
kotlinx
.
cinterop
.
ExperimentalForeignApi
::
class
,
kotlin
.
experimental
.
ExperimentalNativeApi
::
class
)
@OptIn
(
kotlinx
.
cinterop
.
ExperimentalForeignApi
::
class
,
kotlin
.
experimental
.
ExperimentalNativeApi
::
class
)
@CName
(
"hiLogPrintMsg"
)
@CName
(
"hiLogPrintMsg"
)
...
@@ -46,3 +48,9 @@ actual fun pirntAllLevelHiLog(){
...
@@ -46,3 +48,9 @@ actual fun pirntAllLevelHiLog(){
actual
fun
pirntRandomHiLog
(){
actual
fun
pirntRandomHiLog
(){
hiLogPrintMsg
(
0
u
,
6
u
,
4660
u
,
"TestTag"
,
"持续日志打印-高亮"
);
hiLogPrintMsg
(
0
u
,
6
u
,
4660
u
,
"TestTag"
,
"持续日志打印-高亮"
);
}
}
@OptIn
(
ExperimentalNativeApi
::
class
,
ExperimentalForeignApi
::
class
)
@CName
(
"testArkTsToKotin"
)
actual
fun
testArkTsToKotin
()
{
print
(
"测试ArkTs至Kotlin单向跳转"
)
}
\ No newline at end of file
harmonyApp/entry/oh-package.json5
View file @
aa0c52b6
...
@@ -8,6 +8,6 @@
...
@@ -8,6 +8,6 @@
"dependencies": {
"dependencies": {
"libentry.so": "file:./src/main/cpp/types/libentry",
"libentry.so": "file:./src/main/cpp/types/libentry",
// 添加 compose.har 依赖
// 添加 compose.har 依赖
"compose": "file:./libs/compose.har"
,
"compose": "file:./libs/compose.har"
}
}
}
}
\ No newline at end of file
harmonyApp/entry/src/main/cpp/include/libkn_api.h
View file @
aa0c52b6
...
@@ -205,6 +205,7 @@ extern void setPixelRatio(libkn_KDouble ratio);
...
@@ -205,6 +205,7 @@ extern void setPixelRatio(libkn_KDouble ratio);
extern
void
androidx_compose_ui_arkui_init
(
void
*
env
,
void
*
exports
);
extern
void
androidx_compose_ui_arkui_init
(
void
*
env
,
void
*
exports
);
extern
void
*
MainArkUIViewController
(
void
*
env
);
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
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
();
extern
libkn_KInt
kn_get_render_backend_id
();
typedef
struct
{
typedef
struct
{
...
@@ -786,6 +787,7 @@ typedef struct {
...
@@ -786,6 +787,7 @@ typedef struct {
void
(
*
pirntAllLevelHiLog
)();
void
(
*
pirntAllLevelHiLog
)();
void
(
*
pirntRandomHiLog
)();
void
(
*
pirntRandomHiLog
)();
void
(
*
pirntSingleHiLog
)();
void
(
*
pirntSingleHiLog
)();
void
(
*
testArkTsToKotin_
)();
}
demo013
;
}
demo013
;
}
dong
;
}
dong
;
}
com
;
}
com
;
...
...
harmonyApp/entry/src/main/cpp/napi_init.cpp
View file @
aa0c52b6
...
@@ -84,6 +84,14 @@ static napi_value nativeRegisterNodeStatusModifyConstructor(napi_env env, napi_c
...
@@ -84,6 +84,14 @@ static napi_value nativeRegisterNodeStatusModifyConstructor(napi_env env, napi_c
return
nullptr
;
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
EXTERN_C_START
static
napi_value
Init
(
napi_env
env
,
napi_value
exports
)
{
static
napi_value
Init
(
napi_env
env
,
napi_value
exports
)
{
androidx_compose_ui_arkui_init
(
env
,
exports
);
androidx_compose_ui_arkui_init
(
env
,
exports
);
...
@@ -95,6 +103,7 @@ static napi_value Init(napi_env env, napi_value exports) {
...
@@ -95,6 +103,7 @@ static napi_value Init(napi_env env, napi_value exports) {
{
"nativeRegisterNodeConstructor"
,
nullptr
,
nativeRegisterNodeConstructor
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"nativeRegisterNodeConstructor"
,
nullptr
,
nativeRegisterNodeConstructor
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"nativeRegisterNodeStatusModifyConstructor"
,
nullptr
,
nativeRegisterNodeStatusModifyConstructor
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"nativeRegisterNodeStatusModifyConstructor"
,
nullptr
,
nativeRegisterNodeStatusModifyConstructor
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"nativeSetPixelRatio"
,
nullptr
,
nativeSetPixelRatio
,
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
);
napi_define_properties
(
env
,
exports
,
sizeof
(
desc
)
/
sizeof
(
desc
[
0
]),
desc
);
return
exports
;
return
exports
;
...
...
harmonyApp/entry/src/main/cpp/types/libentry/Index.d.ts
View file @
aa0c52b6
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
MainArkUIViewController
:
()
=>
ArkUIViewController
export
const
testArkTsToKotin
:()
=>
void
harmonyApp/entry/src/main/ets/pages/Index.ets
View file @
aa0c52b6
...
@@ -10,9 +10,9 @@ struct Index {
...
@@ -10,9 +10,9 @@ struct Index {
private controller: ArkUIViewController | undefined = undefined;
private controller: ArkUIViewController | undefined = undefined;
@State errorMessage: string = 'Native module not ready';
@State errorMessage: string = 'Native module not ready';
ab
aboutToAppear() {
aboutToAppear() {
//ArkTs生命周期断点处
//ArkTs生命周期断点处
if (nativeApi === undefined) {
if (nativeApi === undefined) {
hilog.error(DOMAIN, 'Compose', 'nativeApi is undefined, cannot create controller');
hilog.error(DOMAIN, 'Compose', 'nativeApi is undefined, cannot create controller');
...
@@ -20,6 +20,15 @@ struct Index {
...
@@ -20,6 +20,15 @@ struct Index {
return;
return;
}
}
hilog.info(DOMAIN, 'Compose', 'nativeApi is ready');
nativeApi.testArkTsToKotin();
try {
try {
this.controller = nativeApi.MainArkUIViewController();
this.controller = nativeApi.MainArkUIViewController();
const state = this.controller ? 'created' : 'not_created';
const state = this.controller ? 'created' : 'not_created';
...
@@ -33,6 +42,14 @@ struct Index {
...
@@ -33,6 +42,14 @@ struct Index {
}
}
}
}
// 模拟耗时操作
private loadData() {
for (let i = 0; i < 10000; i++) {
// 模拟数据处理
let temp = i * i;
}
}
build() {
build() {
Column() {
Column() {
if (this.controller) {
if (this.controller) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment