M3(T-M2-04/T-M3-13): LocalUploadServer 截图上传分享链路落地
补「H5 主动 POST 截图上传分享」链路,对齐原工程 OkHttpPhotoServer + savehandler:
- LocalUploadServer 从骨架实现为真实本机 HTTP server(@ohos.net.socket TCPSocketServer):
127.0.0.1:8099 起逐端口重试 listen;手解极简 HTTP/1.1(\r\n\r\n 分隔 + Content-Length
累积读全 body);仅 POST /testurl,body 取 base64(form name=/raw 兼容)+type → emit
PHOTO_UPLOAD → 回 200;非 /testurl 回 404;16MB 上限;异常 log 不崩溃。
baseUrl 反映实际端口。注:TCPSocketServer 无显式 close,stop 用 off('connect')+释放引用
- common ShareEvents.PHOTO_UPLOAD + PhotoUploadPayload
- ShareProvider:订阅 PHOTO_UPLOAD(仅激活槽处理,避免双实例重复分享)→ 落盘 → 微信图片
分享(type=="1"好友/其他朋友圈)→ sharesuccess;onDestroy 退订;抽 wechatImageByFriend/
wechatSceneByFriend 供面板截图与 POST 上传两条链路共用
真机验证项:H5 真实 POST body 格式、127.0.0.1 端口可达、微信开放平台注册
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
cb3673cb1b
commit
187e73a549
@@ -10,6 +10,19 @@
|
||||
export class ShareEvents {
|
||||
/** 请求弹出分享面板。 */
|
||||
static readonly SHOW_PANEL: string = 'share.showPanel';
|
||||
/**
|
||||
* H5 主动 POST 截图到本机上传服务(LocalUploadServer /testurl)后,由 server 解析出图片+type
|
||||
* 经此事件投给 ShareProvider 走微信图片分享(对齐 Android OkHttpPhotoServer + savehandler)。
|
||||
*/
|
||||
static readonly PHOTO_UPLOAD: string = 'share.photoUpload';
|
||||
}
|
||||
|
||||
/** PHOTO_UPLOAD 载荷(H5 POST 上传的截图)。 */
|
||||
export interface PhotoUploadPayload {
|
||||
/** 图片 base64(可能带 data: 前缀,也可能是纯 base64)。 */
|
||||
imageBase64: string;
|
||||
/** 好友/朋友圈语义(与分享面板 sharefriend 同义):"1" 好友 / 其他 朋友圈。 */
|
||||
type: string;
|
||||
}
|
||||
|
||||
/** SHOW_PANEL 载荷。 */
|
||||
|
||||
Reference in New Issue
Block a user