Skip to content

Commit

Permalink
更新"茶百道同步 Cookie"
Browse files Browse the repository at this point in the history
  • Loading branch information
leiyiyan authored Aug 6, 2024
1 parent 72da3bf commit 7ef0f50
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions script/cbd/cbd_ck.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,31 @@ async function main(user) {
const envs = ql.selectEnvByName(QL.envName);
if(!envs.length) throw new Error(`⛔️ 请在青龙应用配置环境变量:${QL.envName}`);
const selectedEnv = envs[0]

console.log(QL.envName);
console.log(envs);

debug(selectedEnv);

if (selectedEnv) {
const envValues = JSON.parse(selectedEnv.value);
console.log(envValues)
const index = envValues.findIndex(e => e.csession == user.csession)
let index = envValues.findIndex(e => e.csession == user.csession)
index = index === -1 ? 0 : index
console.log('index: ' + index)
if (envValues[index].csession == user.csession) {
$.title = `${QL.envName}当前ck未过期,无需同步`;
DoubleLog(`⛔️ ${QL.envName}当前ck未过期,无需同步`);
return;
}
envValues[index] = user;
// 更新已存在的环境变量
await ql.updateEnv({ value: JSON.stringify(envValues), name: QL.envName, id: selectedEnv.id });
} else {
// 添加新的环境变量
await ql.addEnv([{ value: JSON.stringify(user), name: QL.envName }])
}
console.log(`🎉${QL.envName}数据同步青龙成功!`);
$.title = `🎉${QL.envName}数据同步青龙成功!`;
DoubleLog(`${QL.envName}\n数据同步青龙成功!`);
} catch (e) {
console.log("操作青龙出错:" + e);
throw new Error("操作青龙出错:" + e);
Expand Down

0 comments on commit 7ef0f50

Please sign in to comment.