fix(tools): 解决排序功能中的空值异常问题

- 为 localeCompare 方法调用添加可选链操作符
- 防止当 a_key 为 null 或 undefined 时引发错误
- 确保排序逻辑在所有情况下都能正常执行
This commit is contained in:
yan
2026-01-29 17:20:08 +08:00
parent d83d6f5435
commit 610679f962

View File

@@ -890,7 +890,7 @@ async function initRun(config_run) {
const orderA = orderMap.get(a_key) ?? 0; // 没在 JSON 中的排到最后
const orderB = orderMap.get(b_key) ?? 0;
if (orderA === orderB) {
return a_key.localeCompare(b_key);
return a_key?.localeCompare(b_key);
}
return orderB - orderA; // 修改为倒序数字比较
})