Merge remote-tracking branch 'origin/dev' into cody/netwrok_SDK
# Conflicts: # apps/im_app/lib/features/chat/presentation/chat_db_test_view_model.dart # apps/im_app/lib/features/login/presentation/login_view_model.dart 修复逻辑漏洞,性能优化
This commit is contained in:
@@ -58,17 +58,16 @@ class ChatDbTestViewModel extends _$ChatDbTestViewModel {
|
||||
return ChatDbTestState(testResults: testResults);
|
||||
}
|
||||
|
||||
// ── 导航(Demo 按钮,正式开发后随 UI 一并替换) ──────────────────────────
|
||||
// ── 操作(Demo 按钮,正式开发后随 UI 一并替换) ──────────────────────────
|
||||
|
||||
/// 开始测试
|
||||
void startDBTest(BuildContext context) {
|
||||
state = state.copyWith(testStarted: true, currentState: '开始测试');
|
||||
_testDBInsert();
|
||||
}
|
||||
|
||||
/// 结束测试
|
||||
void stopDBTest(BuildContext context) {
|
||||
state = state.copyWith(testStarted: false, currentState: '结束测试');
|
||||
/// 切换测试状态(开始 / 停止)
|
||||
void toggleDBTest() {
|
||||
if (state.testStarted) {
|
||||
state = state.copyWith(testStarted: false, currentState: '结束测试');
|
||||
} else {
|
||||
state = state.copyWith(testStarted: true, currentState: '开始测试');
|
||||
_testDBInsert();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _testDBInsert() async {
|
||||
@@ -84,13 +83,11 @@ class ChatDbTestViewModel extends _$ChatDbTestViewModel {
|
||||
for (var i = 0; i < count; i += chunkSize) {
|
||||
final chunk = List.generate(
|
||||
chunkSize.clamp(0, count - i),
|
||||
(j) => UsersCompanion.insert(
|
||||
uid: Value(i + j),
|
||||
nickname: Value('User ${i + j}'),
|
||||
),
|
||||
(j) =>
|
||||
UsersCompanion.insert(uid: i + j, nickname: Value('User ${i + j}')),
|
||||
);
|
||||
|
||||
await db.batchInsertOrReplace<User>(chunk);
|
||||
await db.batchInsertOrReplace<DriftUser>(chunk);
|
||||
completed += chunk.length;
|
||||
|
||||
// 让出主线程
|
||||
|
||||
Reference in New Issue
Block a user