raintee-maputils 1.0.24 → 1.0.26

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.
package/dist/index.js CHANGED
@@ -5754,7 +5754,6 @@ var RainteeGISUtil = /*#__PURE__*/Object.freeze({
5754
5754
  });
5755
5755
 
5756
5756
  const treeDataAdapter = (data) => {
5757
- let i = 0;
5758
5757
  let treeData = [];
5759
5758
  let checkedKeys = [];
5760
5759
  data.forEach((item) => {
@@ -5762,16 +5761,17 @@ const treeDataAdapter = (data) => {
5762
5761
  let groups = kvs.find(item => item[0] === 'Main')[1].split('/');
5763
5762
  let layerName = kvs.find(item => item[0] === 'CN')[1];
5764
5763
  let currentNode = treeData;
5764
+ let currentNodeKey = '';
5765
5765
  groups.forEach((group, index) => {
5766
- currentNode.find(item => item.label === group) || i++;
5766
+ currentNode.find(item => item.label === group) || (() => { currentNodeKey += group; })();
5767
5767
  currentNode.find(item => item.label === group) || currentNode.push({
5768
- id: i,
5768
+ id: currentNodeKey,
5769
5769
  label: group,
5770
5770
  children: []
5771
5771
  });
5772
5772
  currentNode = currentNode.find(item => item.label === group).children;
5773
5773
  });
5774
- i++;
5774
+ currentNodeKey += layerName;
5775
5775
  currentNode.push({
5776
5776
  id: i,
5777
5777
  label: layerName,
@@ -6038,6 +6038,30 @@ function mergeStringAndObject(str, obj) {
6038
6038
  console.error('合并过程中发生错误:', error);
6039
6039
  return str; // 出错时返回原字符串
6040
6040
  }
6041
+ }
6042
+
6043
+ function sortDataFromCNToEN(data) {
6044
+ function isFirstCharLetter(str) {
6045
+ if (!str || typeof str !== 'string') return false;
6046
+ const firstChar = str.charAt(0);
6047
+ return /^[a-zA-Z]$/.test(firstChar);
6048
+ }
6049
+ // 排序逻辑:非字母开头的排前面,字母开头的排后面
6050
+ const sortedData = data.sort((a, b) => {
6051
+
6052
+ const aIsLetter = isFirstCharLetter(a.text);
6053
+ const bIsLetter = isFirstCharLetter(b.text);
6054
+
6055
+ // 如果 a 不是字母开头,b 是字母开头 → a 排前面 → 返回 -1
6056
+ // 如果 a 是字母开头,b 不是字母开头 → b 排前面 → 返回 1
6057
+ // 如果都是或都不是 → 保持原顺序(稳定)或进一步排序
6058
+ if (!aIsLetter && bIsLetter) return -1;
6059
+ if (aIsLetter && !bIsLetter) return 1;
6060
+
6061
+ // 同组内的排序(可选):可以按 text 升序排列
6062
+ return a.text.localeCompare(b.text);
6063
+ });
6064
+ return sortedData
6041
6065
  }
6042
6066
 
6043
6067
  var RainteeSourceMapTool = /*#__PURE__*/Object.freeze({
@@ -6047,6 +6071,7 @@ var RainteeSourceMapTool = /*#__PURE__*/Object.freeze({
6047
6071
  generateKeyValueTableHTML: generateKeyValueTableHTML,
6048
6072
  getLayerIdFidld: getLayerIdFidld,
6049
6073
  mergeStringAndObject: mergeStringAndObject,
6074
+ sortDataFromCNToEN: sortDataFromCNToEN,
6050
6075
  treeDataAdapter: treeDataAdapter,
6051
6076
  treeDataAdapterNext: treeDataAdapterNext
6052
6077
  });