优化配置,修复 demo bug
1,network 框架完善 2,websocket 机制完善 3,设计文档整理到架构文档 4,脚本,配置完善
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:im_app/app/di/db_provider.dart';
|
||||
import 'package:im_app/data/local/drift/app_database.dart';
|
||||
@@ -45,13 +44,12 @@ class ChatDbTestState {
|
||||
|
||||
@riverpod
|
||||
class ChatDbTestViewModel extends _$ChatDbTestViewModel {
|
||||
|
||||
@override
|
||||
ChatDbTestState build() {
|
||||
// 这里就是 onInit
|
||||
final List<TestResult> testResults = List.generate(
|
||||
1000,
|
||||
(i) => TestResult(
|
||||
(i) => TestResult(
|
||||
title: '用户 ${Random().nextInt(9999)}',
|
||||
subtitle: 'uid: ${Random().nextInt(999999)}',
|
||||
duration: '${Random().nextInt(500)}ms',
|
||||
@@ -86,7 +84,7 @@ class ChatDbTestViewModel extends _$ChatDbTestViewModel {
|
||||
for (var i = 0; i < count; i += chunkSize) {
|
||||
final chunk = List.generate(
|
||||
chunkSize.clamp(0, count - i),
|
||||
(j) => UsersCompanion.insert(
|
||||
(j) => UsersCompanion.insert(
|
||||
uid: Value(i + j),
|
||||
nickname: Value('User ${i + j}'),
|
||||
),
|
||||
@@ -98,13 +96,13 @@ class ChatDbTestViewModel extends _$ChatDbTestViewModel {
|
||||
// 让出主线程
|
||||
await Future.delayed(Duration.zero);
|
||||
|
||||
debugPrint('已完成: $completed / $count (${stopwatch.elapsedMilliseconds}ms)');
|
||||
debugPrint(
|
||||
'已完成: $completed / $count (${stopwatch.elapsedMilliseconds}ms)',
|
||||
);
|
||||
|
||||
// 更新 UI 状态
|
||||
if (ref.mounted) {
|
||||
state = state.copyWith(
|
||||
currentState: '已插入 $completed / $count 条',
|
||||
);
|
||||
state = state.copyWith(currentState: '已插入 $completed / $count 条');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,4 +114,4 @@ class ChatDbTestViewModel extends _$ChatDbTestViewModel {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user