v2.0.0: 模组插件管理、下载引擎(镜像+队列)、SSH终端、UI改版与依赖仓库

This commit is contained in:
ZV Dev committed 2026-10-22 23:28:14 +08:00
1 parent b8f163aa3a
commit 33d137e33c
29 files changed
+3061 -30

No files matched your search

+30
View File
@@ -8,20 +8,37 @@ class ServerConfig {
final int port;
final String password;
/// SSH(SFTP / 终端)可选配置,纯 RCON 用户可留空。
final bool sshEnabled;
final int sshPort;
final String sshUser;
final String sshPassword;
ServerConfig({
required this.id,
required this.name,
required this.host,
required this.port,
required this.password,
this.sshEnabled = false,
this.sshPort = 22,
this.sshUser = '',
this.sshPassword = '',
});
/// 是否具备模组/终端功能所需的 SSH 配置。
bool get hasSsh => sshEnabled && sshUser.isNotEmpty;
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'host': host,
'port': port,
'password': password,
'sshEnabled': sshEnabled,
'sshPort': sshPort,
'sshUser': sshUser,
'sshPassword': sshPassword,
};
factory ServerConfig.fromJson(Map<String, dynamic> json) => ServerConfig(
@@ -30,6 +47,10 @@ class ServerConfig {
host: json['host'],
port: json['port'],
password: json['password'],
sshEnabled: json['sshEnabled'] ?? false,
sshPort: json['sshPort'] ?? 22,
sshUser: json['sshUser'] ?? '',
sshPassword: json['sshPassword'] ?? '',
);
}
@@ -61,6 +82,15 @@ class ServerProvider extends ChangeNotifier {
notifyListeners();
}
ServerConfig? byId(String? id) {
if (id == null) return null;
try {
return _servers.firstWhere((s) => s.id == id);
} catch (_) {
return null;
}
}
Future<void> _save() async {
await SecureStorageService.saveServers(_servers);
}