自习室优化ok
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:app/global/event_bus.dart';
|
||||
import 'package:app/providers/user_store.dart';
|
||||
import 'package:app/router/route_paths.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:app/router/routes.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'config/theme/theme.dart';
|
||||
import 'global/theme/theme.dart';
|
||||
import 'global/theme/themes/light_theme.dart';
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
@@ -19,9 +25,26 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
class MyApp extends StatefulWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
State<MyApp> createState() => _MyAppState();
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// 1. 监听 401
|
||||
EventBus().stream.listen((event) {
|
||||
if (event == GlobalEvent.unauthorized) {
|
||||
final ctx = navigatorKey.currentState?.context;
|
||||
ctx?.go(RoutePaths.login);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ScreenUtilInit(
|
||||
|
||||
Reference in New Issue
Block a user