- 新增管理员角色(手机号12345678910),管理员可增删医生、查看患者 - 注册页重构:去掉角色选择+审核码,改为选医生+填姓名 - 医生端点按DoctorId过滤患者,Patient↔Doctor关系建立 - Doctor/DoctorProfile/User实体新增关联字段 - JSON循环引用修复(IgnoreCycles) - /api/doctors改为公开接口 - 登录闪屏修复+原生Android启动页 - 输入框全局白底+灰框 - 蓝牙重连同步修复 - Web端(doctor_web+health_app/web)全部删除 - 全局UI改版:白底企业风,新配色和组件系统 - 新品牌图标和启动图
68 lines
2.1 KiB
Dart
68 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||
import 'core/app_router.dart';
|
||
import 'core/app_theme.dart';
|
||
import 'core/navigation_provider.dart';
|
||
import 'providers/auth_provider.dart';
|
||
|
||
/// 健康管家 App 根组件
|
||
class HealthApp extends ConsumerWidget {
|
||
const HealthApp({super.key});
|
||
|
||
@override
|
||
Widget build(BuildContext context, WidgetRef ref) {
|
||
return MaterialApp(
|
||
title: '健康管家',
|
||
debugShowCheckedModeBanner: false,
|
||
theme: AppTheme.lightTheme,
|
||
localizationsDelegates: const [
|
||
GlobalMaterialLocalizations.delegate,
|
||
GlobalWidgetsLocalizations.delegate,
|
||
GlobalCupertinoLocalizations.delegate,
|
||
],
|
||
supportedLocales: const [Locale('zh', 'CN'), Locale('zh')],
|
||
locale: const Locale('zh'),
|
||
home: const _RootNavigator(),
|
||
// 注入 ShadTheme,让所有页面都能用 shadcn 组件
|
||
builder: (context, child) =>
|
||
ShadTheme(data: AppTheme.shadTheme, child: child!),
|
||
);
|
||
}
|
||
}
|
||
|
||
/// 根导航——根据 Riverpod 路由状态切换页面
|
||
class _RootNavigator extends ConsumerWidget {
|
||
const _RootNavigator();
|
||
|
||
@override
|
||
Widget build(BuildContext context, WidgetRef ref) {
|
||
final stack = ref.watch(routeStackProvider);
|
||
final current = stack.last;
|
||
final authState = ref.watch(authProvider);
|
||
|
||
// 登录后自动跳转(在下一帧完成,无闪烁)
|
||
if (authState.isLoggedIn && current.name == 'login') {
|
||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||
final role = authState.user?.role ?? 'User';
|
||
if (role == 'Admin') {
|
||
goRoute(ref, 'adminHome');
|
||
} else if (role == 'Doctor') {
|
||
goRoute(ref, 'doctorHome');
|
||
} else {
|
||
goRoute(ref, 'home');
|
||
}
|
||
});
|
||
}
|
||
|
||
return PopScope(
|
||
canPop: stack.length <= 1,
|
||
onPopInvokedWithResult: (didPop, result) {
|
||
if (!didPop) popRoute(ref);
|
||
},
|
||
child: buildPage(current, ref),
|
||
);
|
||
}
|
||
}
|