同步配置
This commit is contained in:
parent
1dc9d2d131
commit
f69fb95860
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
node_modules/*
|
||||
config.json
|
||||
profiles/
|
||||
profiles/*
|
||||
|
||||
@ -61,38 +61,42 @@ async function syncToDouxiaoyun(cookieString, secUserId) {
|
||||
|
||||
if (!configResp.ok) throw new Error(`查询配置失败: HTTP ${configResp.status}`);
|
||||
const configData = await configResp.json();
|
||||
const items = configData.data?.items || configData.items || configData.data || [];
|
||||
const items = configData.data?.items || configData.items || configData.data.data || [];
|
||||
const existingConfig = Array.isArray(items) ? items[0] : items;
|
||||
|
||||
if (!existingConfig || !existingConfig.id) {
|
||||
console.log(" ⚠️ 未找到现有配置项");
|
||||
console.log(JSON.stringify(configData, null, 4))
|
||||
return;
|
||||
}
|
||||
console.log(` ✅ 找到配置项: id=${existingConfig.id}, userName=${existingConfig.userName}`);
|
||||
console.log(` ✅ 找到配置项: id=${existingConfig.id}, userName=${existingConfig.userName} statusMsg=${existingConfig.statusMsg}`);
|
||||
|
||||
// 3. 更新配置
|
||||
console.log(" 3/3 更新 cookies...");
|
||||
const updateBody = {
|
||||
...existingConfig,
|
||||
cookies: cookieString,
|
||||
secUserId: secUserId || existingConfig.secUserId || "",
|
||||
};
|
||||
if("已过期" == existingConfig.statusMsg) {
|
||||
// 3. 更新配置
|
||||
console.log(" 3/3 更新 cookies...");
|
||||
const updateBody = {
|
||||
...existingConfig,
|
||||
cookies: cookieString,
|
||||
secUserId: secUserId || existingConfig.secUserId || "",
|
||||
};
|
||||
|
||||
const updateResp = await fetch(`${apiBase}/api/config/update`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"accept": "application/json, text/plain, */*",
|
||||
"authorization": `Bearer ${token}`,
|
||||
"content-type": "application/json",
|
||||
"Referer": `${apiBase}/`,
|
||||
},
|
||||
body: JSON.stringify(updateBody),
|
||||
});
|
||||
const updateResp = await fetch(`${apiBase}/api/config/update`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"accept": "application/json, text/plain, */*",
|
||||
"authorization": `Bearer ${token}`,
|
||||
"content-type": "application/json",
|
||||
"Referer": `${apiBase}/`,
|
||||
},
|
||||
body: JSON.stringify(updateBody),
|
||||
});
|
||||
|
||||
if (!updateResp.ok) throw new Error(`更新配置失败: HTTP ${updateResp.status}`);
|
||||
const updateResult = await updateResp.json();
|
||||
console.log(" ✅ douxiaoyun cookies 更新成功!");
|
||||
console.log(` 响应: ${JSON.stringify(updateResult).substring(0, 200)}`);
|
||||
}
|
||||
|
||||
if (!updateResp.ok) throw new Error(`更新配置失败: HTTP ${updateResp.status}`);
|
||||
const updateResult = await updateResp.json();
|
||||
console.log(" ✅ douxiaoyun cookies 更新成功!");
|
||||
console.log(` 响应: ${JSON.stringify(updateResult).substring(0, 200)}`);
|
||||
} catch (err) {
|
||||
console.error(` ❌ 同步 douxiaoyun 失败: ${err.message}`);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user