mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
opt.: performance
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -7,7 +7,7 @@ class Conn {
|
||||
final int passive;
|
||||
final int fail;
|
||||
|
||||
Conn({
|
||||
const Conn({
|
||||
required this.maxConn,
|
||||
required this.active,
|
||||
required this.passive,
|
||||
|
||||
@@ -8,7 +8,7 @@ class Disk {
|
||||
final String size;
|
||||
final String avail;
|
||||
|
||||
Disk({
|
||||
const Disk({
|
||||
required this.path,
|
||||
required this.loc,
|
||||
required this.usedPercent,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -9,7 +9,7 @@ class PrivateKeyInfo {
|
||||
@HiveField(1)
|
||||
final String key;
|
||||
|
||||
PrivateKeyInfo({
|
||||
const PrivateKeyInfo({
|
||||
required this.id,
|
||||
required this.key,
|
||||
});
|
||||
|
||||
@@ -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+'));
|
||||
|
||||
@@ -27,7 +27,7 @@ class ServerPrivateInfo {
|
||||
|
||||
final String id;
|
||||
|
||||
ServerPrivateInfo({
|
||||
const ServerPrivateInfo({
|
||||
required this.name,
|
||||
required this.ip,
|
||||
required this.port,
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user