Repository navigation
feat(settings): point users to the FutureOS official account - #831
Merged
Merged
Conversation
The WeChat account has no discovery path from inside the apps, so add one entry point on each client. Following the account needs no server and no paired desktop, so both entries stay usable offline. Desktop: a card on Settings → About, beside the Website and GitHub rows. Mobile: Settings → This phone → Official account, as its own screen. Every other row there is gated on the paired desktop; this one deliberately is not, and a test pins that so a later edit cannot strand it exactly when the user has no desktop at hand. The QR asset is re-encoded from the account's own payload rather than a copy of WeChat's artwork: same error-correction level (Q) in fewer modules (33 vs 37), so each module is larger at the size we render and nothing covers the data area. The account name is copied for the mobile case, where a phone cannot scan its own screen (the WeChat desktop build cannot open an account's follow page either, so no such action is offered there).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
公众号此前在两个客户端里都没有入口 —— 用户只能从文章或外部渠道知道它的存在。这个 PR 给两端各加一个入口:桌面放在 设置 → 关于(与「官网 / GitHub」并列),移动放在 设置 → 本机 → 公众号(独立页面)。
为什么两端的主动作不一样
微信生态里没有「搜索公众号」的 URL scheme,且文章链接在系统浏览器里打开看不到关注按钮(关注入口只在微信内)。实测这个账号的二维码解出来是
http://weixin.qq.com/r/mp/...,打开后会window.location="weixin://qr/...":因为微信桌面版无法打开公众号关注页,「在微信中打开」这类按钮在桌面端会是死按钮,所以两端都只提供「复制公众号名 / 阅读文章」。
关键不变量:离线可用
移动端设置页里其它每一行都用
!remote.desktopOnline/!enabled之类条件 disable 掉了,而关注公众号不需要任何连接。所以这一行的disabled恒为false,并写了一条测试锁住它(同时校验桌面离线时仍可点、仍能进入该页)——否则以后有人照着旁边几行「顺手补上」一个 disable 条件,就会恰好在用户没有桌面端可用时把这个入口堵死。二维码资源
不是照搬微信导出的图,而是用账号自身的载荷重新编码:
用独立解码器(zxing-cpp)核对过:微信原图本身就是 EC-Q,所以纯码是「同级纠错、模块更少、无遮挡」,在同样显示尺寸下每个模块更大。载荷逐字节相同,扫码行为一致。
顺带排除了一处易混资源:仓库里
.screenshots/wechat-qr.png是企业微信客服码(work.weixin.qq.com/...),不是公众号关注码;两者肉眼很像,不能互相替换。验证
scoped 检查(本次只动 desktop/ 与 mobile/ 的 TS 与资源):
tsc --noEmit干净,eslint干净,jest 126 suites / 2001 tests 全绿tsc --noEmit干净,eslint干净,vitest 145 files / 1255 tests 全绿新写的断言都证伪过一次(改坏被测行为后确认测试真的失败):桌面端改错文章 URL → 失败;移动端给入口行加
disabled→ 失败。此外用真实界面做了像素级验证:在本地无头 Chrome 里渲染两端 UI、截图,再从截图里解码二维码,两端都还原出正确载荷 —— 这端到端证明了「资源导入 → React 渲染 → 实际显示尺寸 → 仍可扫」,而不是只断言样式盒尺寸。
风险与回滚
低。纯新增入口,不改动既有交互;唯一被改的既有文件是
AboutPage.tsx(挂一行卡片)、SettingsScreen.tsx(加一个路由 + 一行链接)与两份 i18n。要回滚删掉卡片/这一行即可,无数据或协议面影响。