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.irq,
this.softirq, 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; int get total => user + sys + nice + idle + iowait + irq + softirq;
} }

View File

@@ -25,23 +25,4 @@ class DiskInfo {
this.size, this.size,
this.avail, 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; late String name;
String? ip; late String ip;
int? port; late int port;
String? user; late String user;
Object? authorization; late Object authorization;
String? pubKeyId;
ServerPrivateInfo({ ServerPrivateInfo(
this.name, {required this.name,
this.ip, required this.ip,
this.port, required this.port,
this.user, required this.user,
this.authorization, required this.authorization,
}); this.pubKeyId});
ServerPrivateInfo.fromJson(Map<String, dynamic> json) { ServerPrivateInfo.fromJson(Map<String, dynamic> json) {
name = json["name"]?.toString(); name = json["name"].toString();
ip = json["ip"]?.toString(); ip = json["ip"].toString();
port = json["port"]?.toInt(); port = json["port"].toInt();
user = json["user"]?.toString(); user = json["user"].toString();
authorization = json["authorization"]; authorization = json["authorization"];
pubKeyId = json["pubKeyId"]?.toString();
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{}; final Map<String, dynamic> data = <String, dynamic>{};
@@ -40,11 +42,12 @@ class ServerPrivateInfo {
data["port"] = port; data["port"] = port;
data["user"] = user; data["user"] = user;
data["authorization"] = authorization; data["authorization"] = authorization;
data["pubKeyId"] = pubKeyId;
return data; return data;
} }
} }
List<ServerPrivateInfo>? getServerInfoList(dynamic data) { List<ServerPrivateInfo> getServerInfoList(dynamic data) {
List<ServerPrivateInfo> ss = []; List<ServerPrivateInfo> ss = [];
if (data is String) { if (data is String) {
data = json.decode(data); data = json.decode(data);

View File

@@ -50,9 +50,9 @@ class ServerProvider extends BusyProvider {
SSHClient genClient(ServerPrivateInfo spi) { SSHClient genClient(ServerPrivateInfo spi) {
return SSHClient( return SSHClient(
host: spi.ip!, host: spi.ip,
port: spi.port!, port: spi.port,
username: spi.user!, username: spi.user,
passwordOrKey: spi.authorization); 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 backendUrl = 'https://v2.custed.lolli.tech';
const baseUrl = backendUrl + '/res/toolbox'; const baseUrl = backendUrl + '/res/toolbox';
const joinQQGroupUrl = 'https://jq.qq.com/?_wv=1027&k=G0hUmPAq'; 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() { List<ServerPrivateInfo> fetch() {
return getServerInfoList( return getServerInfoList(
json.decode(box.get('servers', defaultValue: '[]')!))!; json.decode(box.get('servers', defaultValue: '[]')!));
} }
void delete(ServerPrivateInfo s) { void delete(ServerPrivateInfo s) {

View File

@@ -48,11 +48,19 @@ class _ServerPageState extends State<ServerPage>
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
return Scaffold( return Scaffold(
body: SingleChildScrollView( 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), padding: const EdgeInsets.symmetric(horizontal: 7),
child: AnimationLimiter( child: AnimationLimiter(
child: Consumer<ServerProvider>(builder: (_, pro, __) { child: Column(
return Column(
children: AnimationConfiguration.toStaggeredList( children: AnimationConfiguration.toStaggeredList(
duration: const Duration(milliseconds: 377), duration: const Duration(milliseconds: 377),
childAnimationBuilder: (widget) => SlideAnimation( childAnimationBuilder: (widget) => SlideAnimation(
@@ -65,9 +73,9 @@ class _ServerPageState extends State<ServerPage>
const SizedBox(height: 13), const SizedBox(height: 13),
...pro.servers.map((e) => _buildEachServerCard(e)) ...pro.servers.map((e) => _buildEachServerCard(e))
], ],
)); ))),
})), );
), }),
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: () => onPressed: () =>
AppRoute(const ServerEditPage(), 'Add server info page') AppRoute(const ServerEditPage(), 'Add server info page')