更新数据库

This commit is contained in:
Happi (哈比)
2026-03-06 16:54:51 +08:00
parent bf9e099747
commit 113ecb633a
17 changed files with 604 additions and 117 deletions

View File

@@ -0,0 +1,71 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:im_app/features/chat/presentation/chat_db_test_view_model.dart';
import '../../../core/ui/components/app_button.dart';
import '../presentation/chat_view_model.dart';
/// 聊天页Demo 按钮)
///
/// 包含五个演示按钮,覆盖 go_router 的常见导航场景:
/// - 「切换 Tab」 — go替换历史不可返回
/// - 「有参 pushextra」 — push + extraDart Record可返回
/// - 「有参 push路径参数」— push + URL 内嵌 id可返回
/// - 「无参 push」 — push可返回
/// - 「退出登录」 — 守卫自动重定向到 /login
///
/// 所有操作通过 [ChatViewModel] 处理View 不直接调用路由。
/// 正式开发后替换为会话列表,按钮相关代码一并清除。
class ChatDbTestPage extends ConsumerWidget {
const ChatDbTestPage({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.read(chatDbTestViewModelProvider.notifier);
final state = ref.watch(chatDbTestViewModelProvider);
return Scaffold(
appBar: AppBar(title: const Text('测试数据库'), ),
body: Column(
mainAxisSize: MainAxisSize.max,
spacing: 16,
children: [
SizedBox(height: 4),
Padding(
padding: EdgeInsetsGeometry.symmetric(horizontal: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
AppButton.inverse(
label: state.testStarted ? '结束' : '开始',
onPressed: () => state.testStarted ? vm.stopDBTest(context) : vm.startDBTest(context),
),
SizedBox(width: 8),
Expanded(
child: Text(
state.currentState,
textAlign: TextAlign.end,
),
)
],
)
),
Expanded(
child: ListView.builder(
itemCount: state.testResults.length,
itemBuilder: (context, index) {
final result = state.testResults[index];
return ListTile(
titleAlignment: ListTileTitleAlignment.center,
title: Text(result.title),
subtitle: Text(result.subtitle),
// trailing: Text(result.duration),
);
},
),
)
],
),
);
}
}

View File

@@ -54,6 +54,10 @@ class ChatPage extends ConsumerWidget {
label: '无参 go',
onPressed: () => vm.goToSettings(context),
),
AppButton.inverse(
label: '测试数据库性能',
onPressed: () => vm.goToDatabaseTest(context),
),
AppButton.secondary(
label: '退出登录',
fullWidth: false,