服务器状态页预览部分完成

This commit is contained in:
LollipopKit
2021-09-18 19:03:06 +08:00
parent 2c9b08264f
commit 962ef4ca48
12 changed files with 223 additions and 139 deletions

View File

@@ -17,11 +17,18 @@ class ServerStore extends PersistentStore {
void delete(ServerPrivateInfo s) {
final ss = fetch();
ss.removeWhere((e) => e.ip == s.ip && e.port == s.port && e.user == e.user);
ss.removeAt(index(s));
box.put('servers', json.encode(ss));
}
bool have(ServerPrivateInfo s) => fetch()
.where((e) => e.ip == s.ip && e.port == s.port && e.user == e.user)
.isNotEmpty;
void update(ServerPrivateInfo old, ServerPrivateInfo newInfo) {
final ss = fetch();
ss[index(old)] = newInfo;
box.put('servers', json.encode(ss));
}
int index(ServerPrivateInfo s) => fetch()
.indexWhere((e) => e.ip == s.ip && e.port == s.port && e.user == e.user);
bool have(ServerPrivateInfo s) => index(s) != -1;
}