新增米家环境监控模块 (采集/聚合/历史/前端 EnvView) + CI 挂载米家凭证目录并自动应用迁移
Docker Build and Push / build-image (push) Successful in 6m54s

This commit is contained in:
jif2.zhang
2026-09-21 11:42:58 +08:00
parent 53f63e0986
commit 8e2c6ffa35
36 changed files with 11327 additions and 428 deletions
+39
View File
@@ -0,0 +1,39 @@
// 环境监控 API: 走后端 /api/mihome/* (凭证/token 不出前端)
import { api, getApiBase } from './client.js'
// 状态: 授权 + 家庭(设备) + 电量 + 最新样本 + 缺日 + 统计可用性
export async function getMihomeStatus() {
return api('/mihome/status')
}
// 历史: range = today | month | year
export async function getMihomeHistory(did, range) {
return api('/mihome/device/' + encodeURIComponent(did) + '/history?range=' + encodeURIComponent(range))
}
// 改别名 (alias 传空串 = 清空)
export async function setMihomeAlias(did, alias) {
return api('/mihome/device/' + encodeURIComponent(did), { method: 'PUT', body: { alias } })
}
// 立即同步
export async function syncMihome() {
return api('/mihome/sync', { method: 'POST' })
}
// 重授权
export async function startMihomeAuth() {
return api('/mihome/reauthorize', { method: 'POST' })
}
export async function getMihomeAuthStatus() {
return api('/mihome/reauthorize/status')
}
export async function cancelMihomeAuth() {
return api('/mihome/reauthorize/cancel', { method: 'POST' })
}
// 二维码图片地址 (服务端带小米 UA 代理, 避免 CDN 拒连)
export function mihomeQrImageUrl() {
const base = getApiBase() // 同源时为空串
return base + '/api/mihome/reauthorize/qr-image'
}