Skip to content

fix: 阅读器首行文字裁切、正文贴吧链接内页打开与楼中楼图片占位 - #85

Open
IamNewHands wants to merge 2 commits into
infinityf4p:mainfrom
IamNewHands:fix/reader-text-clip-and-in-app-links
Open

IamNewHands wants to merge 2 commits into
infinityf4p:mainfrom
IamNewHands:fix/reader-text-clip-and-in-app-links

Conversation

@IamNewHands

Copy link
Copy Markdown

三个阅读器缺陷修复,只动 8 个既有文件,不涉及 project.pbxproj。

1. 主楼 / 回复标题首行被裁切

CoreText 会报告没有 ascent 溢出,而 iOS 17+ 的 .oversize 仍可能把首行画到容器原点之上,越过原来那点固定余量,于是部分帖子与回复标题丢掉顶部像素。

改为始终测量首行字形的墨迹:顶部 inset 至少 3pt,并把 usedRect.minY 的负向溢出计入测量高度,标题不会再被裁切。

2. 正文里的贴吧链接不再跳出应用

帖子正文里的 tieba.baidu.com 链接此前直接交给 UIApplication.shared.open:装了官方客户端就跳官方客户端,否则跳 Safari,应用内没有拦截点。

现在链接回调先过 ExternalRoute.parse:命中 /p/<id> 或 /f?kw= 就在阅读器内打开,未命中才保留原来的外部打开。帖子详情与楼中楼弹窗各自持有一个 fullScreenCover(楼中楼弹窗打开时,它背后的阅读器已经在呈现 sheet,无法再呈现第二个 cover),因此从链接打开的帖子还能继续在内部打开下一层链接。

3. 楼中楼内联预览的图片占位

楼层下方的楼中楼预览走 InlineContentText,而它对 .image / .video 是直接跳过,所以只有图片的楼中楼在预览里只剩「用户名: 」一行空白,读起来像一条空回复。

现在媒体块折叠为 [图片] / [视频],与既有的 [语音] 一致;「查看全部 N 条回复」弹窗本来就经 ContentBlocksView 渲染真实图片,未改动。

说明

  • 不含 fork 的 CI / 打包改动:.github/workflows/* 一行未动,project.yml 与上游逐字节相同(构建号仍是上游的 58)。
  • 新增用例:内联占位文本与朗读文本、楼中楼图片块映射、正文链接校验与路由判定一致。
  • 已在 fork 上用上游的 .github/workflows/ci.yml(本 PR 未改动它)跑通:单元测试全量 + 13 项 UI 冒烟 + iPad 布局 + Release 构建与 bundled notices 校验 —— https://github.com/IamNewHands/TiebaPure-iOS/actions/runs/37022428656

CoreText can report no ascent overflow while iOS 17+ .oversize still draws the
first line high enough to slip under the small fixed guard, so some post and
reply headings lost their top pixels.

Always measure the first line's glyph ink, floor the top inset at 3pt, and
reserve the negative usedRect.minY extent in the measured height so a heading
can never be clipped. Update the smoke test to the measured-height contract.
两个阅读器缺口:

1. 帖子正文里的 tieba.baidu.com 链接此前直接交给
   UIApplication.shared.open,装了官方客户端就跳官方客户端,否则跳
   Safari,应用内没有任何拦截点。现在 InlineContentText 的链接回调先过
   ExternalRoute.parse:命中 /p/<id> 或 /f?kw= 就在阅读器内打开,未命中
   才保留原来的外部打开。帖子详情与楼中楼弹窗各自持有一个
   fullScreenCover——楼中楼弹窗打开时,它背后的阅读器已经在呈现 sheet,
   无法再呈现第二个 cover——因此从链接打开的帖子还能继续在内部打开下一
   层链接。

2. 楼中楼的内联预览走 InlineContentText,而它对 .image/.video 是直接
   break,只有图片的楼中楼在楼层下只剩「用户名: 」一行空白。现在媒体块
   折叠为 [图片]/[视频],与既有的 [语音] 一致;完整弹窗本来就经
   ContentBlocksView 渲染真实图片,未改动。

测试:ContentMappingTests 覆盖楼中楼图片块映射;TiebaPureSmokeTests 覆盖
内联占位文本与朗读文本;TiebaURLTests 覆盖正文链接校验与路由判定一致。
本机无 Xcode,编译与用例由 CI 验证。构建号 68 → 69(project.yml 两处 +
project.pbxproj 四处,与 project.yml 保持一致)。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant