a2bei4-utils 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1222,6 +1222,9 @@ async function fetchOrDownloadByUrl(url, fileName) {
1222
1222
  const urlPathname = new URL(url).pathname;
1223
1223
  // 获取路径的最后一部分作为文件名,并移除可能的查询参数
1224
1224
  fileName = urlPathname.substring(urlPathname.lastIndexOf("/") + 1).split("?")[0];
1225
+ if (fileName) {
1226
+ fileName = decodeURIComponent(fileName);
1227
+ }
1225
1228
  } catch (e) {}
1226
1229
  // 如果提取后文件名为空(例如 URL 以 '/' 结尾),也使用时间戳
1227
1230
  if (!fileName) {
@@ -1792,23 +1795,23 @@ function flatCompleteTree2NestedTree(nodes, parentId = 0, { idKey = "id", parent
1792
1795
  * @param {T[]} arr - 嵌套树森林
1793
1796
  * @param {string} [idKey='id'] - 主键字段
1794
1797
  * @param {string} [childrenKey='children'] - 子节点字段
1795
- * @returns {any} 找到的节点;未找到返回 `undefined`
1798
+ * @returns {T | undefined} 找到的节点;未找到返回 `undefined`
1796
1799
  */
1797
- const findTreeNodeById = function findTreeNodeByIdFn(id, arr, idKey = "id", childrenKey = "children") {
1800
+ function findTreeNodeById(id, arr, idKey = "id", childrenKey = "children") {
1798
1801
  if (Array.isArray(arr) && arr.length > 0) {
1799
1802
  for (let i = 0; i < arr.length; i++) {
1800
1803
  const item = arr[i];
1801
1804
  if (item[idKey]?.toString() === id?.toString()) {
1802
1805
  return item;
1803
1806
  } else if (Array.isArray(item[childrenKey]) && item[childrenKey].length > 0) {
1804
- const result = findTreeNodeByIdFn(id, item[childrenKey], idKey, childrenKey);
1807
+ const result = findTreeNodeById(id, item[childrenKey], idKey, childrenKey);
1805
1808
  if (result) {
1806
1809
  return result;
1807
1810
  }
1808
1811
  }
1809
1812
  }
1810
1813
  }
1811
- };
1814
+ }
1812
1815
 
1813
1816
  /**
1814
1817
  * 在嵌套树中按 `id` 递归查找节点,并返回其指定属性值。