@@ -218,15 +218,24 @@ let progress = {
|
|||||||
lastRunDate: null // 记录上次运行的日期
|
lastRunDate: null // 记录上次运行的日期
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 获取本地日期(YYYY-MM-DD 格式)
|
||||||
|
function getLocalDate() {
|
||||||
|
const now = new Date();
|
||||||
|
const year = now.getFullYear();
|
||||||
|
const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始,需要加 1
|
||||||
|
const date = String(now.getDate()).padStart(2, '0');
|
||||||
|
return `${year}-${month}-${date}`;
|
||||||
|
}
|
||||||
// 读取进度
|
// 读取进度
|
||||||
async function loadProgress() {
|
async function loadProgress() {
|
||||||
try {
|
try {
|
||||||
const content = await file.readText(progressFile);
|
const content = await file.readText(progressFile);
|
||||||
const loadedProgress = JSON.parse(content);
|
const loadedProgress = JSON.parse(content);
|
||||||
|
|
||||||
// 检查日期是否一致
|
// 获取本地日期
|
||||||
const now = new Date();
|
const today = getLocalDate();
|
||||||
const today = now.toISOString().split('T')[0]; // 当前日期(YYYY-MM-DD)
|
|
||||||
|
// 获取保存的日期
|
||||||
const lastRunDate = loadedProgress.lastRunDate;
|
const lastRunDate = loadedProgress.lastRunDate;
|
||||||
|
|
||||||
if (lastRunDate && lastRunDate === today) {
|
if (lastRunDate && lastRunDate === today) {
|
||||||
@@ -239,24 +248,31 @@ async function loadProgress() {
|
|||||||
progress.completedTasks = [];
|
progress.completedTasks = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
progress.lastRunDate = today; // 更新当前日期
|
// 更新当前日期
|
||||||
log.info("加载进度成功:", progress);
|
progress.lastRunDate = today;
|
||||||
|
// 日志输出
|
||||||
|
log.info(`加载进度成功: ${JSON.stringify(progress)}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error("加载进度失败:", error);
|
log.error("加载进度失败:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存进度
|
// 保存进度
|
||||||
async function saveProgress() {
|
async function saveProgress() {
|
||||||
try {
|
try {
|
||||||
progress.lastRunDate = new Date().toISOString().split('T')[0]; // 更新当前日期
|
// 获取本地日期
|
||||||
|
const today = getLocalDate();
|
||||||
|
|
||||||
|
// 更新进度并保存
|
||||||
|
progress.lastRunDate = today;
|
||||||
await file.writeText(progressFile, JSON.stringify(progress));
|
await file.writeText(progressFile, JSON.stringify(progress));
|
||||||
log.info("进度已保存。");
|
|
||||||
|
log.info(`进度已保存,当前日期: ${today}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error("保存进度失败:", error);
|
log.error("保存进度失败:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let count = 0; // 用于记录分解圣遗物的次数
|
let count = 0; // 用于记录分解圣遗物的次数
|
||||||
|
|
||||||
async function runFile(filePath, times = 2) {
|
async function runFile(filePath, times = 2) {
|
||||||
|
|||||||
Reference in New Issue
Block a user