chore: 新增 DEBUG_VERSION

This commit is contained in:
Del Wang
2025-04-13 12:04:27 +08:00
parent 3ef2587732
commit 93c7fcdfd2
+6 -2
View File
@@ -64,10 +64,10 @@ async function getOTA(channel: "release" | "current" | "stable" = "release") {
return;
}
const sn = speaker.serialNumber;
const model = speaker.hardware;
const version = speaker.romVersion;
const time = new Date().getTime();
const sn = process.env.DEBUG_VERSION ? "" : speaker.serialNumber;
const version = process.env.DEBUG_VERSION ?? speaker.romVersion;
const otaInfo = `channel=${channel}&filterID=${sn}&locale=zh_CN&model=${model}&time=${time}&version=${version}&8007236f-a2d6-4847-ac83-c49395ad6d65`;
const base64Str = Buffer.from(otaInfo).toString("base64");
const code = createHash("md5").update(base64Str).digest("hex");
@@ -92,6 +92,10 @@ async function main() {
console.log(`❌ 获取设备信息失败`);
process.exit(1);
}
if (process.env.DEBUG_VERSION) {
console.log(JSON.stringify(ota, null, 4));
return;
}
console.log(`🔥 正在获取 OTA 信息...`);
const res = await fetch(ota.url);
const data = await res.json();