接入发布分享原生系统分享路径

发布分享弹窗在 native_app 中调用 share.open

保留复制链接与下载卡片回退路径

补充 HostBridge 分享测试和宿主壳能力文档
This commit is contained in:
2026-06-18 00:16:26 +08:00
parent d64e576e3f
commit 4266c1e5e8
7 changed files with 166 additions and 8 deletions

View File

@@ -9,6 +9,7 @@ import {
getNativeAppHostRuntime,
isWechatMiniProgramWebViewRuntime,
navigateHostNativePage,
openHostShare,
openHostShareGrid,
openWechatMiniProgramShareGridPage,
postWechatMiniProgramMessage,
@@ -319,6 +320,13 @@ describe('hostBridge', () => {
await expect(setHostAppTitle({ title: ' 拼图 - 陶泥儿 ' })).resolves.toBe(
true,
);
await expect(
openHostShare({
title: '暖灯猫街',
message: '邀请你来玩',
url: 'https://app.genarrative.world/works/detail?work=PZ-1',
}),
).resolves.toBe(true);
expect(invoke).toHaveBeenCalledWith('host_bridge_request', {
request: expect.objectContaining({
@@ -364,6 +372,16 @@ describe('hostBridge', () => {
},
}),
});
expect(invoke).toHaveBeenCalledWith('host_bridge_request', {
request: expect.objectContaining({
method: 'share.open',
payload: {
title: '暖灯猫街',
message: '邀请你来玩',
url: 'https://app.genarrative.world/works/detail?work=PZ-1',
},
}),
});
});
test('原生 App 宿主不支持能力时回退到 H5 路径', async () => {
@@ -404,6 +422,13 @@ describe('hostBridge', () => {
false,
);
await expect(setHostAppTitle({ title: ' ' })).resolves.toBe(false);
await expect(
openHostShare({
title: '暖灯猫街',
message: '邀请你来玩',
url: 'https://app.genarrative.world/works/detail?work=PZ-1',
}),
).resolves.toBe(false);
});
test('普通浏览器不处理宿主文本导出', async () => {