接入移动壳图片导入能力

Expo 壳通过系统相册选择器实现 file.importImage

限制导入图片 MIME 与大小并避免暴露设备本地 URI

H5 facade 将用户取消导入归为无选择回退

更新移动壳依赖、配置校验、测试和架构文档
This commit is contained in:
2026-06-18 03:04:21 +08:00
parent 199f02cf9f
commit 14f838c414
12 changed files with 348 additions and 7 deletions
@@ -1089,4 +1089,34 @@ describe('hostBridge', () => {
}),
});
});
test('原生 App 宿主取消导入图片时回退为 false', async () => {
const invoke = vi.fn(
async (_command: string, args?: Record<string, unknown>) => {
const request = (args as { request: { id: string } }).request;
return {
bridge: 'GenarrativeHostBridge',
version: 1,
id: request.id,
ok: false,
error: {
code: 'cancelled',
message: 'file import cancelled',
},
};
},
);
window.history.replaceState(
null,
'',
nativeAppPath(['file.importImage']),
);
window.__TAURI__ = {
core: {
invoke: asTauriInvoke(invoke),
},
};
await expect(importHostImageFile()).resolves.toBe(false);
});
});
+2 -1
View File
@@ -125,7 +125,8 @@ function isUnsupportedHostBridgeError(error: unknown) {
return (
error instanceof Error &&
(error.name === 'unsupported_method' ||
error.name === 'unsupported_capability')
error.name === 'unsupported_capability' ||
error.name === 'cancelled')
);
}