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
ff6b2712
Commit
ff6b2712
authored
Mar 13, 2026
by
dsq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文件重新命名
parent
07adf52c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
24 deletions
+37
-24
build.gradle.kts
composeApp/build.gradle.kts
+1
-0
HighLogDemo.kt
...src/commonMain/kotlin/com.dong.demo013/Log/HighLogDemo.kt
+31
-22
TestLog.ohosX64.kt
...rc/ohosX64Main/kotlin/com.dong/demo013/TestLog.ohosX64.kt
+0
-0
gradle.properties
gradle.properties
+3
-0
CMakeLists.txt
harmonyApp/entry/src/main/cpp/CMakeLists.txt
+2
-2
No files found.
composeApp/build.gradle.kts
View file @
ff6b2712
...
...
@@ -45,6 +45,7 @@ kotlin {
// 确保链接系统 zlib,使 libkn.so 的 NEEDED 包含 libz.so
linkerOpts
(
"-lz"
)
}
// 禁用内联类可能有助于 NAPI
val
main
by
compilations
.
getting
main
.
compilerOptions
.
configure
{
freeCompilerArgs
.
add
(
"-Xbinary=sanitizer=address"
)
...
...
composeApp/src/commonMain/kotlin/com.dong.demo013/Log/HighLogDemo.kt
View file @
ff6b2712
...
...
@@ -8,9 +8,9 @@ import androidx.compose.ui.Alignment
import
androidx.compose.ui.Modifier
import
androidx.compose.ui.text.input.KeyboardType
import
androidx.compose.ui.unit.dp
import
com.dong.demo013.LogController
import
com.dong.demo013.TimerController
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.isActive
import
kotlin.time.TimeSource
@OptIn
(
ExperimentalLayoutApi
::
class
)
@Composable
...
...
@@ -19,22 +19,35 @@ internal fun HighLogDemo() {
var
logSpeed
by
remember
{
mutableStateOf
(
"100"
)
}
var
logCount
by
remember
{
mutableStateOf
(
0
)
}
var
isGenerating
by
remember
{
mutableStateOf
(
false
)
}
var
logController
by
remember
{
mutableStateOf
<
LogController
?>(
null
)
}
// 计时器状态
var
timerController
by
remember
{
mutableStateOf
<
TimerController
?>(
null
)
}
// 计时器状态 - 使用纯 Compose 方式实现
var
displayTime
by
remember
{
mutableStateOf
(
0L
)
}
var
isTimerRunning
by
remember
{
mutableStateOf
(
false
)
}
val
timeSource
=
remember
{
TimeSource
.
Monotonic
}
var
startTimeMark
by
remember
{
mutableStateOf
(
timeSource
.
markNow
())
}
// 初始化计时器
LaunchedEffect
(
Unit
)
{
// 使用 LaunchedEffect 实现计时器
LaunchedEffect
(
isTimerRunning
)
{
if
(
isTimerRunning
)
{
startTimeMark
=
timeSource
.
markNow
()
while
(
isActive
&&
isTimerRunning
)
{
delay
(
100
)
// 每 100ms 更新一次显示
displayTime
=
startTimeMark
.
elapsedNow
().
inWholeSeconds
}
}
else
{
// 暂停时重置时间
displayTime
=
0
}
}
// 定期更新显示时间
LaunchedEffect
(
timerController
)
{
while
(
true
)
{
delay
(
100
)
// 每100ms更新一次显示
displayTime
=
timerController
?.
elapsedTime
?:
0
// 日志生成协程
LaunchedEffect
(
isGenerating
,
logSpeed
)
{
if
(
isGenerating
)
{
val
speed
=
logSpeed
.
toIntOrNull
()
?:
100
while
(
isActive
&&
isGenerating
)
{
delay
(
speed
.
toLong
())
logCount
++
}
}
}
...
...
@@ -123,14 +136,10 @@ internal fun HighLogDemo() {
)
{
Button
(
onClick
=
{
val
speed
=
logSpeed
.
toIntOrNull
()
?:
100
// 启动日志生成和计时器
logCount
=
0
// 重置并启动计时器
timerController
?.
reset
()
timerController
?.
start
()
isGenerating
=
true
isTimerRunning
=
true
},
modifier
=
Modifier
.
weight
(
1f
),
enabled
=
logSpeed
.
isNotEmpty
()
&&
!
isGenerating
...
...
@@ -140,9 +149,9 @@ internal fun HighLogDemo() {
Button
(
onClick
=
{
logController
?.
stop
()
timerController
?.
stop
()
// 停止日志生成和计时器
isGenerating
=
false
isTimerRunning
=
false
},
modifier
=
Modifier
.
weight
(
1f
),
enabled
=
isGenerating
...
...
composeApp/src/ohosX64Main/kotlin/com.dong/demo013/TestLog.ohos
Arm
64.kt
→
composeApp/src/ohosX64Main/kotlin/com.dong/demo013/TestLog.ohos
X
64.kt
View file @
ff6b2712
File moved
gradle.properties
View file @
ff6b2712
...
...
@@ -17,3 +17,6 @@ kotlin.native.cacheKind=none
org.gradle.internal.http.connectionTimeout
=
100000
org.gradle.internal.http.socketTimeout
=
100000
# kotlin.mpp.applyDefaultHierarchyTemplate=false
kotlin.native.optimizations.extraOpts
=
-Oz
kotlin.native.binary.alignment
=
8
harmonyApp/entry/src/main/cpp/CMakeLists.txt
View file @
ff6b2712
...
...
@@ -9,7 +9,7 @@ if(DEFINED PACKAGE_FIND_FILE)
endif
()
include_directories
(
${
NATIVERENDER_ROOT_PATH
}
${
NATIVERENDER_ROOT_PATH
}
/include
)
${
NATIVERENDER_ROOT_PATH
}
/include
)
# 从skikobridge 换成了 compose
find_package
(
compose
)
...
...
@@ -29,7 +29,7 @@ else()
set
(
LIBKN_ABI_DIR
"arm64-v8a"
)
endif
()
set_target_properties
(
ComposeApp PROPERTIES
IMPORTED_LOCATION
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../libs/
${
LIBKN_ABI_DIR
}
/libkn.so"
IMPORTED_LOCATION
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../libs/
${
LIBKN_ABI_DIR
}
/libkn.so"
)
target_link_libraries
(
entry PUBLIC ComposeApp
)
# 先链接 libkn.so,再链接 compose里面的skikobridge
...
...
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