fix(client): 连接后延迟用内核 urltest 实测 + 侧栏套餐到期日接真
ci-pangolin / Lint — shellcheck (push) Has been cancelled
ci-pangolin / OpenAPI Sync Check (push) Has been cancelled
ci-pangolin / Redline Scan — 脱敏 (UI 文案) (push) Has been cancelled
ci-pangolin / Flutter — analyze + test (push) Has been cancelled

- 延迟:TCP 探针在隧道开启时会被路由进隧道而测不到(显示 —)。改为连接后
  (phase==on)取内核 statsStream 的 urltest delayMs 最小正值(代理真实 RTT),
  未连接时仍用节点 TCP 探针。连接页 _SpeedRow/_NodePill/_CurrentNodeCard
  与统计页平均延迟统一此口径。
- plan_badge_card(侧栏)接 me.expiresAt 显示真实到期日(原只显示「有效期至」
  无日期);account_page 之外漏改的最后一处。

flutter analyze 0 error;114 tests passed。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-19 00:44:46 +08:00
parent 93ec421c41
commit f35bbea0a0
3 changed files with 45 additions and 14 deletions
+10 -1
View File
@@ -6,6 +6,7 @@ import '../models/usage_point.dart';
import '../pangolin_theme.dart';
import '../state/account_providers.dart';
import '../state/app_providers.dart';
import '../state/connection_provider.dart';
import '../state/nodes_provider.dart';
import '../widgets/app_top_bar.dart';
@@ -22,6 +23,14 @@ class StatsPage extends ConsumerWidget {
final me = ref.watch(meProvider).valueOrNull;
final usage = ref.watch(usageProvider(30)).valueOrNull ?? const <UsagePoint>[];
final node = ref.watch(effectiveNodeProvider);
// 延迟:连接后取内核 urltest 实测最小值,否则取节点 TCP 探针 ping。
final stats = ref.watch(vpnStatsProvider).valueOrNull;
final connected = ref.watch(connectionProvider).phase == VpnPhase.on;
var latencyMs = node.ping;
if (connected && stats != null) {
final ds = stats.urltestResults.where((r) => r.delayMs > 0).map((r) => r.delayMs);
if (ds.isNotEmpty) latencyMs = ds.reduce((a, b) => a < b ? a : b);
}
final weekly = (me?.weeklyGb.length == 7) ? me!.weeklyGb : List<double>.filled(7, 0.0);
final maxV = weekly.fold<double>(0, (a, b) => a > b ? a : b);
@@ -33,7 +42,7 @@ class StatsPage extends ConsumerWidget {
final metrics = [
(t.trafficMonth, monthGb.toStringAsFixed(1), 'GB'),
(t.avgPing, node.ping > 0 ? '${node.ping}' : '', 'ms'),
(t.avgPing, latencyMs > 0 ? '$latencyMs' : '', 'ms'),
(t.durMonth, monthHours.toStringAsFixed(1), 'h'),
];