Browse Source

remove app

liuyuqi-dellpc 1 year ago
parent
commit
2bc7edea57
6 changed files with 65 additions and 66 deletions
  1. 0 23
      lib/app/app_scene.dart
  2. 5 38
      lib/app/user_manager.dart
  3. 23 2
      lib/main.dart
  4. 3 0
      lib/model/constant.dart
  5. 34 0
      lib/model/user_model.dart
  6. 0 3
      lib/public.dart

+ 0 - 23
lib/app/app_scene.dart

@@ -1,23 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:shuqi/public.dart';
-import 'package:shuqi/index_page.dart';
-
-final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();
-
-class MyApp extends StatelessWidget {
-  @override
-  Widget build(BuildContext context) {
-    return MaterialApp(
-      title: '书旗小说',
-      navigatorObservers: [routeObserver],
-      debugShowCheckedModeBanner: false,
-      theme: ThemeData(
-        primaryColor: Colors.white,
-        dividerColor: Color(0xffeeeeee),
-        scaffoldBackgroundColor: SQColor.paper,
-        textTheme: TextTheme(bodyLarge: TextStyle(color: SQColor.darkGray)),
-      ),
-      home: IndexPage(),
-    );
-  }
-}

+ 5 - 38
lib/app/user_manager.dart

@@ -1,5 +1,6 @@
 import 'dart:convert';
 
+import 'package:shuqi/model/user_model.dart';
 import 'package:shuqi/utility/event_bus.dart';
 import 'package:shuqi/model/constant.dart';
 
@@ -9,8 +10,8 @@ const String EventUserLogout = 'EventUserLogout';
 class UserManager {
   static UserManager instance = UserManager();
 
-  User? user;
-  static User? get currentUser {
+  UserModel? user;
+  static UserModel? get currentUser {
     return UserManager.instance.user;
   }
 
@@ -21,7 +22,7 @@ class UserManager {
   }
 
   login(Map<String, dynamic> userJson) {
-    var user = User.fromJson(userJson);
+    var user = UserModel.fromJson(userJson);
     this.user = user;
     saveUser();
 
@@ -35,7 +36,7 @@ class UserManager {
   loadUserFromLocal() {
     String? userJson = preferences.getString('user');
     if (userJson != null) {
-      user = User.fromJson(json.decode(userJson));
+      user = UserModel.fromJson(json.decode(userJson));
     }
   }
 
@@ -45,37 +46,3 @@ class UserManager {
   }
 }
 
-class User {
-  late String token;
-  late int id;
-  late String nickname;
-  late String avatarUrl;
-  late bool isVip;
-  late double wealth;
-  late int coupon;
-  late int monthlyTicket;
-
-  User.fromJson(Map json) {
-    token = json['token'];
-    id = json['id'];
-    nickname = json['nickname'];
-    avatarUrl = json['avatar'];
-    isVip = json['is_vip'] == 1;
-    wealth = json['wealth'];
-    coupon = json['coupon'];
-    monthlyTicket = json['ticket'];
-  }
-
-  Map<String, dynamic> toJson() {
-    return {
-      'token': token,
-      'id': id,
-      'nickname': nickname,
-      'avatar': avatarUrl,
-      'is_vip': isVip ? 1 : 0,
-      'wealth': wealth,
-      'coupon': coupon,
-      'ticket': monthlyTicket,
-    };
-  }
-}

+ 23 - 2
lib/main.dart

@@ -1,14 +1,35 @@
 import 'package:flutter/material.dart';
 import 'dart:io';
 import 'package:flutter/services.dart';
-import 'package:shuqi/app/app_scene.dart';
+import 'package:shuqi/index_page.dart';
+import 'package:shuqi/model/constant.dart';
+import 'package:shuqi/model/sq_color.dart';
 
 void main() {
   runApp(MyApp());
 
   // 状态栏透明
   if (Platform.isAndroid) {
-    SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(statusBarColor: Colors.transparent);
+    SystemUiOverlayStyle systemUiOverlayStyle =
+        SystemUiOverlayStyle(statusBarColor: Colors.transparent);
     SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
   }
 }
+
+class MyApp extends StatelessWidget {
+  @override
+  Widget build(BuildContext context) {
+    return MaterialApp(
+      title: '书旗小说',
+      navigatorObservers: [routeObserver],
+      debugShowCheckedModeBanner: false,
+      theme: ThemeData(
+        primaryColor: Colors.white,
+        dividerColor: Color(0xffeeeeee),
+        scaffoldBackgroundColor: SQColor.paper,
+        textTheme: TextTheme(bodyLarge: TextStyle(color: SQColor.darkGray)),
+      ),
+      home: IndexPage(),
+    );
+  }
+}

+ 3 - 0
lib/model/constant.dart

@@ -1,4 +1,7 @@
+import 'package:flutter/material.dart';
 import 'package:shared_preferences/shared_preferences.dart';
 
 late SharedPreferences preferences;
 const String EventToggleTabBarIndex = 'EventToggleTabBarIndex';
+
+final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();

+ 34 - 0
lib/model/user_model.dart

@@ -0,0 +1,34 @@
+class UserModel {
+  late String token;
+  late int id;
+  late String nickname;
+  late String avatarUrl;
+  late bool isVip;
+  late double wealth;
+  late int coupon;
+  late int monthlyTicket;
+
+  UserModel.fromJson(Map json) {
+    token = json['token'];
+    id = json['id'];
+    nickname = json['nickname'];
+    avatarUrl = json['avatar'];
+    isVip = json['is_vip'] == 1;
+    wealth = json['wealth'];
+    coupon = json['coupon'];
+    monthlyTicket = json['ticket'];
+  }
+
+  Map<String, dynamic> toJson() {
+    return {
+      'token': token,
+      'id': id,
+      'nickname': nickname,
+      'avatar': avatarUrl,
+      'is_vip': isVip ? 1 : 0,
+      'wealth': wealth,
+      'coupon': coupon,
+      'ticket': monthlyTicket,
+    };
+  }
+}

+ 0 - 3
lib/public.dart

@@ -1,7 +1,5 @@
 library public;
 
-// Vendor
-
 // Global
 export 'package:shuqi/model/constant.dart';
 
@@ -21,7 +19,6 @@ export 'package:shuqi/app/request.dart';
 export 'package:shuqi/app/app_navigator.dart';
 export 'package:shuqi/model/sq_color.dart';
 export 'package:shuqi/app/user_manager.dart';
-export 'package:shuqi/app/app_scene.dart';
 
 // Model
 export 'package:shuqi/model/novel.dart';