wkjp-list-page 1.0.36 → 1.0.38

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wkjp-list-page",
3
- "version": "1.0.36",
3
+ "version": "1.0.38",
4
4
  "description": "Vue2 + ElementUI CommonListPage component",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
@@ -770,22 +770,44 @@ export default {
770
770
  // 英文字母/数字:超过40个字符宽度单位(约40个英文字母/数字)
771
771
  shouldShowOverflowTooltip(text) {
772
772
  var str = String(text == null ? "" : text);
773
+
774
+ // 如果字符串为空,不显示省略号
775
+ if (str.length === 0) {
776
+ return false;
777
+ }
778
+
773
779
  var fullWidthCount = 0; // 全角字符计数
774
780
  var halfWidthCount = 0; // 半角字符计数
781
+ var isPureNumberOrLetter = true; // 标记是否为纯数字或字母
775
782
 
776
783
  for (var i = 0; i < str.length; i++) {
777
784
  var charCode = str.charCodeAt(i);
785
+ var char = str.charAt(i);
786
+
787
+ // 检查是否为全角字符
778
788
  if (
779
789
  (charCode >= 0x4E00 && charCode <= 0x9FFF) || // 中文
780
790
  (charCode >= 0x3000 && charCode <= 0x303F) || // CJK符号和标点
781
791
  (charCode >= 0xFF00 && charCode <= 0xFFEF) // 全角字符
782
792
  ) {
783
793
  fullWidthCount++;
794
+ isPureNumberOrLetter = false; // 包含全角字符,不是纯数字/字母
784
795
  } else {
785
796
  halfWidthCount++;
797
+ // 检查是否为数字或字母(半角)
798
+ if (!((charCode >= 48 && charCode <= 57) || // 数字 0-9
799
+ (charCode >= 65 && charCode <= 90) || // 大写字母 A-Z
800
+ (charCode >= 97 && charCode <= 122))) { // 小写字母 a-z
801
+ isPureNumberOrLetter = false; // 包含非数字字母字符
802
+ }
786
803
  }
787
804
  }
788
805
 
806
+ // 纯数字或字母内容不显示省略号
807
+ if (isPureNumberOrLetter && halfWidthCount > 0 && fullWidthCount === 0) {
808
+ return false;
809
+ }
810
+
789
811
  // 计算总宽度单位:全角字符*2 + 半角字符*1
790
812
  var totalWidth = fullWidthCount * 2 + halfWidthCount;
791
813
 
@@ -907,6 +929,7 @@ export default {
907
929
  // slot 列可以设置 showOverflowTooltip
908
930
  // 对于 slot 列,我们只检查用户是否显式设置了 showOverflowTooltip
909
931
  // 因为 slot 列的内容是自定义的,无法自动判断是否需要省略号
932
+ // 注意:slot列无法自动判断内容是否为纯数字字母,所以这里保留用户设置
910
933
  if (col.showOverflowTooltip === true) {
911
934
  slotLayout.showOverflowTooltip = true;
912
935
  }
@@ -962,10 +985,16 @@ export default {
962
985
  if (Number.isFinite(userWidth) && userWidth > 0) {
963
986
  // 获取最长内容的字符串来判断是否需要显示省略号
964
987
  var maxContentText = this.getColumnMaxContentText(col);
965
- var shouldShowTooltip = this.shouldShowOverflowTooltip(maxContentText) || col.showOverflowTooltip === true;
988
+ var shouldShowTooltip = this.shouldShowOverflowTooltip(maxContentText);
989
+ // 纯数字字母内容不显示省略号,即使设置了 showOverflowTooltip: true
990
+ if (shouldShowTooltip) {
991
+ return {
992
+ width: userWidth,
993
+ showOverflowTooltip: true
994
+ };
995
+ }
966
996
  return {
967
- width: userWidth,
968
- showOverflowTooltip: shouldShowTooltip
997
+ width: userWidth
969
998
  };
970
999
  }
971
1000
  }
@@ -977,7 +1006,8 @@ export default {
977
1006
  // 判断是否需要显示 tooltip
978
1007
  // 获取最长内容的字符串来判断是否需要显示省略号
979
1008
  var maxContentText = this.getColumnMaxContentText(col);
980
- var shouldShowTooltip = this.shouldShowOverflowTooltip(maxContentText) || col.showOverflowTooltip === true;
1009
+ var shouldShowTooltip = this.shouldShowOverflowTooltip(maxContentText);
1010
+ // 纯数字字母内容不显示省略号,即使设置了 showOverflowTooltip: true
981
1011
  if (shouldShowTooltip) {
982
1012
  layout.showOverflowTooltip = true;
983
1013
  }