添加 node.js
This commit is contained in:
@@ -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);
|
||||
});
|
||||
Reference in New Issue
Block a user