@whitesev/pops 3.3.3 → 3.3.4

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.
@@ -5351,10 +5351,13 @@ var pops = (function () {
5351
5351
  </div>`);
5352
5352
  // 存储原来的值
5353
5353
  Reflect.set($fileName, "__value__", folderData);
5354
- Reflect.set($folder, "folderData", folderData);
5354
+ Reflect.set($folder, "__value__", folderData);
5355
5355
  $folder.appendChild($fileName);
5356
5356
  return {
5357
5357
  folderElement: $folder,
5358
+ /**
5359
+ * 超链接标签的容器
5360
+ */
5358
5361
  fileNameElement: $fileName,
5359
5362
  };
5360
5363
  }
@@ -5443,8 +5446,17 @@ var pops = (function () {
5443
5446
  },
5444
5447
  addIndexCSS: false,
5445
5448
  });
5449
+ let childConfig;
5446
5450
  if (typeof dataConfig.clickEvent === "function") {
5447
- const childConfig = await dataConfig.clickEvent(clickEvent, dataConfig);
5451
+ const result = await dataConfig.clickEvent(clickEvent, dataConfig);
5452
+ if (Array.isArray(result)) {
5453
+ childConfig = result;
5454
+ }
5455
+ }
5456
+ else if (Array.isArray(dataConfig.clickEvent)) {
5457
+ childConfig = dataConfig.clickEvent;
5458
+ }
5459
+ if (childConfig) {
5448
5460
  // 添加顶部导航的箭头
5449
5461
  folderFileListBreadcrumbPrimaryElement.appendChild(this.createHeaderArrowIcon());
5450
5462
  // 添加顶部导航的链接文字
@@ -5458,50 +5470,65 @@ var pops = (function () {
5458
5470
  }
5459
5471
  loadingMask.close();
5460
5472
  }
5473
+ /**
5474
+ * 更新文件的显示的链接信息
5475
+ *
5476
+ * 这里主要用于鼠标中键或者右键触发,左键触发方式会根据mode进行处理
5477
+ * @returns 更新的文件的下载链接
5478
+ */
5479
+ updateFileLink($row, downloadInfo) {
5480
+ const downloadUrl = typeof downloadInfo?.url === "string" ? downloadInfo.url.trim() : "";
5481
+ if (downloadUrl !== "" && downloadUrl !== "null" && downloadUrl !== "undefined") {
5482
+ const $link = $row.querySelector("a");
5483
+ $link.setAttribute("href", downloadUrl);
5484
+ return downloadUrl;
5485
+ }
5486
+ }
5461
5487
  /**
5462
5488
  * 文件的点击事件 - 下载文件
5463
- * @param $target
5489
+ * @param evt 点击事件
5490
+ * @param $row 列表项
5464
5491
  * @param dataConfig
5465
5492
  */
5466
- async downloadFile(clickEvent, $row, dataConfig) {
5467
- popsDOMUtils.preventEvent(clickEvent);
5468
- const $link = $row.querySelector("a");
5493
+ async onFileClick(evt, $row, dataConfig) {
5494
+ let downloadInfo;
5469
5495
  if (typeof dataConfig.clickEvent === "function") {
5470
- const downloadInfo = await dataConfig.clickEvent(clickEvent, dataConfig);
5471
- if (downloadInfo != null &&
5472
- typeof downloadInfo === "object" &&
5473
- !Array.isArray(downloadInfo) &&
5474
- typeof downloadInfo.url === "string" &&
5475
- downloadInfo.url.trim() !== "") {
5476
- $link.setAttribute("href", downloadInfo.url);
5477
- $link.setAttribute("target", "_blank");
5478
- if (downloadInfo.autoDownload) {
5479
- if (downloadInfo.mode == null || String(downloadInfo.mode) === "") {
5480
- // 未设置mode的话默认为aBlank
5481
- downloadInfo.mode = "aBlank";
5482
- }
5496
+ const result = await dataConfig.clickEvent(evt, dataConfig);
5497
+ if (typeof result === "object" && result != null && !Array.isArray(result)) {
5498
+ downloadInfo = result;
5499
+ }
5500
+ }
5501
+ else if (typeof dataConfig.clickEvent === "object" &&
5502
+ dataConfig.clickEvent != null &&
5503
+ !Array.isArray(dataConfig.clickEvent)) {
5504
+ downloadInfo = dataConfig.clickEvent;
5505
+ }
5506
+ if (downloadInfo) {
5507
+ const downloadUrl = this.updateFileLink($row, downloadInfo);
5508
+ if (downloadUrl) {
5509
+ if (typeof downloadInfo.mode === "string") {
5483
5510
  if (downloadInfo.mode === "a" || downloadInfo.mode === "aBlank") {
5484
5511
  // a标签下载
5485
5512
  const $anchor = popsDOMUtils.createElement("a");
5486
5513
  if (downloadInfo.mode === "aBlank") {
5487
5514
  $anchor.setAttribute("target", "_blank");
5488
5515
  }
5489
- $anchor.href = downloadInfo.url;
5516
+ $anchor.href = downloadUrl;
5490
5517
  $anchor.click();
5491
5518
  }
5492
5519
  else if (downloadInfo.mode === "open" || downloadInfo.mode === "openBlank") {
5493
5520
  // window.open下载
5494
5521
  if (downloadInfo.mode === "openBlank") {
5495
- globalThis.open(downloadInfo.url, "_blank");
5522
+ globalThis.open(downloadUrl, "_blank");
5496
5523
  }
5497
5524
  else {
5498
- globalThis.open(downloadInfo.url);
5525
+ globalThis.open(downloadUrl);
5499
5526
  }
5500
5527
  }
5501
5528
  else if (downloadInfo.mode === "iframe") {
5502
5529
  // iframe下载
5503
5530
  const $downloadIframe = popsDOMUtils.createElement("iframe");
5504
- $downloadIframe.src = downloadInfo.url;
5531
+ $downloadIframe.src = downloadUrl;
5505
5532
  $downloadIframe.onload = function () {
5506
5533
  popsUtils.setTimeout(() => {
5507
5534
  $downloadIframe.remove();
@@ -5683,8 +5710,14 @@ var pops = (function () {
5683
5710
  // 文件 - 点击事件
5684
5711
  popsDOMUtils.on(fileNameElement, "click", (event) => {
5685
5712
  // 下载文件
5686
- this.downloadFile(event, fileNameElement, item);
5713
+ popsDOMUtils.preventEvent(event);
5714
+ this.onFileClick(event, fileNameElement, item);
5687
5715
  });
5716
+ // 如果clickEvent不是函数,那么现在就可以进行配置
5717
+ if (typeof item.clickEvent === "object" && item.clickEvent !== null && !Array.isArray(item.clickEvent)) {
5718
+ // {} 单文件配置
5719
+ this.updateFileLink(fileNameElement, item.clickEvent);
5720
+ }
5688
5721
  folderListBodyElement.appendChild(folderElement);
5689
5722
  }
5690
5723
  });
@@ -13369,7 +13402,7 @@ var pops = (function () {
13369
13402
  },
13370
13403
  };
13371
13404
 
13372
- const version = "3.3.3";
13405
+ const version = "3.3.4";
13373
13406
 
13374
13407
  class Pops {
13375
13408
  /** 配置 */