js: AutoArtifactsPro: 修复"负负得正"的basename实现,优化代码结构 (#1191)
This commit is contained in:
@@ -476,28 +476,26 @@ async function runArtifactsPaths(runRouteA, grindPartyName, useABE) {
|
|||||||
const filePathExtra = `assets/${ArtifactsPath}/${folderName}/03额外`;
|
const filePathExtra = `assets/${ArtifactsPath}/${folderName}/03额外`;
|
||||||
const filePathPreparation = `assets/${ArtifactsPath}/${folderName}/00准备`;
|
const filePathPreparation = `assets/${ArtifactsPath}/${folderName}/00准备`;
|
||||||
|
|
||||||
// 运行准备路线(关闭拾取)
|
// 将每组路线的逻辑抽取为公用函数
|
||||||
dispatcher.ClearAllTriggers();
|
async function runPathGroups(filePathDir, subTaskName) {
|
||||||
{
|
|
||||||
// 读取文件夹中的文件名并处理
|
// 读取文件夹中的文件名并处理
|
||||||
const filePaths = file.readPathSync(filePathPreparation);
|
const filePaths = file.readPathSync(filePathDir);
|
||||||
const jsonFileNames = [];
|
const jsonFilePaths = [];
|
||||||
|
|
||||||
for (const filePath of filePaths) {
|
for (const filePath of filePaths) {
|
||||||
const fileName = basename(filePath); // 提取文件名
|
if (filePath.endsWith('.json')) { // 检查文件名是否以 .json 结尾
|
||||||
if (fileName.endsWith('.json')) { // 检查文件名是否以 .json 结尾
|
jsonFilePaths.push(filePath); // 存储文件名
|
||||||
jsonFileNames.push(fileName); // 存储文件名
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let currentTask = 0; // 当前任务计数器
|
let currentTask = 0; // 当前任务计数器
|
||||||
|
|
||||||
// 执行准备路线的地图追踪文件
|
// 执行准备路线的地图追踪文件
|
||||||
for (const fileName of jsonFileNames) {
|
for (const fileName of jsonFilePaths) {
|
||||||
const fullPath = fileName;
|
const fullPath = fileName;
|
||||||
await fakeLog(fileName, false, true, 0);
|
await fakeLog(fileName, false, true, 0);
|
||||||
currentTask += 1; // 更新当前任务计数器
|
currentTask += 1; // 更新当前任务计数器
|
||||||
log.info(`当前进度:${fullPath}为准备${folderName}第${currentTask}/${jsonFileNames.length}个`);
|
log.info(`当前进度:${fullPath}为${subTaskName}${folderName}第${currentTask}/${jsonFilePaths.length}个`);
|
||||||
await pathingScript.runFile(fullPath);
|
await pathingScript.runFile(fullPath);
|
||||||
//捕获任务取消的信息并跳出循环
|
//捕获任务取消的信息并跳出循环
|
||||||
try {
|
try {
|
||||||
@@ -509,6 +507,11 @@ async function runArtifactsPaths(runRouteA, grindPartyName, useABE) {
|
|||||||
await fakeLog(fileName, false, false, 0);
|
await fakeLog(fileName, false, false, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 运行准备路线(关闭拾取)
|
||||||
|
dispatcher.ClearAllTriggers();
|
||||||
|
await runPathGroups(filePathPreparation, "准备");
|
||||||
|
|
||||||
// 启用自动拾取的实时任务
|
// 启用自动拾取的实时任务
|
||||||
dispatcher.addTimer(new RealtimeTimer("AutoPick"));
|
dispatcher.addTimer(new RealtimeTimer("AutoPick"));
|
||||||
|
|
||||||
@@ -516,103 +519,13 @@ async function runArtifactsPaths(runRouteA, grindPartyName, useABE) {
|
|||||||
await switchPartyIfNeeded(grindPartyName);
|
await switchPartyIfNeeded(grindPartyName);
|
||||||
|
|
||||||
// 运行普通路线
|
// 运行普通路线
|
||||||
{
|
await runPathGroups(filePathNormal, "普通");
|
||||||
// 读取文件夹中的文件名并处理
|
|
||||||
const filePaths = file.readPathSync(filePathNormal);
|
|
||||||
const jsonFileNames = [];
|
|
||||||
|
|
||||||
for (const filePath of filePaths) {
|
|
||||||
const fileName = basename(filePath); // 提取文件名
|
|
||||||
if (fileName.endsWith('.json')) { // 检查文件名是否以 .json 结尾
|
|
||||||
jsonFileNames.push(fileName); // 存储文件名
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let currentTask = 0; // 当前任务计数器
|
|
||||||
|
|
||||||
// 执行普通路线的地图追踪文件
|
|
||||||
for (const fileName of jsonFileNames) {
|
|
||||||
const fullPath = fileName;
|
|
||||||
await fakeLog(fileName, false, true, 0);
|
|
||||||
currentTask += 1; // 更新当前任务计数器
|
|
||||||
log.info(`当前进度:${fullPath}为普通${folderName}第${currentTask}/${jsonFileNames.length}个`);
|
|
||||||
await pathingScript.runFile(fullPath);
|
|
||||||
//捕获任务取消的信息并跳出循环
|
|
||||||
try {
|
|
||||||
await sleep(10); // 假设 sleep 是一个异步函数,休眠 10 毫秒
|
|
||||||
} catch (error) {
|
|
||||||
log.error(`发生错误: ${error}`);
|
|
||||||
return false; // 终止循环
|
|
||||||
}
|
|
||||||
await fakeLog(fileName, false, false, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 运行收尾路线
|
// 运行收尾路线
|
||||||
{
|
await runPathGroups(filePathEnding, "收尾");
|
||||||
// 读取文件夹中的文件名并处理
|
|
||||||
const filePaths = file.readPathSync(filePathEnding);
|
|
||||||
const jsonFileNames = [];
|
|
||||||
|
|
||||||
for (const filePath of filePaths) {
|
|
||||||
const fileName = basename(filePath); // 提取文件名
|
|
||||||
if (fileName.endsWith('.json')) { // 检查文件名是否以 .json 结尾
|
|
||||||
jsonFileNames.push(fileName); // 存储文件名
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let currentTask = 0; // 当前任务计数器
|
|
||||||
|
|
||||||
// 执行收尾路线的地图追踪文件
|
|
||||||
for (const fileName of jsonFileNames) {
|
|
||||||
const fullPath = fileName;
|
|
||||||
await fakeLog(fileName, false, true, 0);
|
|
||||||
currentTask += 1; // 更新当前任务计数器
|
|
||||||
log.info(`当前进度:${fullPath}为收尾${folderName}第${currentTask}/${jsonFileNames.length}个`);
|
|
||||||
await pathingScript.runFile(fullPath);
|
|
||||||
//捕获任务取消的信息并跳出循环
|
|
||||||
try {
|
|
||||||
await sleep(10); // 假设 sleep 是一个异步函数,休眠 10 毫秒
|
|
||||||
} catch (error) {
|
|
||||||
log.error(`发生错误: ${error}`);
|
|
||||||
return false; // 终止循环
|
|
||||||
}
|
|
||||||
await fakeLog(fileName, false, false, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 运行额外路线
|
// 运行额外路线
|
||||||
{
|
await runPathGroups(filePathExtra, "额外");
|
||||||
// 读取文件夹中的文件名并处理
|
|
||||||
const filePaths = file.readPathSync(filePathExtra);
|
|
||||||
const jsonFileNames = [];
|
|
||||||
|
|
||||||
for (const filePath of filePaths) {
|
|
||||||
const fileName = basename(filePath); // 提取文件名
|
|
||||||
if (fileName.endsWith('.json')) { // 检查文件名是否以 .json 结尾
|
|
||||||
jsonFileNames.push(fileName); // 存储文件名
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let currentTask = 0; // 当前任务计数器
|
|
||||||
|
|
||||||
// 执行额外路线的地图追踪文件
|
|
||||||
for (const fileName of jsonFileNames) {
|
|
||||||
const fullPath = fileName;
|
|
||||||
await fakeLog(fileName, false, true, 0);
|
|
||||||
currentTask += 1; // 更新当前任务计数器
|
|
||||||
log.info(`当前进度:${fullPath}为额外${folderName}第${currentTask}/${jsonFileNames.length}个`);
|
|
||||||
await pathingScript.runFile(fullPath);
|
|
||||||
//捕获任务取消的信息并跳出循环
|
|
||||||
try {
|
|
||||||
await sleep(10); // 假设 sleep 是一个异步函数,休眠 10 毫秒
|
|
||||||
} catch (error) {
|
|
||||||
log.error(`发生错误: ${error}`);
|
|
||||||
return false; // 终止循环
|
|
||||||
}
|
|
||||||
await fakeLog(fileName, false, false, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -702,11 +615,6 @@ async function fakeLog(name, isJs, isStart, duration) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 辅助函数:提取文件名
|
|
||||||
function basename(filePath) {
|
|
||||||
return filePath.split('/').pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
//用于获取结束时间
|
//用于获取结束时间
|
||||||
async function getEndTime(minIntervalTime, lastEndTime) {
|
async function getEndTime(minIntervalTime, lastEndTime) {
|
||||||
const minIntervalTimeInMs = minIntervalTime * 60 * 1000; // 将分钟转换为毫秒
|
const minIntervalTimeInMs = minIntervalTime * 60 * 1000; // 将分钟转换为毫秒
|
||||||
|
|||||||
Reference in New Issue
Block a user