From 43e673972663a1a0b10f624dc574a50e059688bf Mon Sep 17 00:00:00 2001 From: Del Wang Date: Fri, 15 Aug 2025 12:43:06 +0800 Subject: [PATCH] =?UTF-8?q?chore(patch):=20=E6=9B=B4=E6=96=B0=E5=9B=BA?= =?UTF-8?q?=E4=BB=B6=E4=BF=A1=E6=81=AF=E8=8E=B7=E5=8F=96=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/client-patch/.env.example | 13 +++++--- packages/client-patch/package-lock.json | 40 ++++++++++++------------- packages/client-patch/package.json | 6 ++-- packages/client-patch/src/ota.ts | 30 ++++--------------- 4 files changed, 38 insertions(+), 51 deletions(-) diff --git a/packages/client-patch/.env.example b/packages/client-patch/.env.example index 5a7d735..0175292 100644 --- a/packages/client-patch/.env.example +++ b/packages/client-patch/.env.example @@ -1,9 +1,14 @@ -# 你的小米账号/密码 +#你的小米账号/密码 MI_USER=23333333 MI_PASS=xxxxxxxxx - -# 你的小爱音箱名称/DID +#你的小爱音箱名称/DID MI_DID=小爱音箱Pro -# 你的 SSH 登录密码(默认为 open-xiaoai) +#你的 SSH 登录密码,默认为 open-xiaoai SSH_PASSWORD=open-xiaoai + +#账号登录异常时,请取消下面的注释,使用 MI_TOKEN 登录 +#MI_TOKEN=你的 passToken 获取教程 👉 https://github.com/idootop/migpt-next/issues/4 + +# 获取设备异常时,请取消下面的注释,查看设备列表详情 +#MI_DEBUG=true diff --git a/packages/client-patch/package-lock.json b/packages/client-patch/package-lock.json index 44e3567..b9b2e4b 100644 --- a/packages/client-patch/package-lock.json +++ b/packages/client-patch/package-lock.json @@ -8,11 +8,11 @@ "name": "open-xiaoai-patch", "version": "1.0.0", "dependencies": { - "@mi-gpt/miot": "^1.0.0" + "@mi-gpt/miot": "^1.2.1" }, "devDependencies": { - "@mi-gpt/config": "1.0.0", - "@types/node": "^22.13.11", + "@mi-gpt/config": "1.1.0", + "@types/node": "^24.2.1", "tsx": "^4.19.3", "typescript": "^5.8.2" } @@ -443,9 +443,9 @@ } }, "node_modules/@mi-gpt/config": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@mi-gpt/config/-/config-1.0.0.tgz", - "integrity": "sha512-oo/roYiRcGiHsZESjukwPTsRFqddShTJ8gkccR5ZMYn8SySj07A0nCsEsLEfB9mLkvNY8D6PCO1NxbRDDRBBlA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@mi-gpt/config/-/config-1.1.0.tgz", + "integrity": "sha512-o24iFINsoDuvInnMpfBQ4zCuTObbdodjXyizXmxl3yyYOMjmIAXizO/1UZ9/dv3UVTov3sjL09aCGuBeIVhvtA==", "dev": true, "license": "MIT", "engines": { @@ -453,12 +453,12 @@ } }, "node_modules/@mi-gpt/miot": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@mi-gpt/miot/-/miot-1.0.0.tgz", - "integrity": "sha512-smWhddHzK1du3/LW2FifBrIIyeZNx/RvTSe0Zi4v3lYZwK8NeEwomg1jBjktQCCV4Fh8OuqNbCdNbmiVXmr5kw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@mi-gpt/miot/-/miot-1.2.1.tgz", + "integrity": "sha512-DAFNUsLPepXSqJk/b+zfct8NCQHZzcl7f1t4X2WPKzxmDNagkawYlb96uPbk4syvn+DSg6vqle0Wm+gjmJ4kUA==", "license": "MIT", "dependencies": { - "@mi-gpt/utils": "1.0.0", + "@mi-gpt/utils": "1.1.1", "axios": "^1.8.4", "pako": "^2.1.0" }, @@ -467,22 +467,22 @@ } }, "node_modules/@mi-gpt/utils": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@mi-gpt/utils/-/utils-1.0.0.tgz", - "integrity": "sha512-hAU/uYPNiNJgXWkQrVqRLe/9Uz8AgtoiNwcbbwQs8iXJcyq3NjcSHkkwUseJAnaQFE9iv/kvHZZsx3r2HhlKjw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@mi-gpt/utils/-/utils-1.1.1.tgz", + "integrity": "sha512-FiGHV2RDBRGE/Xb9Q5H757t3ZqOpo6gL+44VXiRxQb3fQiapOpn038RAWErHJYZajYzkxP2jl8Wggsb+wp77Zg==", "license": "MIT", "engines": { "node": ">=16" } }, "node_modules/@types/node": { - "version": "22.14.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.14.1.tgz", - "integrity": "sha512-u0HuPQwe/dHrItgHHpmw3N2fYCR6x4ivMNbPHRkBVP4CvN+kiRrKHWk3i8tXiO/joPwXLMYvF9TTF0eqgHIuOw==", + "version": "24.2.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.2.1.tgz", + "integrity": "sha512-DRh5K+ka5eJic8CjH7td8QpYEV6Zo10gfRkjHCO3weqZHWDtAaSTFtl4+VMqOJ4N5jcuhZ9/l+yy8rVgw7BQeQ==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": "~6.21.0" + "undici-types": "~7.10.0" } }, "node_modules/asynckit": { @@ -883,9 +883,9 @@ } }, "node_modules/undici-types": { - "version": "6.21.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", - "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "version": "7.10.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.10.0.tgz", + "integrity": "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==", "dev": true, "license": "MIT" } diff --git a/packages/client-patch/package.json b/packages/client-patch/package.json index 261c4ee..0e61460 100644 --- a/packages/client-patch/package.json +++ b/packages/client-patch/package.json @@ -11,11 +11,11 @@ "build": "sh src/build.sh" }, "dependencies": { - "@mi-gpt/miot": "^1.0.0" + "@mi-gpt/miot": "^1.2.1" }, "devDependencies": { - "@mi-gpt/config": "1.0.0", - "@types/node": "^22.13.11", + "@mi-gpt/config": "1.1.0", + "@types/node": "^24.2.1", "tsx": "^4.19.3", "typescript": "^5.8.2" } diff --git a/packages/client-patch/src/ota.ts b/packages/client-patch/src/ota.ts index 4b50bc7..5608af7 100644 --- a/packages/client-patch/src/ota.ts +++ b/packages/client-patch/src/ota.ts @@ -13,36 +13,18 @@ const kSupportedDevices = [ // 获取 OTA 信息 async function getOTA(channel: "release" | "current" | "stable" = "release") { const MiNA = await getMiNA({ + did: process.env.MI_DID!, userId: process.env.MI_USER!, password: process.env.MI_PASS!, + passToken: process.env.MI_TOKEN, + debug: !!process.env.MI_DEBUG, }); if (!MiNA) { - console.log(`❌ 登录失败,请检查小米账号密码是否正确:`); - console.log(`当前账号:${process.env.MI_USER}`); - console.log(`当前密码:${process.env.MI_PASS}`); return; } const devices = await MiNA.getDevices(); - const speaker = devices?.find( - (e: any) => - e.name === process.env.MI_DID || e.miotDID === process.env.MI_DID - ); - if (!speaker) { - console.log(`❌ 找不到设备: ${process.env.MI_DID}`); - console.log(`可用设备列表:`); - console.log( - JSON.stringify( - devices.map((e: any) => ({ - name: e.name, - did: e.miotDID, - })), - null, - 4 - ) - ); - return; - } + const speaker = MiNA.account.device as any; if (!kSupportedDevices.includes(speaker.hardware)) { console.log( @@ -65,7 +47,7 @@ async function getOTA(channel: "release" | "current" | "stable" = "release") { } const model = speaker.hardware; - const time = new Date().getTime(); + const time = Date.now(); 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`; @@ -88,7 +70,7 @@ async function main() { } else { ota = await getOTA(); } - if (!ota.url) { + if (!ota?.url) { console.log(`❌ 获取设备信息失败`); process.exit(1); }