发布网络质量探测 1.1.2:新增客户端源文件(二)

署名:言灸
This commit is contained in:
YanJiu committed 2026-11-20 18:58:39 +08:00
1 parent bc39956b6c
commit 6dcc2c4b89
4 files changed
+297

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
// Copyright (C) 2026 言灸
// SPDX-License-Identifier: AGPL-3.0-only
import 'probe_profile.dart';
/// Keeps a port the user typed. An empty field or a value that is still the
/// previous profile's default follows the newly selected profile.
String portAfterProfileChange({
required String current,
required int previousDefault,
required int nextDefault,
}) {
final trimmed = current.trim();
if (trimmed.isEmpty || int.tryParse(trimmed) == previousDefault) {
return '$nextDefault';
}
return current;
}
String portHint(ProbeProfile profile) {
switch (profile.id) {
case 'nq-tcp':
return '合作反射 TCP 默认 19090';
case 'nq-udp':
return '合作反射 UDP 默认 19091';
default:
return '${profile.label} 默认 ${profile.port}';
}
}
const portHelperText =
'合作反射 TCP 默认 19090,UDP 默认 19091。只有当前端口仍是上一种类型的默认值或为空时,切换类型才会自动更换。';