chore: 全面规范化代码,遵循 CLAUDE.md 编码规范

- C# 文件命名改为 snake_case(28 个文件重命名)
- C# 类转换为主构造函数(8 个类)
- 空 catch 添加异常类型(2 处)
- 新建 GlobalUsings.cs(Health.Infrastructure、Health.WebApi)
- Flutter 移除 go_router,改用 Riverpod 路由栈
- Flutter 移除 flutter_secure_storage,改用 sqflite 持久化
- 修复 Flutter 构建路径(Flutter SDK 迁至 D 盘)
- 后端端口改为 0.0.0.0:5000,支持局域网访问
This commit is contained in:
MingNian
2026-06-02 12:41:06 +08:00
parent 14d7c30d3d
commit 6e69f1085e
47 changed files with 342 additions and 428 deletions

View File

@@ -1,4 +1,5 @@
import 'package:go_router/go_router.dart';
import 'package:flutter/material.dart';
import 'navigation_provider.dart';
import '../pages/auth/login_page.dart';
import '../pages/home/home_page.dart';
import '../pages/chart/trend_page.dart';
@@ -9,49 +10,51 @@ import '../pages/settings/settings_pages.dart';
import '../pages/profile/profile_page.dart';
import '../pages/remaining_pages.dart';
/// 应用路由配置
class AppRouter {
AppRouter._();
static final GoRouter router = GoRouter(
initialLocation: '/login',
routes: [
GoRoute(path: '/login', builder: (_, _) => const LoginPage()),
GoRoute(path: '/home', builder: (_, _) => const HomePage()),
GoRoute(path: '/trend/:type', builder: (_, state) => TrendPage(metricType: state.pathParameters['type']!)),
GoRoute(path: '/calendar', builder: (_, _) => const HealthCalendarPage()),
// 用药
GoRoute(path: '/medications', builder: (_, _) => const MedicationListPage()),
GoRoute(path: '/medications/add', builder: (_, _) => const MedicationEditPage()),
GoRoute(path: '/medications/:id/edit', builder: (_, state) => MedicationEditPage(id: state.pathParameters['id'])),
// 报告
GoRoute(path: '/reports', builder: (_, _) => const ReportListPage()),
GoRoute(path: '/reports/:id', builder: (_, state) => ReportDetailPage(id: state.pathParameters['id']!)),
// 问诊
GoRoute(path: '/doctors', builder: (_, _) => const DoctorListPage()),
GoRoute(path: '/consultation/:id', builder: (_, state) => DoctorChatPage(id: state.pathParameters['id']!)),
// 运动
GoRoute(path: '/exercise-plan', builder: (_, _) => const ExercisePlanPage()),
// 饮食
GoRoute(path: '/diet-records', builder: (_, _) => const DietRecordListPage()),
// 个人中心
GoRoute(path: '/profile', builder: (_, _) => const ProfilePage()),
GoRoute(path: '/profile/edit', builder: (_, _) => const EditProfilePage()),
GoRoute(path: '/health-archive', builder: (_, _) => const HealthArchivePage()),
// 复查
GoRoute(path: '/followups', builder: (_, _) => const FollowUpListPage()),
// 设置
GoRoute(path: '/settings', builder: (_, _) => const SettingsPage()),
GoRoute(path: '/settings/notifications', builder: (_, _) => const NotificationPrefsPage()),
GoRoute(path: '/page/:type', builder: (_, state) => StaticTextPage(type: state.pathParameters['type']!)),
],
);
/// 根据路由信息返回对应页面
Widget buildPage(RouteInfo route) {
final params = route.params;
switch (route.name) {
case 'login':
return const LoginPage();
case 'home':
return const HomePage();
case 'trend':
return TrendPage(metricType: params['type'] ?? '');
case 'calendar':
return const HealthCalendarPage();
case 'medications':
return const MedicationListPage();
case 'medicationAdd':
return const MedicationEditPage();
case 'medicationEdit':
return MedicationEditPage(id: params['id']);
case 'reports':
return const ReportListPage();
case 'reportDetail':
return ReportDetailPage(id: params['id']!);
case 'doctors':
return const DoctorListPage();
case 'consultation':
return DoctorChatPage(id: params['id']!);
case 'exercisePlan':
return const ExercisePlanPage();
case 'dietRecords':
return const DietRecordListPage();
case 'profile':
return const ProfilePage();
case 'profileEdit':
return const EditProfilePage();
case 'healthArchive':
return const HealthArchivePage();
case 'followups':
return const FollowUpListPage();
case 'settings':
return const SettingsPage();
case 'notificationPrefs':
return const NotificationPrefsPage();
case 'staticText':
return StaticTextPage(type: params['type']!);
default:
return const LoginPage();
}
}