js: CD-Aware-AutoGather: 修复没有按照设定时间停止运行的问题 (#1195)
This commit is contained in:
@@ -4,7 +4,7 @@ const settingFile = "settings.json";
|
|||||||
const defaultTime = getDefaultTime();
|
const defaultTime = getDefaultTime();
|
||||||
const CooldownDataBase = readRefreshInfo("CooldownData.txt");
|
const CooldownDataBase = readRefreshInfo("CooldownData.txt");
|
||||||
|
|
||||||
let stopTime = null;
|
let stopAtTime = null;
|
||||||
let currentParty = null;
|
let currentParty = null;
|
||||||
|
|
||||||
class ReachStopTime extends Error {
|
class ReachStopTime extends Error {
|
||||||
@@ -96,16 +96,17 @@ async function runScanMode() {
|
|||||||
|
|
||||||
// 采集选中的材料
|
// 采集选中的材料
|
||||||
async function runGatherMode() {
|
async function runGatherMode() {
|
||||||
|
if (settings.stopAtTime) {
|
||||||
|
stopAtTime = settings.stopAtTime;
|
||||||
|
log.info("脚本已被配置为达到{0}后停止运行", stopAtTime);
|
||||||
|
}
|
||||||
|
|
||||||
const selectedMaterials = getSelectedMaterials();
|
const selectedMaterials = getSelectedMaterials();
|
||||||
|
|
||||||
if (selectedMaterials.length === 0) {
|
if (selectedMaterials.length === 0) {
|
||||||
log.error("未选择任何材料,请在脚本配置中勾选所需项目");
|
log.error("未选择任何材料,请在脚本配置中勾选所需项目");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (settings.Time) {
|
|
||||||
stopTime = settings.stopAtTime;
|
|
||||||
log.info("脚本已被配置为达到{0}后停止运行", stopTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("共{0}组材料路线待执行:", selectedMaterials.length);
|
log.info("共{0}组材料路线待执行:", selectedMaterials.length);
|
||||||
for (const item of selectedMaterials) {
|
for (const item of selectedMaterials) {
|
||||||
@@ -127,7 +128,7 @@ async function runGatherMode() {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof ReachStopTime) {
|
if (e instanceof ReachStopTime) {
|
||||||
log.info("达到设置的停止时间 {0},终止运行", stopTime);
|
log.info("达到设置的停止时间 {0},终止运行", stopAtTime);
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
@@ -272,7 +273,7 @@ async function runPathTaskIfCooldownExpired(account, pathTask) {
|
|||||||
const lastTime = recordMap[fileName] || defaultTime;
|
const lastTime = recordMap[fileName] || defaultTime;
|
||||||
const progress = `[${i + 1}/${jsonFiles.length}]`;
|
const progress = `[${i + 1}/${jsonFiles.length}]`;
|
||||||
|
|
||||||
if (settings.Time && isTargetTimeReached(stopTime)) {
|
if (stopAtTime && isTargetTimeReached(stopAtTime)) {
|
||||||
throw new ReachStopTime("达到设置的停止时间,终止运行");
|
throw new ReachStopTime("达到设置的停止时间,终止运行");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 1,
|
"manifest_version": 1,
|
||||||
"name": "带CD管理的自动采集",
|
"name": "带CD管理的自动采集",
|
||||||
"version": "1.2",
|
"version": "1.3",
|
||||||
"bgi_version": "0.45.0",
|
"bgi_version": "0.45.0",
|
||||||
"description": "自动同步你通过BetterGI订阅的地图追踪任务,执行采集任务,并管理材料刷新时间(支持多账号)。\n首次使用前请先简单阅读说明(可在`全自动`——`JS脚本`页面,点击本脚本名称查看)",
|
"description": "自动同步你通过BetterGI订阅的地图追踪任务,执行采集任务,并管理材料刷新时间(支持多账号)。\n首次使用前请先简单阅读说明(可在`全自动`——`JS脚本`页面,点击本脚本名称查看)",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|||||||
Reference in New Issue
Block a user