mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
new: server tag
This commit is contained in:
@@ -16,6 +16,8 @@ class ServerPrivateInfo {
|
||||
late String pwd;
|
||||
@HiveField(5)
|
||||
String? pubKeyId;
|
||||
@HiveField(6)
|
||||
List<String>? tags;
|
||||
|
||||
late String id;
|
||||
|
||||
@@ -26,6 +28,7 @@ class ServerPrivateInfo {
|
||||
required this.user,
|
||||
required this.pwd,
|
||||
this.pubKeyId,
|
||||
this.tags,
|
||||
}) : id = '$user@$ip:$port';
|
||||
|
||||
ServerPrivateInfo.fromJson(Map<String, dynamic> json) {
|
||||
@@ -36,6 +39,7 @@ class ServerPrivateInfo {
|
||||
pwd = json["authorization"].toString();
|
||||
pubKeyId = json["pubKeyId"]?.toString();
|
||||
id = '$user@$ip:$port';
|
||||
tags = json["tags"]?.cast<String>();
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@@ -46,6 +50,11 @@ class ServerPrivateInfo {
|
||||
data["user"] = user;
|
||||
data["authorization"] = pwd;
|
||||
data["pubKeyId"] = pubKeyId;
|
||||
data["tags"] = tags;
|
||||
return data;
|
||||
}
|
||||
|
||||
bool shouldReconnect(ServerPrivateInfo old) {
|
||||
return id != id || pwd != old.pwd || pubKeyId != old.pubKeyId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,14 @@ class ServerPrivateInfoAdapter extends TypeAdapter<ServerPrivateInfo> {
|
||||
user: fields[3] as String,
|
||||
pwd: fields[4] as String,
|
||||
pubKeyId: fields[5] as String?,
|
||||
tags: (fields[6] as List?)?.cast<String>(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, ServerPrivateInfo obj) {
|
||||
writer
|
||||
..writeByte(6)
|
||||
..writeByte(7)
|
||||
..writeByte(0)
|
||||
..write(obj.name)
|
||||
..writeByte(1)
|
||||
@@ -41,7 +42,9 @@ class ServerPrivateInfoAdapter extends TypeAdapter<ServerPrivateInfo> {
|
||||
..writeByte(4)
|
||||
..write(obj.pwd)
|
||||
..writeByte(5)
|
||||
..write(obj.pubKeyId);
|
||||
..write(obj.pubKeyId)
|
||||
..writeByte(6)
|
||||
..write(obj.tags);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -8,20 +8,16 @@ class Snippet {
|
||||
late String name;
|
||||
@HiveField(1)
|
||||
late String script;
|
||||
@HiveField(2)
|
||||
List<String>? tags;
|
||||
Snippet(this.name, this.script, {this.tags});
|
||||
Snippet(this.name, this.script);
|
||||
|
||||
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;
|
||||
data['script'] = script;
|
||||
data['tags'] = tags;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,20 +19,17 @@ class SnippetAdapter extends TypeAdapter<Snippet> {
|
||||
return Snippet(
|
||||
fields[0] as String,
|
||||
fields[1] as String,
|
||||
tags: (fields[2] as List?)?.cast<String>(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, Snippet obj) {
|
||||
writer
|
||||
..writeByte(3)
|
||||
..writeByte(2)
|
||||
..writeByte(0)
|
||||
..write(obj.name)
|
||||
..writeByte(1)
|
||||
..write(obj.script)
|
||||
..writeByte(2)
|
||||
..write(obj.tags);
|
||||
..write(obj.script);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user