From f9aa3b1728d681d56afa0975c2ce471024775c4a Mon Sep 17 00:00:00 2001 From: Junyuan Feng Date: Thu, 5 May 2022 13:31:45 +0800 Subject: [PATCH] Fix scorll error. --- ios/Runner.xcodeproj/project.pbxproj | 12 ++++++------ lib/data/model/server/cpu_2_status.dart | 6 ++++-- lib/data/model/server/net_speed.dart | 5 ++++- lib/data/provider/server.dart | 24 ++++++++++++------------ lib/data/res/build_data.dart | 6 +++--- lib/view/page/convert.dart | 1 + lib/view/page/ping.dart | 1 + lib/view/page/server/tab.dart | 1 + 8 files changed, 32 insertions(+), 24 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index e1742514..9bdf4a0d 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -354,7 +354,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 122; + CURRENT_PROJECT_VERSION = 123; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -362,7 +362,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.122; + MARKETING_VERSION = 1.0.123; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -484,7 +484,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 122; + CURRENT_PROJECT_VERSION = 123; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -492,7 +492,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.122; + MARKETING_VERSION = 1.0.123; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -508,7 +508,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 122; + CURRENT_PROJECT_VERSION = 123; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -516,7 +516,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.122; + MARKETING_VERSION = 1.0.123; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/data/model/server/cpu_2_status.dart b/lib/data/model/server/cpu_2_status.dart index fc453621..3279ccd2 100644 --- a/lib/data/model/server/cpu_2_status.dart +++ b/lib/data/model/server/cpu_2_status.dart @@ -14,8 +14,10 @@ class Cpu2Status { return used.isNaN ? 0 : 100 - used * 100; } - Cpu2Status update(List newStatus, String newTemp) { - return Cpu2Status(now, newStatus, newTemp); + void update(List newStatus, String newTemp) { + pre = now; + now = newStatus; + temp = newTemp; } int get coresCount => now.length; diff --git a/lib/data/model/server/net_speed.dart b/lib/data/model/server/net_speed.dart index 01205ac9..22ae477f 100644 --- a/lib/data/model/server/net_speed.dart +++ b/lib/data/model/server/net_speed.dart @@ -21,7 +21,10 @@ class NetSpeed { return devices; } - NetSpeed update(List newOne) => NetSpeed(now, newOne); + void update(List newOne) { + old = now; + now = newOne; + } int get timeDiff => now[0].time - old[0].time; diff --git a/lib/data/provider/server.dart b/lib/data/provider/server.dart index 4659d643..7101f505 100644 --- a/lib/data/provider/server.dart +++ b/lib/data/provider/server.dart @@ -29,14 +29,15 @@ List loadIndentity(String key) { return SSHKeyPair.fromPem(key); } -const shellCmd = "cat /proc/net/dev && date +%s \necho A====A \n " - "cat /etc/os-release | grep PRETTY_NAME \necho A====A \n" - "cat /proc/stat | grep cpu \necho A====A \n" - "uptime \necho A====A \n" - "cat /proc/net/snmp \necho A====A \n" - "df -h \necho A====A \n" - "free -m \necho A====A \n" - "cat /sys/class/thermal/thermal_zone*/type \necho A====A \n" +const seperator = 'A====A'; +const shellCmd = "cat /proc/net/dev && date +%s \necho $seperator \n " + "cat /etc/os-release | grep PRETTY_NAME \necho $seperator \n" + "cat /proc/stat | grep cpu \necho $seperator \n" + "uptime \necho $seperator \n" + "cat /proc/net/snmp \necho $seperator \n" + "df -h \necho $seperator \n" + "free -m \necho $seperator \n" + "cat /sys/class/thermal/thermal_zone*/type \necho $seperator \n" "cat /sys/class/thermal/thermal_zone*/temp"; const shellPath = '.serverbox.sh'; final cpuTempReg = RegExp('(x86_pkg_temp|cpu_thermal)'); @@ -190,7 +191,7 @@ class ServerProvider extends BusyProvider { final si = _servers[idx]; if (si.client == null) return; final raw = await si.client!.run("sh $shellPath").string; - final lines = raw.split('A====A').map((e) => e.trim()).toList(); + final lines = raw.split(seperator).map((e) => e.trim()).toList(); try { _getCPU(spi, lines[2], lines[7], lines[8]); @@ -232,7 +233,7 @@ class ServerProvider extends BusyProvider { final bytesOut = int.parse(bytes[8]); results.add(NetSpeedPart(device, bytesIn, bytesOut, time)); } - info.status.netSpeed = info.status.netSpeed.update(results); + info.status.netSpeed.update(results); } void _getSysVer(ServerPrivateInfo spi, String raw) { @@ -285,8 +286,7 @@ class ServerProvider extends BusyProvider { int.parse(matches[6]))); } if (cpus.isNotEmpty) { - info.status.cpu2Status = - info.status.cpu2Status.update(cpus, _getCPUTemp(tempType, tempValue)); + info.status.cpu2Status.update(cpus, _getCPUTemp(tempType, tempValue)); } } diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index fa16a37f..662e3653 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 = 122; + static const int build = 123; static const String engine = "Flutter 2.10.5 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 5464c5bac7 (2 weeks ago) • 2022-04-18 09:55:37 -0700\nEngine • revision 57d3bac3dd\nTools • Dart 2.16.2 • DevTools 2.9.2\n"; - static const String buildAt = "2022-05-04 21:07:15.254894"; - static const int modifications = 5; + static const String buildAt = "2022-05-04 21:08:15.263486"; + static const int modifications = 0; } diff --git a/lib/view/page/convert.dart b/lib/view/page/convert.dart index 1a329875..36537712 100644 --- a/lib/view/page/convert.dart +++ b/lib/view/page/convert.dart @@ -50,6 +50,7 @@ class _ConvertPageState extends State body: GestureDetector( child: SingleChildScrollView( padding: const EdgeInsets.symmetric(horizontal: 7), + controller: ScrollController(), child: Column(children: [ const SizedBox(height: 13), _buildInputTop(), diff --git a/lib/view/page/ping.dart b/lib/view/page/ping.dart index 17b46fbb..961d277c 100644 --- a/lib/view/page/ping.dart +++ b/lib/view/page/ping.dart @@ -48,6 +48,7 @@ class _PingPageState extends State width: double.infinity, height: _media.size.height * 0.6, child: ListView.builder( + controller: ScrollController(), itemCount: _results.length, itemBuilder: (context, index) { final result = _results[index]; diff --git a/lib/view/page/server/tab.dart b/lib/view/page/server/tab.dart index efca2a99..69e6ae05 100644 --- a/lib/view/page/server/tab.dart +++ b/lib/view/page/server/tab.dart @@ -71,6 +71,7 @@ class _ServerPageState extends State } return ListView.separated( padding: const EdgeInsets.all(7), + controller: ScrollController(), itemBuilder: (ctx, idx) { if (idx == pro.servers.length) { return SizedBox(height: _media.padding.bottom);