Browse Source

add sqlite3 to release

arthur.wu 2 years ago
parent
commit
2215443aa2

+ 1 - 1
Tools/TestTools/client/lib/Services/DatabaseService.dart

@@ -23,11 +23,11 @@ class DatabaseService {
 
       var databaseFactory = databaseFactoryFfi;
       var dir = await getApplicationSupportDirectory();
-      Logger.info('getApplicationSupportDirectory: ${dir?.path}');
       //database = await databaseFactory.openDatabase(inMemoryDatabasePath);
       var path = join(dir.path, 'client_database.db');
       var exist = await databaseExists(path);
       database = await databaseFactory.openDatabase(path);
+      Logger.info('client_database path: ${path}');
       if (exist) {
         //TODO
       } else {

+ 1 - 3
Tools/TestTools/client/lib/Services/UserService.dart

@@ -17,9 +17,7 @@ class UserService {
   late Profile? currentUser = null;
   final String UserStroageKey = "CurrentUser";
 
-  late WebSocketChannel? Channel = WebSocketChannel.connect(
-    Uri.parse('ws://192.168.6.175:8443/wss/?token=${currentUser?.accessToken}'),
-  ); //TODO
+  late WebSocketChannel? Channel = null;
 
   Future<Profile?> getCurrentUser() async {
     var service = GetIt.instance.get<LocalStorageService>();

+ 36 - 31
Tools/TestTools/client/lib/main.dart

@@ -42,41 +42,46 @@ void main() {
 }
 
 Future<void> initialize() async {
-  final getIt = GetIt.instance;
-  var isWeb = PlatformUtils.isWeb;
-  if (isWeb) {
-    Logger.client = ColorizeLoggerClient();
-    Logger.info('The first log in web');
-  } else {
-    if (Logger.isReleaseMode()) {
-      /// use file
-      Directory directory = await getApplicationDocumentsDirectory();
-      final currentDate = DateTime.now();
-      final fileName =
-          '${currentDate.year}-${currentDate.month}-${currentDate.day}-logs.txt';
-      Logger.client = FileLoggerClient(filePath: '${directory.path}/$fileName');
+  try {
+    final getIt = GetIt.instance;
+    var isWeb = PlatformUtils.isWeb;
+    if (isWeb) {
+      Logger.client = ColorizeLoggerClient();
+      Logger.info('The first log in web');
     } else {
-      Logger.client = ColorizeLoggerClient(); //for debug
+      if (Logger.isReleaseMode()) {
+        /// use file
+        Directory directory = await getApplicationDocumentsDirectory();
+        final currentDate = DateTime.now();
+        final fileName =
+            '${currentDate.year}-${currentDate.month}-${currentDate.day}-logs.txt';
+        Logger.client =
+            FileLoggerClient(filePath: '${directory.path}/$fileName');
+      } else {
+        Logger.client = ColorizeLoggerClient(); //for debug
+      }
+      Logger.info('The first log in app');
+
+      /// use sentry
+      // await SentryFlutter.init(
+      //   (options) {
+      //     options.dsn = 'https://example@sentry.io/add-your-dsn-here';
+      //   },
+      // );
+      // Logger.client = SentryLoggerClient();
+      var dbServcie = new DatabaseService();
+      getIt.registerSingleton<DatabaseService>(dbServcie);
+      await dbServcie.initialize();
     }
-    Logger.info('The first log in app');
 
-    /// use sentry
-    // await SentryFlutter.init(
-    //   (options) {
-    //     options.dsn = 'https://example@sentry.io/add-your-dsn-here';
-    //   },
-    // );
-    // Logger.client = SentryLoggerClient();
-    var dbServcie = new DatabaseService();
-    getIt.registerSingleton<DatabaseService>(dbServcie);
-    await dbServcie.initialize();
+    getIt.registerSingleton<LocalStorageService>(LocalStorageService(isWeb));
+    getIt.registerSingleton<ApiTestService>(ApiTestService());
+    getIt.registerSingleton<UserService>(UserService());
+    getIt.registerSingleton<ConsultationService>(ConsultationService());
+    runApp(const MyApp());
+  } catch (ex) {
+    Logger.error("initialize exception:$ex");
   }
-
-  getIt.registerSingleton<LocalStorageService>(LocalStorageService(isWeb));
-  getIt.registerSingleton<ApiTestService>(ApiTestService());
-  getIt.registerSingleton<UserService>(UserService());
-  getIt.registerSingleton<ConsultationService>(ConsultationService());
-  runApp(const MyApp());
 }
 
 class MyApp extends StatelessWidget {

BIN
Tools/TestTools/client/windows/sqlite3.dll