合并客户端真机预览链路

需求:将待审 Release 扫码验收与项目级真机入口并入登录、发布集成候选。

实现:合并 Main-owned 精确预览与提交映射能力,保留现有登录和一键发布边界。
This commit is contained in:
2026-08-08 17:59:42 +08:00
20 changed files with 1890 additions and 12 deletions

25
src/lib/device-preview.ts Normal file
View File

@@ -0,0 +1,25 @@
import { hostApiFetch } from '@/lib/host-api';
import type { DevicePreviewSnapshot } from '../../shared/device-preview';
type DevicePreviewResponse = {
success: boolean;
preview?: DevicePreviewSnapshot;
error?: string;
};
export class DevicePreviewApiError extends Error {
constructor(message: string) {
super(message);
this.name = 'DevicePreviewApiError';
}
}
export async function fetchProjectDevicePreview(projectId: string): Promise<DevicePreviewSnapshot> {
const response = await hostApiFetch<DevicePreviewResponse>(
`/api/opencode/projects/${encodeURIComponent(projectId)}/device-preview`,
);
if (!response.success || !response.preview) {
throw new DevicePreviewApiError(response.error || '无法读取真机预览状态');
}
return response.preview;
}