diff --git a/lib/base/userinfo_viewmodel.dart b/lib/base/userinfo_viewmodel.dart index be3b0ff..f4b73c3 100644 --- a/lib/base/userinfo_viewmodel.dart +++ b/lib/base/userinfo_viewmodel.dart @@ -12,7 +12,7 @@ class UserInfoViewModel { String userInfoJson = SpUtil.getString(spUserInfo); _userName = SpUtil.getString(spUserName); _passWord = SpUtil.getString(spPassWord); - _host = SpUtil.getString(spHost, defValue: ''); + _host = SpUtil.getString(spHost, defValue: 'http://49.234.59.95:5700'); if (userInfoJson.isNotEmpty) { _token = userInfoJson; } diff --git a/lib/module/env/env_page.dart b/lib/module/env/env_page.dart index 3403c8f..5ee7d9d 100644 --- a/lib/module/env/env_page.dart +++ b/lib/module/env/env_page.dart @@ -11,6 +11,7 @@ import 'package:qinglong_app/base/ui/empty_widget.dart'; import 'package:qinglong_app/module/env/env_bean.dart'; import 'package:qinglong_app/module/env/env_viewmodel.dart'; import 'package:qinglong_app/utils/extension.dart'; +import 'package:qinglong_app/utils/utils.dart'; class EnvPage extends StatefulWidget { const EnvPage({Key? key}) : super(key: key); @@ -200,10 +201,13 @@ class EnvItemCell extends StatelessWidget { ), ), ), + const SizedBox( + width: 5, + ), bean.status == 1 ? const Icon( Icons.dnd_forwardslash, - size: 12, + size: 16, color: Colors.red, ) : const SizedBox.shrink(), @@ -217,7 +221,7 @@ class EnvItemCell extends StatelessWidget { Material( color: Colors.transparent, child: Text( - bean.remarks ?? "-", + Utils.formatGMTTime(bean.timestamp ?? ""), maxLines: 1, style: TextStyle( overflow: TextOverflow.ellipsis, @@ -228,6 +232,21 @@ class EnvItemCell extends StatelessWidget { ), ], ), + Padding( + padding: const EdgeInsets.only(top: 8.0), + child: Material( + color: Colors.transparent, + child: Text( + bean.remarks ?? "-", + maxLines: 1, + style: TextStyle( + overflow: TextOverflow.ellipsis, + color: ref.watch(themeProvider).themeColor.descColor(), + fontSize: 12, + ), + ), + ), + ), const SizedBox( height: 8, ), diff --git a/lib/module/login/login_page.dart b/lib/module/login/login_page.dart index 6a4348d..a85b313 100644 --- a/lib/module/login/login_page.dart +++ b/lib/module/login/login_page.dart @@ -244,6 +244,8 @@ class _LoginPageState extends ConsumerState { setState(() {}); HttpResponse response = await Api.login(userName, password); if (response.success) { + getIt().updateToken(response.bean?.token ?? ""); + HttpResponse userResponse = await Api.user(); if (userResponse.success) { if (userResponse.bean != null && userResponse.bean!.twoFactorActivated != null && userResponse.bean!.twoFactorActivated!) { @@ -251,7 +253,6 @@ class _LoginPageState extends ConsumerState { isLoading = false; setState(() {}); } else { - getIt().updateToken(response.bean?.token ?? ""); Navigator.of(context).pushReplacementNamed(Routes.routeHomePage); } } else { diff --git a/lib/module/task/task_viewmodel.dart b/lib/module/task/task_viewmodel.dart index 7069c47..1338c11 100644 --- a/lib/module/task/task_viewmodel.dart +++ b/lib/module/task/task_viewmodel.dart @@ -30,9 +30,6 @@ class TaskViewModel extends BaseViewModel { } void sortList() { - list.sort((a, b) { - return b.created!.compareTo(a.created!); - }); for (int i = 0; i < list.length; i++) { if (list[i].isPinned == 1) { diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 4ec766a..f5b2374 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -6,6 +6,70 @@ class Utils { FocusScope.of(context).requestFocus(FocusNode()); } + static String formatGMTTime(String gmtTime) { + // "Wed Jan 12 2022 20:33:39 GMT+0800 (中国标准时间)" + try { + if (gmtTime.isEmpty) return "-"; + List splitedStr = gmtTime.split(" "); + + int year = int.parse(splitedStr[3]); + String time = splitedStr[4]; + List splitedTime = time.split(":"); + int hour = int.parse(splitedTime[0]); + int min = int.parse(splitedTime[1]); + int second = int.parse(splitedTime[2]); + + int day = int.parse(splitedStr[2]); + + String month = "01"; + + switch (splitedStr[1]) { + case "Jan": + month = "01"; + break; + case "Feb": + month = "02"; + break; + case "Mar": + month = "03"; + break; + case "Apr": + month = "04"; + break; + case "May": + month = "05"; + break; + case "Jun": + month = "06"; + break; + case "Jul": + month = "07"; + break; + case "Aug": + month = "08"; + break; + case "Sep": + month = "09"; + break; + case "Oct": + month = "10"; + break; + case "Nov": + month = "11"; + break; + case "Dec": + month = "12"; + break; + } + + var date = DateTime(year, int.parse(month), day, hour, min, second); + + return formatMessageTime(date.millisecondsSinceEpoch); + } catch (e) { + return "-"; + } + } + static String formatMessageTime(int time) { DateTime current = DateTime.now(); DateTime chatTime; diff --git a/test/widget_test.dart b/test/widget_test.dart index d23c01e..fd3f115 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -5,13 +5,9 @@ // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:qinglong_app/base/http/http.dart'; -import 'package:qinglong_app/base/userinfo_viewmodel.dart'; +void main() { + String time = "Wed Jan 12 2022 20:33:39 GMT+0800 (中国标准时间)"; -import 'package:qinglong_app/main.dart'; -import 'package:qinglong_app/module/login/login_bean.dart'; -import 'package:qinglong_app/module/login/login_viewmodel.dart'; - -void main() {} + var result = DateTime.tryParse(time); + print(result); +}