diff --git a/lib/data/provider/apt.dart b/lib/data/provider/apt.dart index d6109f90..a7677516 100644 --- a/lib/data/provider/apt.dart +++ b/lib/data/provider/apt.dart @@ -89,7 +89,8 @@ class AptProvider extends BusyProvider { default: // avoid other outputs // such as: [Could not chdir to home directory /home/test: No such file or directory, , WARNING: apt does not have a stable CLI interface. Use with caution in scripts., , Listing...] - final idx = list.indexWhere((element) => element.contains('[upgradable from:')); + final idx = + list.indexWhere((element) => element.contains('[upgradable from:')); if (idx != -1) { list = list.sublist(idx); } diff --git a/lib/data/provider/server.dart b/lib/data/provider/server.dart index faf4984d..d53177ed 100644 --- a/lib/data/provider/server.dart +++ b/lib/data/provider/server.dart @@ -176,7 +176,12 @@ class ServerProvider extends BusyProvider { logger.info( 'Connected to [${spi.name}] in [${time2.difference(time1).toString()}].'); s.connectionState = ServerConnectionState.connected; - s.client!.run("echo '$shellCmd' > $shellPath && chmod +x $shellPath"); + final writeResult = await s.client! + .run("echo '$shellCmd' > $shellPath && chmod +x $shellPath") + .string; + if (writeResult.isNotEmpty) { + throw Exception(writeResult); + } } catch (e) { s.connectionState = ServerConnectionState.failed; s.status.failedInfo = '$e ## '; @@ -189,13 +194,15 @@ class ServerProvider extends BusyProvider { // if client is null, return if (s.client == null) return; final raw = await s.client!.run("sh $shellPath").string; - if (raw.isEmpty) { + final lines = raw.split(seperator).map((e) => e.trim()).toList(); + if (raw.isEmpty || lines.length == 1) { s.connectionState = ServerConnectionState.failed; - s.status.failedInfo = 'Empty output'; + if (s.status.failedInfo == null || s.status.failedInfo!.isEmpty) { + s.status.failedInfo = 'No data received'; + } notifyListeners(); return; } - final lines = raw.split(seperator).map((e) => e.trim()).toList(); lines.removeAt(0); try { diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index a17a9650..55355229 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,9 +2,9 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 143; + static const int build = 144; static const String engine = - "Flutter 3.0.1 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision fb57da5f94 (3 days ago) • 2022-05-19 15:50:29 -0700\nEngine • revision caaafc5604\nTools • Dart 2.17.1 • DevTools 2.12.2\n"; - static const String buildAt = "2022-05-23 17:48:09.246927"; - static const int modifications = 0; + "Flutter 3.0.1 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision fb57da5f94 (4 days ago) • 2022-05-19 15:50:29 -0700\nEngine • revision caaafc5604\nTools • Dart 2.17.1 • DevTools 2.12.2\n"; + static const String buildAt = "2022-05-24 13:07:20.629833"; + static const int modifications = 2; } diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 7cbb98a5..7a4efdf0 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -81,6 +81,7 @@ class MessageLookup extends MessageLookupByLibrary { "choosePrivateKey": MessageLookupByLibrary.simpleMessage("Choose private key"), "clear": MessageLookupByLibrary.simpleMessage("Clear"), + "clickSee": MessageLookupByLibrary.simpleMessage("Click here"), "close": MessageLookupByLibrary.simpleMessage("Close"), "containerStatus": MessageLookupByLibrary.simpleMessage("Container status"), diff --git a/lib/generated/intl/messages_zh.dart b/lib/generated/intl/messages_zh.dart index b953e8fd..657a15e6 100644 --- a/lib/generated/intl/messages_zh.dart +++ b/lib/generated/intl/messages_zh.dart @@ -76,6 +76,7 @@ class MessageLookup extends MessageLookupByLibrary { "chooseDestination": MessageLookupByLibrary.simpleMessage("选择目标"), "choosePrivateKey": MessageLookupByLibrary.simpleMessage("选择私钥"), "clear": MessageLookupByLibrary.simpleMessage("清除"), + "clickSee": MessageLookupByLibrary.simpleMessage("点击查看"), "close": MessageLookupByLibrary.simpleMessage("关闭"), "containerStatus": MessageLookupByLibrary.simpleMessage("容器状态"), "convert": MessageLookupByLibrary.simpleMessage("转换"), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index d6421246..272fc840 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -1300,6 +1300,16 @@ class S { args: [], ); } + + /// `Click here` + String get clickSee { + return Intl.message( + 'Click here', + name: 'clickSee', + desc: '', + args: [], + ); + } } class AppLocalizationDelegate extends LocalizationsDelegate { diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 6e7f47d6..76465ce6 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -123,5 +123,6 @@ "restoreSureWithDate": "Are you sure to restore from {date} ?", "backupVersionNotMatch": "Backup version is not match.", "invalidJson": "Invalid JSON", - "restoreSuccess": "Restore success. Restart app to apply." + "restoreSuccess": "Restore success. Restart app to apply.", + "clickSee": "Click here" } \ No newline at end of file diff --git a/lib/l10n/intl_zh.arb b/lib/l10n/intl_zh.arb index a807cfb4..f5bfa7ed 100644 --- a/lib/l10n/intl_zh.arb +++ b/lib/l10n/intl_zh.arb @@ -123,5 +123,6 @@ "restoreSureWithDate": "确定恢复 {date} 的备份吗?", "backupVersionNotMatch": "备份版本不匹配,无法恢复", "invalidJson": "无效的json,存在格式问题", - "restoreSuccess": "恢复成功,需要重启App来应用更改" + "restoreSuccess": "恢复成功,需要重启App来应用更改", + "clickSee": "点击查看" } \ No newline at end of file diff --git a/lib/view/page/apt.dart b/lib/view/page/apt.dart index a3032a95..601dff84 100644 --- a/lib/view/page/apt.dart +++ b/lib/view/page/apt.dart @@ -136,10 +136,10 @@ class _AptManagePageState extends State SizedBox( height: _media.size.height * 0.4, child: Padding( - padding: EdgeInsets.all(17), + padding: const EdgeInsets.all(17), child: RoundRectCard( SingleChildScrollView( - padding: EdgeInsets.all(17), + padding: const EdgeInsets.all(17), child: Text( apt.error!, textAlign: TextAlign.center, diff --git a/lib/view/page/server/tab.dart b/lib/view/page/server/tab.dart index 18198a4f..9c97bde9 100644 --- a/lib/view/page/server/tab.dart +++ b/lib/view/page/server/tab.dart @@ -3,10 +3,10 @@ import 'package:circle_chart/circle_chart.dart'; import 'package:dropdown_button2/dropdown_button2.dart'; import 'package:flutter/material.dart'; import 'package:get_it/get_it.dart'; -import 'package:marquee/marquee.dart'; import 'package:provider/provider.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:toolbox/core/route.dart'; +import 'package:toolbox/core/utils.dart'; import 'package:toolbox/data/model/app/menu_item.dart'; import 'package:toolbox/data/model/server/server.dart'; import 'package:toolbox/data/model/server/server_connection_state.dart'; @@ -167,19 +167,10 @@ class _ServerPageState extends State Row( children: [ hasError - ? ConstrainedBox( - constraints: BoxConstraints( - maxWidth: _media.size.width * 0.57, - maxHeight: 15), - child: Marquee( - accelerationDuration: const Duration(seconds: 3), - accelerationCurve: Curves.linear, - decelerationDuration: const Duration(seconds: 3), - decelerationCurve: Curves.linear, - text: topRightStr, - textScaleFactor: 1.0, - style: style), - ) + ? GestureDetector( + onTap: () => showRoundDialog( + context, s.error, Text(ss.failedInfo ?? ''), []), + child: Text(s.clickSee, style: style)) : Text(topRightStr, style: style, textScaleFactor: 1.0), _buildMoreBtn(spi), ], diff --git a/pubspec.lock b/pubspec.lock index 906ded6f..8c8c46d3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -159,13 +159,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.3.0" - fading_edge_scrollview: - dependency: transitive - description: - name: fading_edge_scrollview - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" fake_async: dependency: transitive description: @@ -326,13 +319,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.2" - marquee: - dependency: "direct main" - description: - name: marquee - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.2" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 80e5df43..c7d3a74b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,7 +54,6 @@ dependencies: clipboard: ^0.1.3 r_upgrade: ^0.3.6 pull_to_refresh: ^2.0.0 - marquee: ^2.2.0 dropdown_button2: ^1.1.1 flutter_advanced_drawer: ^1.3.0 path_provider: ^2.0.9