From 6a8758f97ae8b48dd667da26b173bcee881d9451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AE=80=E7=AE=80=E5=8D=95=E5=8D=95?= Date: Sun, 17 May 2026 08:00:23 +0200 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20node.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- node.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 node.js diff --git a/node.js b/node.js new file mode 100644 index 0000000..4b4d37c --- /dev/null +++ b/node.js @@ -0,0 +1,26 @@ +const https = require('https'); + +const jsonUrl = 'https://gittea.dev/Vibrantly/Try/raw/branch/master/x.json'; + +https.get(jsonUrl, (res) => { + let base64Data = ''; + res.on('data', (chunk) => { base64Data += chunk; }); + + res.on('end', () => { + // --- 核心解码逻辑 --- + // 直接使用 Buffer.from 指定 'base64' 编码进行还原 + const jsonString = Buffer.from(base64Data.trim(), 'base64').toString('utf-8'); + + // --- 自动解析并运行 --- + try { + const configData = JSON.parse(jsonString); + console.log("【自动转换并解析成功】:", configData); + + // 继续执行你的业务逻辑... + } catch (e) { + console.error("JSON 解析失败:", e); + } + }); + }).on("error", (err) => { + console.error("请求出错:", err.message); + });