Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
TestToolChainKmpDemo
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
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dsq
TestToolChainKmpDemo
Commits
ad3aefed
Commit
ad3aefed
authored
Mar 04, 2026
by
dsq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改持续页面
parent
c2fbdb01
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
117 additions
and
2 deletions
+117
-2
ContinuousLogPage.ets
harmonyApp/entry/src/main/ets/pages/ContinuousLogPage.ets
+115
-0
Index.ets
harmonyApp/entry/src/main/ets/pages/Index.ets
+2
-2
No files found.
harmonyApp/entry/src/main/ets/pages/ContinuousLogPage.ets
0 → 100644
View file @
ad3aefed
import testNapi from 'libentry.so';
@Entry
@Component
struct ContinuousLogPage {
@State message: string = '大量持续日志输出';
@State isRunning: boolean = false;
@State elapsedTime: number = 0; // 经过的秒数
private logTimer: number = -1; // 日志定时器 ID(100ms)
private displayTimer: number = -1; // 显示定时器 ID(1s)
aboutToAppear() {
// 初始化状态
this.isRunning = false;
this.elapsedTime = 0;
}
aboutToDisappear() {
// 清理定时器
this.stopAllTimers();
}
startContinuousLog() {
if (this.isRunning) {
return;
}
this.isRunning = true;
this.elapsedTime = 0;
// 每 100ms 调用一次 printRandomHiLog
this.logTimer = setInterval(() => {
testNapi.pirntRandomHiLog();
}, 100);
// 每秒更新一次显示
this.displayTimer = setInterval(() => {
this.elapsedTime++;
}, 1000);
}
stopContinuousLog() {
this.stopAllTimers();
this.isRunning = false;
this.elapsedTime = 0;
}
stopAllTimers() {
if (this.logTimer !== -1) {
clearInterval(this.logTimer);
this.logTimer = -1;
}
if (this.displayTimer !== -1) {
clearInterval(this.displayTimer);
this.displayTimer = -1;
}
}
build() {
Column() {
// 标题
Text('大量持续日志输出')
.fontSize(24)
.fontWeight(FontWeight.Bold)
.margin({ top: 50, bottom: 30 })
// 说明文字
Text('点击开始后每 100ms 生成一条随机日志')
.fontSize(16)
.fontColor('#666666')
.margin({ bottom: 30 })
// 计时器显示
Text(`已运行:${this.elapsedTime} 秒`)
.fontSize(20)
.fontColor('#007DFF')
.fontWeight(FontWeight.Medium)
.margin({ bottom: 50 })
// 状态显示
Text(this.isRunning ? '正在输出日志...' : '已停止')
.fontSize(18)
.fontColor(this.isRunning ? '#FF4444' : '#666666')
.margin({ bottom: 50 })
// 按钮行
Row() {
// 开始按钮
Button('开始')
.width('40%')
.height(50)
.backgroundColor('#00D900')
.enabled(!this.isRunning)
.onClick(() => {
this.startContinuousLog();
})
// 停止按钮
Button('停止')
.width('40%')
.height(50)
.backgroundColor('#FF4444')
.enabled(this.isRunning)
.onClick(() => {
this.stopContinuousLog();
})
}
.width('80%')
.justifyContent(FlexAlign.SpaceEvenly)
.margin({ top: 20 })
}
.width('100%')
.height('100%')
}
}
harmonyApp/entry/src/main/ets/pages/Index.ets
View file @
ad3aefed
...
@@ -40,13 +40,13 @@ struct Index {
...
@@ -40,13 +40,13 @@ struct Index {
})
})
// 大量持续日志输出按钮
// 大量持续日志输出按钮
Button('
大量持续日志输出
')
Button('
进入持续日志页面
')
.width('80%')
.width('80%')
.height(50)
.height(50)
.backgroundColor('#007DFF')
.backgroundColor('#007DFF')
.margin({ bottom: 20 })
.margin({ bottom: 20 })
.onClick(() => {
.onClick(() => {
testNapi.pirntRandomHiLog(
);
router.pushUrl({ url: 'pages/ContinuousLogPage' }
);
})
})
// 越界崩溃测试按钮
// 越界崩溃测试按钮
...
...
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