接入原生壳分享卡图片导出
新增 file.exportImage 宿主能力契约 分享卡下载在原生壳中优先走宿主图片导出 Expo 壳写入缓存图片并调用系统分享保存 Tauri 壳通过保存对话框写入图片字节 补齐能力漂移检查、测试和架构文档
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import type {
|
||||
FileExportImagePayload,
|
||||
FileExportImageResult,
|
||||
FileExportTextPayload,
|
||||
FileExportTextResult,
|
||||
HapticsImpactPayload,
|
||||
@@ -73,6 +75,8 @@ export type HostShareGridRequest = {
|
||||
|
||||
export type HostFileExportTextRequest = FileExportTextPayload;
|
||||
|
||||
export type HostFileExportImageRequest = FileExportImagePayload;
|
||||
|
||||
export type HostClipboardWriteTextRequest = {
|
||||
text: string;
|
||||
};
|
||||
@@ -687,6 +691,27 @@ export async function exportHostTextFile(
|
||||
}
|
||||
}
|
||||
|
||||
export async function exportHostImageFile(
|
||||
params: HostFileExportImageRequest,
|
||||
) {
|
||||
if (!canUseNativeHostCapability('file.exportImage')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return await requestNativeAppHostBridge<FileExportImageResult>(
|
||||
'file.exportImage',
|
||||
params,
|
||||
{ timeoutMs: 30000 },
|
||||
);
|
||||
} catch (error) {
|
||||
if (isUnsupportedHostBridgeError(error)) {
|
||||
return false;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function requestHostHapticsImpact(
|
||||
params: HostHapticsImpactRequest = {},
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user