Files
FruitServer/docs/plans/INBOX.md
T

26 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## [已处理] 2026-10-20 | K54-A 修复 iOS 启动「剧目列表加载失败」(ATS + 探测顺序)(仅 App 端)
**用户指令(2026-10-20,原文)**:
> 「我现在启动iOS 显示剧目列表加载失败」
**根因(已定位)**
1. `ios/Runner/Info.plist` 只配置了 `NSAllowsLocalNetworking`,它只放行 `.local` 与无点主机名,**不放行** `http://127.0.0.1`、`http://192.168.x.x`、`http://39.162.50.99` 这类明文本 IP 请求 → iOS 上所有接口被 ATS 拦截,首页/剧场报「剧目列表加载失败」。
2. `AppConfig.probeAndApplyBaseUrl()` 只探测 `127.0.0.1:8081`,失败后直接回落到公网 `39.162.50.99:8081`;iOS 真机既没有 adb reverse(127 不可达),公网也可能不可达,于是必然失败。
**口径(只改 Flutter / iOS 配置,不动后端、不改接口)**
1. `Info.plist`:`NSAppTransportSecurity` 中:
- 增加 `NSAllowsArbitraryLoads = true`(开发阶段放开明文);
- 同时保留 `NSAllowsLocalNetworking = true`;
- 增加 `NSExceptionDomains`:`127.0.0.1`、`localhost`、`192.168.31.187`、`39.162.50.99`,均 `NSExceptionAllowsInsecureHTTPLoads = true`、`NSIncludesSubdomains = true`。
2. `AppConfig.probeAndApplyBaseUrl()` 改为按顺序探测并选第一个 200:
`127.0.0.1:8081` → `devHostBaseUrl`(192.168.31.187)→ `publicBaseUrl`;
全部失败时使用平台默认(模拟器/桌面 = 127.0.0.1;真机 = devHostBaseUrl),**不再无条件回落公网**。
3. 探测超时保持 2s/个,不阻塞首帧(首页已有 loading 占位)。
4. Android 行为不回退:有 `adb reverse` 时仍优先 127.0.0.1,无 reverse 时会尝试开发机局域网地址,最后公网。
**测试/门禁**
- 单元测试:探测候选顺序与「全部失败时使用平台默认」;
- `dart analyze lib test` 零告警 + `flutter test` 全过 + `flutter build apk --debug`(iOS 构建由用户在 Xcode 执行)。
**流程**:从 `develop` 拉 `fix/ios-k54-network`;作者 `Zhou Weidong <502333560@qq.com>`;`--no-ff` 合回 develop 并 push;PROGRESS 留痕;真机验收由用户执行(iOS 模拟器/真机冷启动能正常加载首页)。