mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-25 00:23:53 +08:00
add:ota管理与固件上传与下载 (#931)
* 新增ota管理与固件上传于下载 * feat: 支持通过OTA更新websocket地址 * update:合并最新代码 * update:优化OTA增删改查 * update:一个临时下载链接最多只能下载3次,防止盗链和流量攻击 * update:OTA固件增删改查 --------- Co-authored-by: kevin1sMe <linjiang1205@gmail.com> Co-authored-by: hrz <1710360675@qq.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// 日期格式化函数
|
||||
export function formatDate(date) {
|
||||
if (!date) return '';
|
||||
const d = new Date(date);
|
||||
const year = d.getFullYear();
|
||||
const month = String(d.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(d.getDate()).padStart(2, '0');
|
||||
const hour = String(d.getHours()).padStart(2, '0');
|
||||
const minute = String(d.getMinutes()).padStart(2, '0');
|
||||
const second = String(d.getSeconds()).padStart(2, '0');
|
||||
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||||
}
|
||||
|
||||
// 文件大小格式化函数
|
||||
export function formatFileSize(bytes) {
|
||||
if (!bytes || bytes === 0) return '0 B';
|
||||
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
const k = 1024;
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + units[i];
|
||||
}
|
||||
Reference in New Issue
Block a user