diff --git a/meteor-frontend/src/app/camera-settings/page.tsx b/meteor-frontend/src/app/camera-settings/page.tsx index 713cc29..9f102de 100644 --- a/meteor-frontend/src/app/camera-settings/page.tsx +++ b/meteor-frontend/src/app/camera-settings/page.tsx @@ -45,26 +45,29 @@ export default function CameraSettingsPage() { const handleSelectCamera = async (cameraId: string) => { try { setLoading(true); - - // 获取相机详细信息 - const camera = cameras.find(c => c.deviceId === cameraId); + + // 使用 id 查找相机 + const camera = cameras.find(c => c.id === cameraId); if (camera) { setCameraDetails(camera); setSelectedCamera(cameraId); - - // 获取历史数据 - const historyData = await cameraService.getCameraHistory(cameraId); - const formattedHistory: CameraHistoryRecord[] = historyData.map(item => ({ - date: new Date(item.time).toLocaleString(), - status: 'active' as const, // API doesn't provide status in history, defaulting to active - temperature: item.temperature, - coolerPower: item.coolerPower, - gain: item.gain, - exposureCount: undefined, - uptime: undefined - })); - - setCameraHistory(formattedHistory); + + // 只有当 deviceId 存在时才获取历史数据 + if (camera.deviceId) { + const historyData = await cameraService.getCameraHistory(camera.deviceId); + const formattedHistory: CameraHistoryRecord[] = historyData.map(item => ({ + date: new Date(item.time).toLocaleString(), + status: 'active' as const, // API doesn't provide status in history, defaulting to active + temperature: item.temperature, + coolerPower: item.coolerPower, + gain: item.gain, + exposureCount: undefined, + uptime: undefined + })); + setCameraHistory(formattedHistory); + } else { + setCameraHistory([]); + } } } catch (error) { console.error('获取相机详细信息失败:', error); @@ -160,7 +163,7 @@ export default function CameraSettingsPage() {
handleSelectCamera(camera.deviceId)} + onClick={() => handleSelectCamera(camera.id)} >
@@ -175,7 +178,7 @@ export default function CameraSettingsPage() {
位置: - {camera.location} + {camera.location?.site_name || camera.legacyLocation || '未知'}
温度: @@ -233,7 +236,7 @@ export default function CameraSettingsPage() {

{cameraDetails.name}

-

{cameraDetails.location}

+

{cameraDetails.location?.site_name || cameraDetails.legacyLocation || '未知'}

diff --git a/meteor-frontend/src/services/subscription.ts b/meteor-frontend/src/services/subscription.ts index 26185d5..1342c7d 100644 --- a/meteor-frontend/src/services/subscription.ts +++ b/meteor-frontend/src/services/subscription.ts @@ -32,7 +32,7 @@ export interface CheckoutSessionResponse { // New interfaces for the enhanced subscription API export interface SubscriptionPlan { - id: number; + id: string; planId: string; name: string; description?: string; @@ -49,9 +49,9 @@ export interface SubscriptionPlan { } export interface UserSubscription { - id: number; + id: string; userProfileId: string; - subscriptionPlanId: number; + subscriptionPlanId: string; subscriptionPlan: SubscriptionPlan; stripeSubscriptionId?: string; status: 'active' | 'canceled' | 'past_due' | 'trialing' | 'incomplete'; @@ -213,7 +213,13 @@ export const subscriptionApi = { throw new Error(`Failed to fetch user subscription: ${response.statusText}`) } - return response.json() + // Safely handle empty response body + const text = await response.text() + if (!text || text.trim() === '' || text === 'null') { + return null + } + + return JSON.parse(text) } catch (error) { console.error('Error fetching user subscription:', error) return null