Repository navigation
feat(wechat): M5 微信 JS-SDK 扫码签到——jssdk-signature 接口与微信内扫一扫 - #11
Merged
Merged
Conversation
后端新增 wechat 模块:access_token / jsapi_ticket 内存缓存(tokio RwLock,提前 300s 刷新)与 plain SHA1 签名;GET /api/wechat/jssdk-signature?url= 供前端 wx.config,url 自动去除 # 及其后部分。凭证经 WECHAT_APP_ID / WECHAT_APP_SECRET 注入,未配置返回 40307 而非 panic。 前端新增 MicroMessenger UA 检测与 jweixin 动态注入(幂等),房间页底栏在微信内 新增「微信扫一扫」主按钮,扫码结果与相机扫码同路径(本地预校验 → share_qr 推送全房间);非微信环境保持相机扫码。
- 测试改用 Array.from,消除 IDE 对 for...of NodeListOf 的类型告警(本项目 tsconfig lib 为 ES2023+DOM,未含 DOM.Iterable;tsc -b 实际不受影响) - wx.scanQRCode 的 scanType 限定为 qrCode,避免误扫条形码 - fail 回调 errMsg 含 cancel 时按用户取消处理(部分微信版本行为),返回 null
参照参考实现 qrcode_share:
- 后端新增 GET /api/wechat/status(免会话)返回 {available, reason},只暴露
「是否已配置」不含凭证
- 前端环境预检查:房间页仅在「微信内 且 后端判定可用」时才渲染「微信扫一扫」
入口,未配置时完全不显示,避免点击后才报 40307
- VITE_WX_DEBUG=true 时 wx.config({debug:true}),真机以弹窗输出签名校验细节,
便于定位 invalid signature(默认关闭)
9 of 14 tasks
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.
变更说明
M5:微信内置浏览器扫码签到(SPEC §3.2.2 首选方案)。
backend/src/wechat/:GET /api/wechat/jssdk-signature?url=返回{appId,timestamp,nonceStr,signature}(需本站会话)GET /api/wechat/status免会话可用性探测,只返回{available, reason},不泄露凭证WechatClient内存缓存access_token/jsapi_ticket(默认 7200s,提前 300s 刷新;tokio::sync::RwLock避免跨await持锁)jsapi_ticket=..&noncestr=..×tamp=..&url=..取 plain SHA1(新增sha1依赖),url自动去除#及其后部分WECHAT_APP_ID/WECHAT_APP_SECRET注入;未配置时不 panic,返回 40307src/lib/wechat.ts(MicroMessengerUA 检测、jweixin 1.6.0 幂等动态注入、wx.config→wx.scanQRCode封装,用户取消返回null)与src/api/wechat.tsshare_qr推送全房间);非微信环境保持相机扫码wx.scanQRCode参数对齐参考实现qrcode_share:scanType收紧为['qrCode'];fail中errMsg含cancel按用户取消处理VITE_WX_DEBUG真机调试开关(默认关闭)变更类型
feat新功能fix缺陷修复docs文档refactor重构(不改行为)chore构建/依赖/杂项目标分支
dev(feature/fix 常规合并)main(仅发版合并,dev → main)自查清单
feat/fix/docs/chore/+ 简短描述),基于最新dev创建cargo fmt --check/cargo clippy -D warnings/cargo test通过(后端改动)eslint/tsc --noEmit/ 测试 / 构建通过(前端改动)unwrap()(测试代码除外)、无unsafe、无any关联 issue / 备注
tsc -b --force0、oxlint 0、60 tests、build 通过