报警列表卡片,模式页面布局修改,估计播放,优化体验

This commit is contained in:
fengerli
2025-08-30 14:45:55 +08:00
parent e07a4fea01
commit 031f6135c1
18 changed files with 1302 additions and 392 deletions

View File

@ -12,7 +12,25 @@ export const generateShortId = (): string => {
return Date.now().toString(36) + Math.random().toString(36).substr(2, 8);
};
export default generateShortId;
// 时间转化
/**
* 时间戳转 24小时制 HH:mm
* @param timestamp 秒/毫秒级时间戳
*/
export const formatTimestampToHM = (timestamp: number) => {
if (!timestamp) return '';
// 秒级时间戳 → 毫秒级
const msTimestamp = timestamp.toString().length === 10
? timestamp * 1000
: timestamp;
const date = new Date(msTimestamp);
// 小时、分钟补零
const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');
return `${hours}:${minutes}`;
};
// 类型定义
export interface DeviceStatusOptions {
@ -87,25 +105,4 @@ export async function getDeviceStatus(
return checkStatus();
}
// 使用示例
/*
import { getDeviceStatus } from '@/utils/deviceUtils';
import { apiGetDeviceStatus } from '@/api/device';
try {
const result = await getDeviceStatus(
{
functionMode: 1,
batchId: '12345',
typeName: 'sensor',
deviceImei: '1234567890',
interval: 1000
},
apiGetDeviceStatus
);
console.log('设备状态:', result.data);
} catch (error) {
console.error('获取设备状态失败:', error);
}
*/
export default { generateShortId, formatTimestampToHM }