mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 23:23:55 +08:00
fix: 设备最后连接时间返回 UTC 时间戳,修复时区显示问题
This commit is contained in:
@@ -369,11 +369,13 @@ export default {
|
||||
this.deviceList = data.data.map(device => {
|
||||
return {
|
||||
device_id: device.id,
|
||||
model: device.board,
|
||||
model: device.deviceType,
|
||||
firmwareVersion: device.appVersion,
|
||||
macAddress: device.macAddress,
|
||||
bindTime: device.createDate,
|
||||
lastConversation: device.lastConnectedAt,
|
||||
lastConversation: device.lastConnectedAtTimestamp
|
||||
? this.formatRelativeTime(device.lastConnectedAtTimestamp)
|
||||
: '-',
|
||||
remark: device.alias,
|
||||
_originalRemark: device.alias,
|
||||
isEdit: false,
|
||||
@@ -489,6 +491,14 @@ export default {
|
||||
const version = row.firmwareVersion.replace(/\./g, '');
|
||||
return Number(version) >= 200;
|
||||
},
|
||||
formatRelativeTime(timestamp) {
|
||||
if (!timestamp) return '-';
|
||||
const ts = Number(timestamp);
|
||||
if (isNaN(ts)) return '-';
|
||||
const date = new Date(ts);
|
||||
if (isNaN(date.getTime())) return '-';
|
||||
return date.toLocaleString(); // 自动适配本地时区
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user