Fix scorll error.

This commit is contained in:
Junyuan Feng
2022-05-05 13:31:45 +08:00
parent 521ff998af
commit f9aa3b1728
8 changed files with 32 additions and 24 deletions

View File

@@ -14,8 +14,10 @@ class Cpu2Status {
return used.isNaN ? 0 : 100 - used * 100;
}
Cpu2Status update(List<CpuStatus> newStatus, String newTemp) {
return Cpu2Status(now, newStatus, newTemp);
void update(List<CpuStatus> newStatus, String newTemp) {
pre = now;
now = newStatus;
temp = newTemp;
}
int get coresCount => now.length;

View File

@@ -21,7 +21,10 @@ class NetSpeed {
return devices;
}
NetSpeed update(List<NetSpeedPart> newOne) => NetSpeed(now, newOne);
void update(List<NetSpeedPart> newOne) {
old = now;
now = newOne;
}
int get timeDiff => now[0].time - old[0].time;

View File

@@ -29,14 +29,15 @@ List<SSHKeyPair> 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));
}
}

View File

@@ -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;
}