754275cbd6
新增 model.Date 类型,支持前端传入的纯日期格式 YYYY-MM-DD: - UnmarshalJSON 优先解析 YYYY-MM-DD,回退支持 RFC3339 - MarshalJSON 输出 YYYY-MM-DD - Value/Scan 实现 GORM MySQL DATE 列读写 - StockInOrder/StockOutOrder/InventoryCheck 的 OrderDate/CheckDate 改用 Date 类型 feat(client): SelectionArea 全局开启文字可选中复制 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
87 lines
2.3 KiB
Dart
87 lines
2.3 KiB
Dart
import 'dart:async';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'core/auth/auth_state.dart';
|
|
import 'core/router/app_router.dart';
|
|
import 'core/theme/app_theme.dart';
|
|
|
|
void main() {
|
|
FlutterError.onError = (details) {
|
|
FlutterError.presentError(details);
|
|
debugPrint('═══ FlutterError ════════════════════════════');
|
|
debugPrint(details.exceptionAsString());
|
|
debugPrint(details.stack.toString());
|
|
};
|
|
|
|
runZonedGuarded(
|
|
() => runApp(const ProviderScope(child: JiuApp())),
|
|
(error, stack) {
|
|
debugPrint('═══ Zone Error ═══════════════════════════════');
|
|
debugPrint(error.toString());
|
|
debugPrint(stack.toString());
|
|
},
|
|
);
|
|
}
|
|
|
|
class JiuApp extends ConsumerWidget {
|
|
const JiuApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
return MaterialApp(
|
|
title: '酒库管理系统',
|
|
theme: AppTheme.light(),
|
|
debugShowCheckedModeBanner: false,
|
|
home: const _AppBootstrap(),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Restores persisted auth before handing off to the router.
|
|
class _AppBootstrap extends ConsumerStatefulWidget {
|
|
const _AppBootstrap();
|
|
|
|
@override
|
|
ConsumerState<_AppBootstrap> createState() => _AppBootstrapState();
|
|
}
|
|
|
|
class _AppBootstrapState extends ConsumerState<_AppBootstrap> {
|
|
bool _ready = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_init();
|
|
}
|
|
|
|
Future<void> _init() async {
|
|
await ref.read(authStateProvider.notifier).restore();
|
|
if (mounted) setState(() => _ready = true);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (!_ready) {
|
|
return const Scaffold(
|
|
body: Center(child: CircularProgressIndicator()),
|
|
);
|
|
}
|
|
return _RouterApp();
|
|
}
|
|
}
|
|
|
|
class _RouterApp extends ConsumerWidget {
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final router = ref.watch(appRouterProvider);
|
|
return MaterialApp.router(
|
|
title: '酒库管理系统',
|
|
theme: AppTheme.light(),
|
|
routerConfig: router,
|
|
debugShowCheckedModeBanner: false,
|
|
builder: (context, child) => SelectionArea(child: child!),
|
|
);
|
|
}
|
|
}
|