Skip to content

feat(settings): point users to the FutureOS official account - #831

Merged
huichen merged 1 commit into
mainfrom
feat/wechat-entry
Sep 25, 2026
Merged

huichen merged 1 commit into
mainfrom
feat/wechat-entry

Conversation

@huichen

@huichen huichen commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

背景

公众号此前在两个客户端里都没有入口 —— 用户只能从文章或外部渠道知道它的存在。这个 PR 给两端各加一个入口:桌面放在 设置 → 关于(与「官网 / GitHub」并列),移动放在 设置 → 本机 → 公众号(独立页面)。

为什么两端的主动作不一样

微信生态里没有「搜索公众号」的 URL scheme,且文章链接在系统浏览器里打开看不到关注按钮(关注入口只在微信内)。实测这个账号的二维码解出来是 http://weixin.qq.com/r/mp/...,打开后会 window.location="weixin://qr/...":

  • 桌面:手机扫电脑屏幕一步到位 → 二维码是主路径,扫码提示不可省。
  • 移动:手机扫不了自己的屏幕,且二维码要先存相册再进微信识别 → 复制公众号名才是主路径(粘进微信搜索框),二维码留给「旁边的人扫你这台手机」。

因为微信桌面版无法打开公众号关注页,「在微信中打开」这类按钮在桌面端会是死按钮,所以两端都只提供「复制公众号名 / 阅读文章」。

关键不变量:离线可用

移动端设置页里其它每一行都用 !remote.desktopOnline / !enabled 之类条件 disable 掉了,而关注公众号不需要任何连接。所以这一行的 disabled 恒为 false,并写了一条测试锁住它(同时校验桌面离线时仍可点、仍能进入该页)——否则以后有人照着旁边几行「顺手补上」一个 disable 条件,就会恰好在用户没有桌面端可用时把这个入口堵死。

二维码资源

不是照搬微信导出的图,而是用账号自身的载荷重新编码:

微信原图 + 中心 logo 本 PR 的纯码
模块数 37×37 33×33
纠错等级 Q Q(相同)
中心遮挡 有(~20%) 无

用独立解码器(zxing-cpp)核对过:微信原图本身就是 EC-Q,所以纯码是「同级纠错、模块更少、无遮挡」,在同样显示尺寸下每个模块更大。载荷逐字节相同,扫码行为一致。

顺带排除了一处易混资源:仓库里 .screenshots/wechat-qr.png 是企业微信客服码(work.weixin.qq.com/...),不是公众号关注码;两者肉眼很像,不能互相替换。

验证

scoped 检查(本次只动 desktop/ 与 mobile/ 的 TS 与资源):

  • mobile:tsc --noEmit 干净,eslint 干净,jest 126 suites / 2001 tests 全绿
  • desktop:tsc --noEmit 干净,eslint 干净,vitest 145 files / 1255 tests 全绿

新写的断言都证伪过一次(改坏被测行为后确认测试真的失败):桌面端改错文章 URL → 失败;移动端给入口行加 disabled → 失败。

此外用真实界面做了像素级验证:在本地无头 Chrome 里渲染两端 UI、截图,再从截图里解码二维码,两端都还原出正确载荷 —— 这端到端证明了「资源导入 → React 渲染 → 实际显示尺寸 → 仍可扫」,而不是只断言样式盒尺寸。

风险与回滚

低。纯新增入口,不改动既有交互;唯一被改的既有文件是 AboutPage.tsx(挂一行卡片)、SettingsScreen.tsx(加一个路由 + 一行链接)与两份 i18n。要回滚删掉卡片/这一行即可,无数据或协议面影响。

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).
@huichen
huichen enabled auto-merge (squash) September 25, 2026 11:19
@huichen
huichen merged commit ba98fdb into main Sep 25, 2026
12 checks passed
@huichen
huichen deleted the feat/wechat-entry branch September 25, 2026 11:21
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