收口 Makelore 客户端变更
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user