opt.: performance

This commit is contained in:
lollipopkit
2023-09-07 18:41:18 +08:00
parent 3b698fc062
commit b55b8bf831
15 changed files with 50 additions and 39 deletions

View File

@@ -12,7 +12,7 @@ class Backup {
final Map<String, dynamic> dockerHosts;
final Map<String, dynamic> settings;
Backup({
const Backup({
required this.version,
required this.date,
required this.spis,

View File

@@ -4,12 +4,12 @@ import '../../../core/extension/context.dart';
class DynamicColor {
/// 白天模式显示的颜色
Color light;
final Color light;
/// 暗黑模式显示的颜色
Color dark;
final Color dark;
DynamicColor(this.light, this.dark);
const DynamicColor(this.light, this.dark);
Color resolve(BuildContext context) => context.isDark ? dark : light;
}

View File

@@ -30,7 +30,7 @@ import 'dart:convert';
import '/core/utils/platform.dart';
class AppUpdate {
AppUpdate({
const AppUpdate({
required this.changelog,
required this.build,
required this.url,

View File

@@ -7,7 +7,7 @@ class Conn {
final int passive;
final int fail;
Conn({
const Conn({
required this.maxConn,
required this.active,
required this.passive,

View File

@@ -8,7 +8,7 @@ class Disk {
final String size;
final String avail;
Disk({
const Disk({
required this.path,
required this.loc,
required this.usedPercent,

View File

@@ -4,7 +4,7 @@ class Memory {
final int cache;
final int avail;
Memory({
const Memory({
required this.total,
required this.free,
required this.cache,
@@ -80,7 +80,7 @@ class Swap {
final int free;
final int cached;
Swap({
const Swap({
required this.total,
required this.free,
required this.cached,

View File

@@ -9,7 +9,7 @@ class PrivateKeyInfo {
@HiveField(1)
final String key;
PrivateKeyInfo({
const PrivateKeyInfo({
required this.id,
required this.key,
});

View File

@@ -17,7 +17,7 @@ class _ProcValIdxMap {
final int? time;
final int command;
_ProcValIdxMap({
const _ProcValIdxMap({
required this.pid,
this.user,
this.cpu,
@@ -46,7 +46,7 @@ class Proc {
final String? time;
final String command;
Proc({
const Proc({
this.user,
required this.pid,
this.cpu,
@@ -109,14 +109,14 @@ class PsResult {
final List<Proc> procs;
final String? error;
PsResult({
const PsResult({
required this.procs,
this.error,
});
factory PsResult.parse(String raw, {ProcSortMode sort = ProcSortMode.cpu}) {
final lines = raw.split('\n').map((e) => e.trim()).toList();
if (lines.isEmpty) return PsResult(procs: [], error: null);
if (lines.isEmpty) return const PsResult(procs: [], error: null);
final header = lines[0];
final parts = header.split(RegExp(r'\s+'));

View File

@@ -27,7 +27,7 @@ class ServerPrivateInfo {
final String id;
ServerPrivateInfo({
const ServerPrivateInfo({
required this.name,
required this.ip,
required this.port,

View File

@@ -7,18 +7,18 @@ part 'snippet.g.dart';
@HiveType(typeId: 2)
class Snippet implements TagPickable {
@HiveField(0)
late String name;
final String name;
@HiveField(1)
late String script;
final String script;
@HiveField(2)
late List<String>? tags;
Snippet(this.name, this.script, this.tags);
final List<String>? tags;
const Snippet(this.name, this.script, this.tags);
Snippet.fromJson(Map<String, dynamic> json)
: name = json['name'].toString(),
script = json['script'].toString(),
tags = json['tags']?.cast<String>();
Snippet.fromJson(Map<String, dynamic> json) {
name = json['name'].toString();
script = json['script'].toString();
tags = json['tags']?.cast<String>();
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['name'] = name;
@@ -35,3 +35,10 @@ class Snippet implements TagPickable {
@override
String get tagName => name;
}
/// Snippet for installing ServerBoxMonitor
const installSBM = Snippet(
'Install ServerBoxMonitor',
'curl -fsSL https://raw.githubusercontent.com/lollipopkit/server_box_monitor/main/install.sh | sh -s -- install',
null,
);

View File

@@ -1,8 +1,6 @@
class Temperatures {
final Map<String, double> _map = {};
Temperatures();
void parse(String type, String value) {
const noMatch = "/sys/class/thermal/thermal_zone*/type";
// Not support to get CPU temperature