接入桌面壳文本文件导出能力

新增 HostBridge file.exportText 契约、文件名清洗和 H5 导出入口

Tauri 桌面壳通过受控 host_bridge_request 打开保存对话框并写入文本文件

Expo 移动壳对未接入的文件导出能力明确返回 unsupported

更新宿主壳方案、统一协议和项目共享决策记录
This commit is contained in:
2026-06-17 23:02:01 +08:00
parent 6f19e1c3ba
commit d67f9d5725
14 changed files with 540 additions and 12 deletions

View File

@@ -1,4 +1,6 @@
import type {
FileExportTextPayload,
FileExportTextResult,
HostBridgeMethod,
HostBridgeRuntimeResult,
} from '../../../packages/shared/src/contracts/hostBridge';
@@ -57,6 +59,8 @@ export type HostShareGridRequest = {
publicWorkCode: string;
};
export type HostFileExportTextRequest = FileExportTextPayload;
function isUnsupportedHostBridgeError(error: unknown) {
return (
error instanceof Error &&
@@ -444,3 +448,24 @@ export async function getNativeAppHostRuntime() {
'host.getRuntime',
);
}
export async function exportHostTextFile(
params: HostFileExportTextRequest,
) {
if (getHostRuntime().kind !== 'native_app') {
return false;
}
try {
return await requestNativeAppHostBridge<FileExportTextResult>(
'file.exportText',
params,
{ timeoutMs: 30000 },
);
} catch (error) {
if (isUnsupportedHostBridgeError(error)) {
return false;
}
throw error;
}
}