Phase 4.A:登录+分享 stub + QQ 改走 URL Scheme 不依 SDK

按用户约定调整 Phase 4 方向:微信继续走 SDK(等项目方提供),QQ 分享
改用 URL Scheme 直接调起 QQ app,**不依赖 SDK**。

调研 daoqi/msext/Class/Utils/QQShareManager.m 发现已有完整的 URL Scheme
fallback 路径:
  - line 14: __has_include(<TencentOpenAPI/QQApiInterface.h>) 条件编译
  - line 231 注释: "Fallback: 使用 URL Scheme (mqqapi://) - 无需 SDK,
    直接调起 (Legacy)"
  - mqqapi://share/to_fri / mqqapi://share/to_qzone / mqqopensdkfriend://share
    等 schema 实现见 line 733/786/789

新增 handler stub(让 H5 启动 / 业务期调登录 / 分享不报 "no handler"):
  - Source/Bridge/Handlers/AccreditLoginHandler.swift
    accreditlogin cb "Response from accreditlogin"
    完整实现需 Phase 4.B 微信 SDK + WeChatManager.authorize() + WeChatAuth.exchangeForUser
    + bridge.call("sharelogin", 7 字段含大写 Province) 反向 callback
  - Source/Bridge/Handlers/FriendsShareHandler.swift
    friendsSharetypeUrlToptitleDescript cb "sharefriend"
    完整实现需 ShareCenter 策略分发 + sharesuccess 反向 callback

WebContainer.registerBridgeHandlers 接入。

文档调整:
  - Plan §2.3 阻塞表:QQ OpenSDK 标"不需要",改 URL Scheme 路径
  - Plan §5 Phase 4 前置:去掉 QQ OpenSDK 一行
  - Plan §5 Phase 4.2:完整改写为 URL Scheme 方案,含 LSApplicationQueriesSchemes
    清单 + URL 构造样例 + "调起即 success" 乐观策略说明
  - Plan §8 进度追踪:4.2 QQ SDK Vendor 标"不需要"
  - Plan §6.4 里程碑加 3 行(前两轮 commit hash 补 + 本次)
  - CLAUDE.md 依赖管理段加 "不接入 QQ SDK" 约定(与"不引入 CocoaPods"
    并列的负面清单)
  - Verification-Checklist Phase 4 章节:E.19/E.20 stub + K/L 待 4.B/4.C
    完整后填充验证项

BuildProject 通过

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
joywayer
2026-06-22 19:19:23 +08:00
co-authored by Claude Opus 4.7
parent 0602b9d4b6
commit aa80aec18c
6 changed files with 108 additions and 11 deletions
@@ -0,0 +1,31 @@
//
// AccreditLoginHandler.swift
// ylgamehall
//
// H5 → Native handler stub:accreditlogin — 微信授权登录
// 契约:docs/H5-Native-Contract.md §3.1 [1] + §3.2 [10]sharelogin
//
// Phase 4.A 阶段为 stub(仅 cb 维持契约);Phase 4.B 等微信 SDK + AppID +
// Universal Links + 后台 /wechat/login 接口(或客户端 fallback)到位后升级。
//
// 完整实现(Phase 4.B):
// 1. WeChatManager.shared.authorize() → 拿 WXAuthCode(state UUID 配对)
// 2. WeChatAuth.exchangeForUser(code:) → 后台 /wechat/login 或客户端直拼
// sns/oauth2/access_token + sns/userinfo
// 3. bridge.call("sharelogin", data: 7 字段) 反向 callback
// 字段名严格 1:1 含历史包袱:Province 大写 P、city 经 danbian: 去单引号
//
import Foundation
public enum AccreditLoginHandler {
public static func register(on bridge: any BridgeProtocol) {
// 【1】accreditlogin
// 入参忽略;cb: "Response from accreditlogin"
// 完整实现需触发 sharelogin 反向 callback(Phase 4.B)
bridge.register("accreditlogin") { _, callback in
callback?(.string("Response from accreditlogin"))
}
}
}
@@ -0,0 +1,38 @@
//
// FriendsShareHandler.swift
// ylgamehall
//
// H5 → Native handler stub:friendsSharetypeUrlToptitleDescript — 分享
// 契约:docs/H5-Native-Contract.md §3.1 [2] + §3.2 [11]sharesuccess
//
// Phase 4.A 阶段为 stub(仅 cb 维持契约);Phase 4.B 微信 SDK 接入 + Phase 4.C
// QQ URL Scheme 完整实现后升级。
//
// 完整实现:
// 1. 入参解析:sharefriend (1=好友 / 2=朋友圈) + sharetype (1=微信 / 2=微信 /
// 3=闲聊;契约 §3.1 [2]) + type (1=链接 / 2=截图 / 3=远端图) + url +
// title + description
// 2. ShareCenter.dispatch(req):
// - sharetype = 3 → 闲聊 NoopSharePlatform(暂未集成)
// - 否则 → WeChatShare(Phase 4.B SDK 接入)
// 3. 分享完成 → bridge.call("sharesuccess", { success: "2", type: <sharefriend 原值> })
//
// ⚠️ QQ 分享按用户约定**不依赖 SDK**,走 URL Scheme(mqq://share/to_fri、
// mqqapi://share/to_qzone 等);参 daoqi/msext QQShareManager.m fallback
// 部分(Phase 4.C 真实落地)
//
import Foundation
public enum FriendsShareHandler {
public static func register(on bridge: any BridgeProtocol) {
// 【2】friendsSharetypeUrlToptitleDescript
// 入参:sharefriend / sharetype / type / url / title / description
// cb: "sharefriend"(msext 字面,沿用)
// 完整实现需触发 sharesuccess 反向 callback(Phase 4.B/4.C)
bridge.register("friendsSharetypeUrlToptitleDescript") { _, callback in
callback?(.string("sharefriend"))
}
}
}