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