2025-08-06 15:56:07 +08:00

89 lines
1.8 KiB
JavaScript

import http from '../utils/http'
export default {
getKpi() {
return http.get('/dashboard/kpi')
},
getAlarmTrend() {
return http.get('/dashboard/alarm-trend')
},
getCameraStats() {
return http.get('/dashboard/camera-stats')
},
getAlgorithmStats() {
return http.get('/dashboard/algorithm-stats')
},
getMonitorsList(params) {
return http.get('/monitors/', params)
},
getMonitorsDetail(monitor_id) {
return http.get(`/api/monitors/${monitor_id}`)
},
// 获取场景列表
getScenesList(params) {
return http.get('/scenes/', params)
},
// 添加场景
addScenes(data) {
return http.post('/scenes/', data)
},
/**
* 设备管理接口
*/
// 添加设备
addDevices(data) {
return http.post('/devices/', data)
},
// 获取设备列表
getDevices(params) {
return http.get('/devices/', params)
},
/**
* 上传视频文件
*/
/**
* 上传视频文件(二进制格式)
* @param {File} file - 视频文件
* @param {string} deviceId - 设备ID
* @param {string} [description] - 视频描述
* @returns {Promise}
*/
uploadVideo (file, deviceId, description = '') {
return new Promise((resolve, reject) => {
const reader = new FileReader()
// 读取文件为二进制字符串
reader.readAsBinaryString(file)
reader.onload = () => {
const binaryString = reader.result
request({
url: '/upload/video',
method: 'post',
data: {
file: binaryString, // 二进制字符串
device_id: deviceId,
description: description
},
headers: {
'Content-Type': 'application/json' // 使用JSON格式
}
}).then(resolve).catch(reject)
}
reader.onerror = error => reject(error)
})
}
}