|
|
|
@ -14,11 +14,6 @@ const HONGYUAN_TOWN_NAMES = [ |
|
|
|
"麦洼乡", |
|
|
|
"麦洼乡", |
|
|
|
"色地镇", |
|
|
|
"色地镇", |
|
|
|
] |
|
|
|
] |
|
|
|
const MONITORING_FALLBACK_ROWS = [ |
|
|
|
|
|
|
|
{ id: "fallback-qiongxi-pasture", name: "邛溪镇家庭生态牧场监控", number: "CAM-001", statusName: "预览点位" }, |
|
|
|
|
|
|
|
{ id: "fallback-wache-grassland", name: "瓦切镇草场监控", number: "CAM-002", statusName: "预览点位" }, |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function joinBase(path) { |
|
|
|
function joinBase(path) { |
|
|
|
if (/^https?:\/\//.test(path)) return path |
|
|
|
if (/^https?:\/\//.test(path)) return path |
|
|
|
return `${JSY_API_BASE}${path.startsWith("/") ? path : `/${path}`}` |
|
|
|
return `${JSY_API_BASE}${path.startsWith("/") ? path : `/${path}`}` |
|
|
|
@ -143,18 +138,11 @@ function normalizeMonitoring(row, index, total, validTotal) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function getHomeMonitorings(params = {}) { |
|
|
|
export async function getHomeMonitorings(params = {}) { |
|
|
|
try { |
|
|
|
const data = await requestJson(joinBase("/api/home/monitorings"), { |
|
|
|
const data = await requestJson(joinBase("/api/home/monitorings"), { |
|
|
|
params, |
|
|
|
params, |
|
|
|
timeout: 18000, |
|
|
|
timeout: 18000, |
|
|
|
}).then(unwrapResponse) |
|
|
|
}).then(unwrapResponse) |
|
|
|
const rows = Array.isArray(data) ? data : data?.rows || data?.list || [] |
|
|
|
const rows = Array.isArray(data) ? data : data?.rows || data?.list || [] |
|
|
|
const playableRows = rows.filter(isPlayableMonitoring) |
|
|
|
const playableRows = rows.filter(isPlayableMonitoring) |
|
|
|
return playableRows.map((row, index) => normalizeMonitoring(row, index, rows.length, playableRows.length)) |
|
|
|
if (playableRows.length) { |
|
|
|
|
|
|
|
return playableRows.map((row, index) => normalizeMonitoring(row, index, rows.length, playableRows.length)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
console.warn("[homeVideo] fallback monitorings used", error) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return MONITORING_FALLBACK_ROWS.map((row, index) => normalizeMonitoring(row, index, MONITORING_FALLBACK_ROWS.length, 0)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|