fix & opt

- display when client.run no result
- remove dep. marquee
This commit is contained in:
Junyuan Feng
2022-05-24 13:25:44 +08:00
parent cb5aed8e79
commit 64196a7ba6
12 changed files with 40 additions and 42 deletions

View File

@@ -89,7 +89,8 @@ class AptProvider extends BusyProvider {
default: default:
// avoid other outputs // 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...] // 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) { if (idx != -1) {
list = list.sublist(idx); list = list.sublist(idx);
} }

View File

@@ -176,7 +176,12 @@ class ServerProvider extends BusyProvider {
logger.info( logger.info(
'Connected to [${spi.name}] in [${time2.difference(time1).toString()}].'); 'Connected to [${spi.name}] in [${time2.difference(time1).toString()}].');
s.connectionState = ServerConnectionState.connected; 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) { } catch (e) {
s.connectionState = ServerConnectionState.failed; s.connectionState = ServerConnectionState.failed;
s.status.failedInfo = '$e ## '; s.status.failedInfo = '$e ## ';
@@ -189,13 +194,15 @@ class ServerProvider extends BusyProvider {
// if client is null, return // if client is null, return
if (s.client == null) return; if (s.client == null) return;
final raw = await s.client!.run("sh $shellPath").string; 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.connectionState = ServerConnectionState.failed;
s.status.failedInfo = 'Empty output'; if (s.status.failedInfo == null || s.status.failedInfo!.isEmpty) {
s.status.failedInfo = 'No data received';
}
notifyListeners(); notifyListeners();
return; return;
} }
final lines = raw.split(seperator).map((e) => e.trim()).toList();
lines.removeAt(0); lines.removeAt(0);
try { try {

View File

@@ -2,9 +2,9 @@
class BuildData { class BuildData {
static const String name = "ServerBox"; static const String name = "ServerBox";
static const int build = 143; static const int build = 144;
static const String engine = 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"; "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-23 17:48:09.246927"; static const String buildAt = "2022-05-24 13:07:20.629833";
static const int modifications = 0; static const int modifications = 2;
} }

View File

@@ -81,6 +81,7 @@ class MessageLookup extends MessageLookupByLibrary {
"choosePrivateKey": "choosePrivateKey":
MessageLookupByLibrary.simpleMessage("Choose private key"), MessageLookupByLibrary.simpleMessage("Choose private key"),
"clear": MessageLookupByLibrary.simpleMessage("Clear"), "clear": MessageLookupByLibrary.simpleMessage("Clear"),
"clickSee": MessageLookupByLibrary.simpleMessage("Click here"),
"close": MessageLookupByLibrary.simpleMessage("Close"), "close": MessageLookupByLibrary.simpleMessage("Close"),
"containerStatus": "containerStatus":
MessageLookupByLibrary.simpleMessage("Container status"), MessageLookupByLibrary.simpleMessage("Container status"),

View File

@@ -76,6 +76,7 @@ class MessageLookup extends MessageLookupByLibrary {
"chooseDestination": MessageLookupByLibrary.simpleMessage("选择目标"), "chooseDestination": MessageLookupByLibrary.simpleMessage("选择目标"),
"choosePrivateKey": MessageLookupByLibrary.simpleMessage("选择私钥"), "choosePrivateKey": MessageLookupByLibrary.simpleMessage("选择私钥"),
"clear": MessageLookupByLibrary.simpleMessage("清除"), "clear": MessageLookupByLibrary.simpleMessage("清除"),
"clickSee": MessageLookupByLibrary.simpleMessage("点击查看"),
"close": MessageLookupByLibrary.simpleMessage("关闭"), "close": MessageLookupByLibrary.simpleMessage("关闭"),
"containerStatus": MessageLookupByLibrary.simpleMessage("容器状态"), "containerStatus": MessageLookupByLibrary.simpleMessage("容器状态"),
"convert": MessageLookupByLibrary.simpleMessage("转换"), "convert": MessageLookupByLibrary.simpleMessage("转换"),

View File

@@ -1300,6 +1300,16 @@ class S {
args: [], args: [],
); );
} }
/// `Click here`
String get clickSee {
return Intl.message(
'Click here',
name: 'clickSee',
desc: '',
args: [],
);
}
} }
class AppLocalizationDelegate extends LocalizationsDelegate<S> { class AppLocalizationDelegate extends LocalizationsDelegate<S> {

View File

@@ -123,5 +123,6 @@
"restoreSureWithDate": "Are you sure to restore from {date} ?", "restoreSureWithDate": "Are you sure to restore from {date} ?",
"backupVersionNotMatch": "Backup version is not match.", "backupVersionNotMatch": "Backup version is not match.",
"invalidJson": "Invalid JSON", "invalidJson": "Invalid JSON",
"restoreSuccess": "Restore success. Restart app to apply." "restoreSuccess": "Restore success. Restart app to apply.",
"clickSee": "Click here"
} }

View File

@@ -123,5 +123,6 @@
"restoreSureWithDate": "确定恢复 {date} 的备份吗?", "restoreSureWithDate": "确定恢复 {date} 的备份吗?",
"backupVersionNotMatch": "备份版本不匹配,无法恢复", "backupVersionNotMatch": "备份版本不匹配,无法恢复",
"invalidJson": "无效的json存在格式问题", "invalidJson": "无效的json存在格式问题",
"restoreSuccess": "恢复成功需要重启App来应用更改" "restoreSuccess": "恢复成功需要重启App来应用更改",
"clickSee": "点击查看"
} }

View File

@@ -136,10 +136,10 @@ class _AptManagePageState extends State<AptManagePage>
SizedBox( SizedBox(
height: _media.size.height * 0.4, height: _media.size.height * 0.4,
child: Padding( child: Padding(
padding: EdgeInsets.all(17), padding: const EdgeInsets.all(17),
child: RoundRectCard( child: RoundRectCard(
SingleChildScrollView( SingleChildScrollView(
padding: EdgeInsets.all(17), padding: const EdgeInsets.all(17),
child: Text( child: Text(
apt.error!, apt.error!,
textAlign: TextAlign.center, textAlign: TextAlign.center,

View File

@@ -3,10 +3,10 @@ import 'package:circle_chart/circle_chart.dart';
import 'package:dropdown_button2/dropdown_button2.dart'; import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart'; import 'package:get_it/get_it.dart';
import 'package:marquee/marquee.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:toolbox/core/route.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/app/menu_item.dart';
import 'package:toolbox/data/model/server/server.dart'; import 'package:toolbox/data/model/server/server.dart';
import 'package:toolbox/data/model/server/server_connection_state.dart'; import 'package:toolbox/data/model/server/server_connection_state.dart';
@@ -167,19 +167,10 @@ class _ServerPageState extends State<ServerPage>
Row( Row(
children: [ children: [
hasError hasError
? ConstrainedBox( ? GestureDetector(
constraints: BoxConstraints( onTap: () => showRoundDialog(
maxWidth: _media.size.width * 0.57, context, s.error, Text(ss.failedInfo ?? ''), []),
maxHeight: 15), child: Text(s.clickSee, style: style))
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),
)
: Text(topRightStr, style: style, textScaleFactor: 1.0), : Text(topRightStr, style: style, textScaleFactor: 1.0),
_buildMoreBtn(spi), _buildMoreBtn(spi),
], ],

View File

@@ -159,13 +159,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.3.0" 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: fake_async:
dependency: transitive dependency: transitive
description: description:
@@ -326,13 +319,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.2" version: "1.0.2"
marquee:
dependency: "direct main"
description:
name: marquee
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.2"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:

View File

@@ -54,7 +54,6 @@ dependencies:
clipboard: ^0.1.3 clipboard: ^0.1.3
r_upgrade: ^0.3.6 r_upgrade: ^0.3.6
pull_to_refresh: ^2.0.0 pull_to_refresh: ^2.0.0
marquee: ^2.2.0
dropdown_button2: ^1.1.1 dropdown_button2: ^1.1.1
flutter_advanced_drawer: ^1.3.0 flutter_advanced_drawer: ^1.3.0
path_provider: ^2.0.9 path_provider: ^2.0.9