@whitesev/pops 1.5.1 → 1.5.3

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.umd.js CHANGED
@@ -2961,8 +2961,6 @@
2961
2961
  deviation = Number.isNaN(deviation) ? 1 : deviation;
2962
2962
  // 最大值2147483647
2963
2963
  let maxZIndex = Math.pow(2, 31) - 1;
2964
- // 比较值2000000000
2965
- let maxZIndexCompare = 2 * Math.pow(10, 9);
2966
2964
  // 当前页面最大的z-index
2967
2965
  let zIndex = 0;
2968
2966
  // 当前的最大z-index的元素,调试使用
@@ -2985,11 +2983,13 @@
2985
2983
  }
2986
2984
  });
2987
2985
  zIndex += deviation;
2986
+ // 用于比较的值2000000000,大于该值就取该值
2987
+ let maxZIndexCompare = 2 * Math.pow(10, 9);
2988
2988
  if (zIndex >= maxZIndexCompare) {
2989
2989
  // 最好不要超过最大值
2990
2990
  zIndex = maxZIndex;
2991
2991
  }
2992
- return { zIndex: maxZIndex, animElement: maxZIndexNode };
2992
+ return { zIndex: zIndex, animElement: maxZIndexNode };
2993
2993
  },
2994
2994
  /**
2995
2995
  * 获取CSS Rule
@@ -5943,7 +5943,7 @@
5943
5943
  <div class="text-ellip content flex-a-i-center">
5944
5944
  <span>文件名</span>
5945
5945
  <div class="pops-folder-list-table__sort" data-sort="fileName">
5946
- <div class="pops-folder-icon-arrow">
5946
+ <div class="pops-folder-icon-arrow" data-sort="按文件名排序">
5947
5947
  <svg
5948
5948
  viewBox="0 0 1024 1024"
5949
5949
  xmlns="http://www.w3.org/2000/svg">
@@ -5962,7 +5962,7 @@
5962
5962
  <div class="text-ellip content flex-a-i-center">
5963
5963
  <span>修改时间</span>
5964
5964
  <div class="pops-folder-list-table__sort" data-sort="latestTime">
5965
- <div class="pops-folder-icon-arrow">
5965
+ <div class="pops-folder-icon-arrow" title="按修改时间排序">
5966
5966
  <svg
5967
5967
  viewBox="0 0 1024 1024"
5968
5968
  xmlns="http://www.w3.org/2000/svg">
@@ -5981,7 +5981,7 @@
5981
5981
  <div class="text-ellip content flex-a-i-center">
5982
5982
  <span>大小</span>
5983
5983
  <div class="pops-folder-list-table__sort" data-sort="fileSize">
5984
- <div class="pops-folder-icon-arrow">
5984
+ <div class="pops-folder-icon-arrow" title="按大小排序">
5985
5985
  <svg
5986
5986
  viewBox="0 0 1024 1024"
5987
5987
  xmlns="http://www.w3.org/2000/svg">
@@ -6071,8 +6071,9 @@
6071
6071
  * @param fileName
6072
6072
  * @param latestTime
6073
6073
  * @param [fileSize="-"]
6074
+ * @param isFolder
6074
6075
  */
6075
- function createFolderRowElement(fileName, latestTime = "-", fileSize = "-") {
6076
+ function createFolderRowElement(fileName, latestTime = "-", fileSize = "-", isFolder = false) {
6076
6077
  let origin_fileName = fileName;
6077
6078
  let origin_latestTime = latestTime;
6078
6079
  let origin_fileSize = fileSize;
@@ -6082,7 +6083,7 @@
6082
6083
  let fileFormatSize = popsDOMUtils.createElement("td");
6083
6084
  let fileType = "";
6084
6085
  let fileIcon = Folder_ICON.folder;
6085
- if (arguments.length === 1) {
6086
+ if (isFolder) {
6086
6087
  /* 文件夹 */
6087
6088
  latestTime = "";
6088
6089
  fileSize = "";
@@ -6137,6 +6138,7 @@
6137
6138
  fileName: origin_fileName,
6138
6139
  latestTime: origin_latestTime,
6139
6140
  fileSize: origin_fileSize,
6141
+ isFolder: isFolder,
6140
6142
  };
6141
6143
  fileNameElement["__value__"] = __value__;
6142
6144
  fileTimeElement["__value__"] = __value__;
@@ -6155,7 +6157,7 @@
6155
6157
  /**
6156
6158
  * 创建移动端文件夹元素
6157
6159
  */
6158
- function createMobileFolderRowElement(fileName, latestTime = "-", fileSize = "-") {
6160
+ function createMobileFolderRowElement(fileName, latestTime = "-", fileSize = "-", isFolder = false) {
6159
6161
  let origin_fileName = fileName;
6160
6162
  let origin_latestTime = latestTime;
6161
6163
  let origin_fileSize = fileSize;
@@ -6163,7 +6165,7 @@
6163
6165
  let fileNameElement = popsDOMUtils.createElement("td");
6164
6166
  let fileType = "";
6165
6167
  let fileIcon = Folder_ICON.folder;
6166
- if (arguments.length === 1) {
6168
+ if (isFolder) {
6167
6169
  /* 文件夹 */
6168
6170
  latestTime = "";
6169
6171
  fileSize = "";
@@ -6207,6 +6209,7 @@
6207
6209
  fileName: origin_fileName,
6208
6210
  latestTime: origin_latestTime,
6209
6211
  fileSize: origin_fileSize,
6212
+ isFolder: isFolder,
6210
6213
  };
6211
6214
  fileNameElement["__value__"] = __value__;
6212
6215
  folderELement["__value__"] = __value__;
@@ -6380,30 +6383,40 @@
6380
6383
  }
6381
6384
  /**
6382
6385
  * 对配置进行排序
6383
- * @param _config_
6386
+ * @param folderDataConfigList
6384
6387
  * @param sortName 比较的属性,默认fileName
6385
6388
  * @param isDesc 是否降序,默认false(升序)
6386
6389
  */
6387
- function sortFolderConfig(_config_, sortName = "fileName", isDesc = false) {
6388
- _config_.sort((a, b) => {
6389
- let beforeVal = a[sortName];
6390
- let afterVal = b[sortName];
6391
- if (sortName === "fileName") {
6392
- /* 文件名,进行字符串转换 */
6393
- beforeVal = beforeVal.toString();
6394
- afterVal = afterVal.toString();
6395
- }
6396
- else if (sortName === "fileSize") {
6397
- /* 文件大小,进行Float转换 */
6398
- beforeVal = parseFloat(beforeVal);
6399
- afterVal = parseFloat(afterVal);
6400
- }
6401
- else if (sortName === "latestTime") {
6402
- /* 文件时间 */
6403
- beforeVal = new Date(beforeVal).getTime();
6404
- afterVal = new Date(afterVal).getTime();
6405
- }
6406
- if (typeof beforeVal === "string" && typeof afterVal === "string") {
6390
+ function sortFolderConfig(folderDataConfigList, sortName = "fileName", isDesc = false) {
6391
+ console.log(folderDataConfigList, sortName, isDesc);
6392
+ if (sortName === "fileName") {
6393
+ // 如果是以文件名排序,文件夹优先放前面
6394
+ let onlyFolderDataConfigList = folderDataConfigList.filter((value) => {
6395
+ return value.isFolder;
6396
+ });
6397
+ let onlyFileDataConfigList = folderDataConfigList.filter((value) => {
6398
+ return !value.isFolder;
6399
+ });
6400
+ // 文件夹排序
6401
+ onlyFolderDataConfigList.sort((leftConfig, rightConfig) => {
6402
+ let beforeVal = leftConfig[sortName].toString();
6403
+ let afterVal = rightConfig[sortName].toString();
6404
+ let compareVal = beforeVal.localeCompare(afterVal);
6405
+ if (isDesc) {
6406
+ /* 降序 */
6407
+ if (compareVal > 0) {
6408
+ compareVal = -1;
6409
+ }
6410
+ else if (compareVal < 0) {
6411
+ compareVal = 1;
6412
+ }
6413
+ }
6414
+ return compareVal;
6415
+ });
6416
+ // 文件名排序
6417
+ onlyFileDataConfigList.sort((leftConfig, rightConfig) => {
6418
+ let beforeVal = leftConfig[sortName].toString();
6419
+ let afterVal = rightConfig[sortName].toString();
6407
6420
  let compareVal = beforeVal.localeCompare(afterVal);
6408
6421
  if (isDesc) {
6409
6422
  /* 降序 */
@@ -6415,8 +6428,30 @@
6415
6428
  }
6416
6429
  }
6417
6430
  return compareVal;
6431
+ });
6432
+ if (isDesc) {
6433
+ // 降序,文件夹在下面
6434
+ return [...onlyFileDataConfigList, ...onlyFolderDataConfigList];
6418
6435
  }
6419
6436
  else {
6437
+ // 升序,文件夹在上面
6438
+ return [...onlyFolderDataConfigList, ...onlyFileDataConfigList];
6439
+ }
6440
+ }
6441
+ else {
6442
+ folderDataConfigList.sort((beforeConfig, afterConfig) => {
6443
+ let beforeVal = beforeConfig[sortName];
6444
+ let afterVal = afterConfig[sortName];
6445
+ if (sortName === "fileSize") {
6446
+ /* 文件大小,进行Float转换 */
6447
+ beforeVal = parseFloat(beforeVal.toString());
6448
+ afterVal = parseFloat(afterVal.toString());
6449
+ }
6450
+ else if (sortName === "latestTime") {
6451
+ /* 文件时间 */
6452
+ beforeVal = new Date(beforeVal).getTime();
6453
+ afterVal = new Date(afterVal).getTime();
6454
+ }
6420
6455
  if (beforeVal > afterVal) {
6421
6456
  if (isDesc) {
6422
6457
  /* 降序 */
@@ -6438,9 +6473,9 @@
6438
6473
  else {
6439
6474
  return 0;
6440
6475
  }
6441
- }
6442
- });
6443
- return _config_;
6476
+ });
6477
+ return folderDataConfigList;
6478
+ }
6444
6479
  }
6445
6480
  /**
6446
6481
  * 添加元素
@@ -6451,8 +6486,8 @@
6451
6486
  _config_.forEach((item) => {
6452
6487
  if (item["isFolder"]) {
6453
6488
  let { folderELement, fileNameElement } = pops.isPhone()
6454
- ? createMobileFolderRowElement(item["fileName"])
6455
- : createFolderRowElement(item["fileName"]);
6489
+ ? createMobileFolderRowElement(item["fileName"], "", "", true)
6490
+ : createFolderRowElement(item["fileName"], "", "", true);
6456
6491
  popsDOMUtils.on(fileNameElement, "click", (event) => {
6457
6492
  refreshFolderInfoClickEvent(event, item);
6458
6493
  });
@@ -6460,8 +6495,8 @@
6460
6495
  }
6461
6496
  else {
6462
6497
  let { folderELement, fileNameElement } = pops.isPhone()
6463
- ? createMobileFolderRowElement(item["fileName"], item["latestTime"], item["fileSize"])
6464
- : createFolderRowElement(item["fileName"], item["latestTime"], item["fileSize"]);
6498
+ ? createMobileFolderRowElement(item["fileName"], item.latestTime, item.fileSize, false)
6499
+ : createFolderRowElement(item["fileName"], item.latestTime, item.fileSize, false);
6465
6500
  setFileClickEvent(fileNameElement, item);
6466
6501
  folderListBodyElement.appendChild(folderELement);
6467
6502
  }
@@ -6498,7 +6533,6 @@
6498
6533
  * @param {PointerEvent} target
6499
6534
  * @param {HTMLElement} event
6500
6535
  * @param {string} sortName
6501
- * @returns
6502
6536
  */
6503
6537
  function arrowSortClickEvent(target, event, sortName) {
6504
6538
  if (!event["notChangeSortRule"]) {
@@ -9952,7 +9986,7 @@
9952
9986
  /** 配置 */
9953
9987
  config = {
9954
9988
  /** 版本号 */
9955
- version: "2024.8.6",
9989
+ version: "2024.9.9",
9956
9990
  cssText: {
9957
9991
  /** 主CSS */
9958
9992
  index: indexCSS,