remove useless function

This commit is contained in:
LollipopKit
2021-10-31 21:40:36 +08:00
parent 2eb6e19a86
commit 1943fde6eb
9 changed files with 46 additions and 71 deletions

View File

@@ -33,28 +33,6 @@ class CpuStatus {
this.irq,
this.softirq,
);
CpuStatus.fromJson(Map<String, dynamic> json) {
id = json["id"];
user = json["user"]?.toInt();
sys = json["sys"]?.toInt();
nice = json["nice"]?.toInt();
idle = json["idle"]?.toInt();
iowait = json["iowait"]?.toInt();
irq = json["irq"]?.toInt();
softirq = json["softirq"]?.toInt();
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data["id"] = id;
data["user"] = user;
data["sys"] = sys;
data["nice"] = nice;
data["idle"] = idle;
data["iowait"] = iowait;
data["irq"] = irq;
data["softirq"] = softirq;
return data;
}
int get total => user + sys + nice + idle + iowait + irq + softirq;
}

View File

@@ -25,23 +25,4 @@ class DiskInfo {
this.size,
this.avail,
);
DiskInfo.fromJson(Map<String, dynamic> json) {
mountPath = json["mountPath"].toString();
mountLocation = json["mountLocation"].toString();
usedPercent = int.parse(json["usedPercent"]);
used = json["used"].toString();
size = json["size"].toString();
avail = json["avail"].toString();
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data["mountPath"] = mountPath;
data["mountLocation"] = mountLocation;
data["usedPercent"] = usedPercent;
data["used"] = used;
data["size"] = size;
data["avail"] = avail;
return data;
}
}

View File

@@ -13,25 +13,27 @@ class ServerPrivateInfo {
}
*/
String? name;
String? ip;
int? port;
String? user;
Object? authorization;
late String name;
late String ip;
late int port;
late String user;
late Object authorization;
String? pubKeyId;
ServerPrivateInfo({
this.name,
this.ip,
this.port,
this.user,
this.authorization,
});
ServerPrivateInfo(
{required this.name,
required this.ip,
required this.port,
required this.user,
required this.authorization,
this.pubKeyId});
ServerPrivateInfo.fromJson(Map<String, dynamic> json) {
name = json["name"]?.toString();
ip = json["ip"]?.toString();
port = json["port"]?.toInt();
user = json["user"]?.toString();
name = json["name"].toString();
ip = json["ip"].toString();
port = json["port"].toInt();
user = json["user"].toString();
authorization = json["authorization"];
pubKeyId = json["pubKeyId"]?.toString();
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
@@ -40,11 +42,12 @@ class ServerPrivateInfo {
data["port"] = port;
data["user"] = user;
data["authorization"] = authorization;
data["pubKeyId"] = pubKeyId;
return data;
}
}
List<ServerPrivateInfo>? getServerInfoList(dynamic data) {
List<ServerPrivateInfo> getServerInfoList(dynamic data) {
List<ServerPrivateInfo> ss = [];
if (data is String) {
data = json.decode(data);

View File

@@ -50,9 +50,9 @@ class ServerProvider extends BusyProvider {
SSHClient genClient(ServerPrivateInfo spi) {
return SSHClient(
host: spi.ip!,
port: spi.port!,
username: spi.user!,
host: spi.ip,
port: spi.port,
username: spi.user,
passwordOrKey: spi.authorization);
}

View File

@@ -0,0 +1,3 @@
import 'package:flutter/widgets.dart';
final appIcon = Image.asset('assets/app_icon.png');

View File

@@ -1,3 +1,5 @@
const backendUrl = 'https://v2.custed.lolli.tech';
const baseUrl = backendUrl + '/res/toolbox';
const joinQQGroupUrl = 'https://jq.qq.com/?_wv=1027&k=G0hUmPAq';
const myGithub = 'https://github.com/LollipopKit';
const rainSunMeGithub = 'https://github.com/RainSunMe';

View File

@@ -12,7 +12,7 @@ class ServerStore extends PersistentStore {
List<ServerPrivateInfo> fetch() {
return getServerInfoList(
json.decode(box.get('servers', defaultValue: '[]')!))!;
json.decode(box.get('servers', defaultValue: '[]')!));
}
void delete(ServerPrivateInfo s) {

View File

@@ -48,12 +48,20 @@ class _ServerPageState extends State<ServerPage>
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
body: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 7),
child: AnimationLimiter(
child: Consumer<ServerProvider>(builder: (_, pro, __) {
return Column(
children: AnimationConfiguration.toStaggeredList(
body: Consumer<ServerProvider>(builder: (_, pro, __) {
if (pro.servers.isEmpty) {
return const Center(
child: Text(
'There is not server.\nClick the fab to add one.',
textAlign: TextAlign.center,
),
);
}
return SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 7),
child: AnimationLimiter(
child: Column(
children: AnimationConfiguration.toStaggeredList(
duration: const Duration(milliseconds: 377),
childAnimationBuilder: (widget) => SlideAnimation(
verticalOffset: 50.0,
@@ -65,9 +73,9 @@ class _ServerPageState extends State<ServerPage>
const SizedBox(height: 13),
...pro.servers.map((e) => _buildEachServerCard(e))
],
));
})),
),
))),
);
}),
floatingActionButton: FloatingActionButton(
onPressed: () =>
AppRoute(const ServerEditPage(), 'Add server info page')