feat(routing): 域名级系统锁冲突提示 + 重置默认按钮 + 客户端 follow-up 清理

承接 FT-A(GET /v1/me/routing 含只读 system_locked_domains)。

- RoutingProfile 加只读 systemLockedDomains(fromJson 读/toJson 不输出);
  routing_screen 冲突检测扩展到域名类规则(domain/domain_suffix/domain_keyword
  命中锁定域名 → systemLocked),ip_cidr 私网启发式保留。
- RoutingProfile.defaults() + RoutingProfileNotifier.resetToDefault()(复用
  _persist:乐观更新/失败回滚/存成功后自动重连,保留只读 systemLockedDomains
  不丢)+ routing_screen 加「重置默认」按钮与二次确认弹层(新增 3 个 l10n 键)。
- RoutingRule.copyWith 用哨兵支持 note 显式清空为 null;RoutingRule/Builtin/
  RoutingProfile 加值相等 operator==/hashCode。
- T8 smartRouteSub 清理:grep 全仓发现 design/prototype/i18n/alias.json →
  gen_proto_i18n.mjs(CI 漂移闸)仍有活引用,按计划口径不删,详见
  .superpowers/sdd/task-FTB-report.md。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-07-29 06:57:58 +08:00
parent 3159dd75c1
commit 2930d76cf3
14 changed files with 410 additions and 17 deletions
@@ -115,6 +115,36 @@ void main() {
expect(api.saved, hasLength(3));
});
test('resetToDefault() 还原出厂档案,保留 systemLockedDomains,并落盘', () async {
final api = _FakeAccountApi()
..initial = RoutingProfile.fromJson({
'mode': 'global',
'builtin': {'china_direct': false, 'lan_direct': true, 'private_via_tunnel': true},
'rules': [
{'type': 'domain', 'value': 'a.com', 'action': 'reject'},
],
'final': 'direct',
'system_locked_domains': ['git.yanmeiai.com'],
});
final c = _makeContainer(api);
addTearDown(c.dispose);
await _waitLoggedIn(c);
await c.read(routingProfileProvider.future);
await c.read(routingProfileProvider.notifier).resetToDefault();
final state = c.read(routingProfileProvider).value!;
expect(state.mode, 'rule');
expect(state.builtin.chinaDirect, isTrue);
expect(state.rules, isEmpty);
expect(state.finalAction, 'proxy');
expect(state.systemLockedDomains, ['git.yanmeiai.com'],
reason: '只读字段随重置保留,不因重置默认档案而丢失');
expect(api.saved, hasLength(1));
expect(api.saved.single.mode, 'rule');
});
test('保存失败:回退到变更前 state 且 rethrow,不静默吞', () async {
final api = _FakeAccountApi();
final c = _makeContainer(api);