zartui 3.1.92 → 3.1.94

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.
Files changed (57) hide show
  1. package/es/composables/use-media-download.d.ts +20 -0
  2. package/es/composables/use-media-download.mjs +111 -0
  3. package/es/drawer-select/DrawerSelect.mjs +13 -30
  4. package/es/drawer-select/index.css +1 -1
  5. package/es/image-preview/ImagePreview.d.ts +2 -5
  6. package/es/image-preview/ImagePreview.mjs +32 -79
  7. package/es/image-preview/function-call.mjs +4 -1
  8. package/es/image-preview/index.css +1 -1
  9. package/es/image-preview/index.d.ts +1 -2
  10. package/es/image-preview/style/index.mjs +2 -0
  11. package/es/image-preview/types.d.ts +3 -1
  12. package/es/index.d.ts +1 -1
  13. package/es/index.mjs +1 -1
  14. package/es/media-picker/MediaPicker.d.ts +1 -1
  15. package/es/media-picker/MediaPicker.mjs +54 -36
  16. package/es/media-picker/index.d.ts +2 -2
  17. package/es/media-picker/style/index.mjs +3 -1
  18. package/es/media-player/MediaPlayer.d.ts +21 -0
  19. package/es/media-player/MediaPlayer.mjs +25 -2
  20. package/es/media-player/index.css +1 -1
  21. package/es/media-player/index.d.ts +14 -0
  22. package/es/media-player/style/index.mjs +4 -0
  23. package/es/photo-picker/index.d.ts +2 -2
  24. package/es/photo-picker/style/index.mjs +2 -0
  25. package/es/uploader/style/index.mjs +2 -0
  26. package/lib/composables/use-media-download.d.ts +20 -0
  27. package/lib/composables/use-media-download.js +138 -0
  28. package/lib/drawer-select/DrawerSelect.js +12 -29
  29. package/lib/drawer-select/index.css +1 -1
  30. package/lib/image-preview/ImagePreview.d.ts +2 -5
  31. package/lib/image-preview/ImagePreview.js +32 -79
  32. package/lib/image-preview/function-call.js +4 -1
  33. package/lib/image-preview/index.css +1 -1
  34. package/lib/image-preview/index.d.ts +1 -2
  35. package/lib/image-preview/style/index.js +2 -0
  36. package/lib/image-preview/types.d.ts +3 -1
  37. package/lib/index.css +1 -1
  38. package/lib/index.d.ts +1 -1
  39. package/lib/index.js +1 -1
  40. package/lib/media-picker/MediaPicker.d.ts +1 -1
  41. package/lib/media-picker/MediaPicker.js +51 -35
  42. package/lib/media-picker/index.d.ts +2 -2
  43. package/lib/media-picker/style/index.js +3 -1
  44. package/lib/media-player/MediaPlayer.d.ts +21 -0
  45. package/lib/media-player/MediaPlayer.js +25 -2
  46. package/lib/media-player/index.css +1 -1
  47. package/lib/media-player/index.d.ts +14 -0
  48. package/lib/media-player/style/index.js +4 -0
  49. package/lib/photo-picker/index.d.ts +2 -2
  50. package/lib/photo-picker/style/index.js +2 -0
  51. package/lib/uploader/style/index.js +2 -0
  52. package/lib/web-types.json +1 -1
  53. package/lib/zartui.cjs.js +208 -134
  54. package/lib/zartui.es.js +208 -134
  55. package/lib/zartui.js +216 -142
  56. package/lib/zartui.min.js +2 -2
  57. package/package.json +5 -5
package/lib/zartui.es.js CHANGED
@@ -9081,7 +9081,6 @@ var stdin_default$15 = defineComponent({
9081
9081
  const commonTypesListRef = ref();
9082
9082
  const showLeftCommonTypesMask = ref(false);
9083
9083
  const showRightCommonTypesMask = ref(false);
9084
- let commonTypesResizeObserver;
9085
9084
  const defaultTreeNode = ref(props.treeData);
9086
9085
  const fields = computed(() => assignDefaultFields$1(props.treeFieldName));
9087
9086
  const visibleCommonTypeList = computed(() => {
@@ -9096,35 +9095,25 @@ var stdin_default$15 = defineComponent({
9096
9095
  children,
9097
9096
  text: key
9098
9097
  } = fields.value;
9098
+ const syncSelectCommonId = (node) => {
9099
+ const selectedId = node == null ? void 0 : node[value];
9100
+ selectCommonId.value = typeof selectedId === "string" || typeof selectedId === "number" ? selectedId : -1;
9101
+ };
9102
+ syncSelectCommonId(props.defaultSelectNode);
9103
+ watch(() => props.defaultSelectNode, (node) => {
9104
+ selectNode.value = node;
9105
+ syncSelectCommonId(node);
9106
+ });
9099
9107
  const updateCommonTypesMask = () => {
9100
9108
  const list = commonTypesListRef.value;
9101
- if (!list) {
9102
- showLeftCommonTypesMask.value = false;
9103
- showRightCommonTypesMask.value = false;
9109
+ if (!list)
9104
9110
  return;
9105
- }
9106
- const remainingScrollWidth = list.scrollWidth - list.clientWidth - list.scrollLeft;
9107
9111
  showLeftCommonTypesMask.value = list.scrollLeft > 0;
9108
- showRightCommonTypesMask.value = remainingScrollWidth > 1;
9112
+ showRightCommonTypesMask.value = list.scrollLeft + list.clientWidth < list.scrollWidth;
9109
9113
  };
9110
9114
  const onCommonTypesScroll = () => {
9111
9115
  updateCommonTypesMask();
9112
9116
  };
9113
- const observeCommonTypesList = () => {
9114
- commonTypesResizeObserver == null ? void 0 : commonTypesResizeObserver.disconnect();
9115
- const list = commonTypesListRef.value;
9116
- if (!list || typeof ResizeObserver === "undefined") {
9117
- return;
9118
- }
9119
- commonTypesResizeObserver = new ResizeObserver(updateCommonTypesMask);
9120
- commonTypesResizeObserver.observe(list);
9121
- };
9122
- const updateCommonTypesLayout = () => {
9123
- nextTick(() => {
9124
- observeCommonTypesList();
9125
- updateCommonTypesMask();
9126
- });
9127
- };
9128
9117
  const allData = {
9129
9118
  [value]: -1,
9130
9119
  [key]: "全部",
@@ -9201,13 +9190,7 @@ var stdin_default$15 = defineComponent({
9201
9190
  };
9202
9191
  flatData(props.treeData);
9203
9192
  updateOffset();
9204
- updateCommonTypesLayout();
9205
- });
9206
- watch(visibleCommonTypeList, updateCommonTypesLayout, {
9207
- flush: "post"
9208
- });
9209
- onBeforeUnmount(() => {
9210
- commonTypesResizeObserver == null ? void 0 : commonTypesResizeObserver.disconnect();
9193
+ nextTick(updateCommonTypesMask);
9211
9194
  });
9212
9195
  const isEmpty = (item) => !item[children] || item[children].length === 0;
9213
9196
  const syncExpandNodeByParent = (item) => {
@@ -12456,15 +12439,25 @@ var stdin_default$U = defineComponent({
12456
12439
  };
12457
12440
  }
12458
12441
  });
12459
- const Download = (bem2) => createVNode("svg", {
12460
- "class": bem2("svg-download-icon"),
12461
- "xmlns": "http://www.w3.org/2000/svg",
12462
- "viewBox": "0 0 20 20"
12463
- }, [createVNode("path", {
12464
- "d": "M3.75,17.5 C3.28976271,17.5 2.91666667,17.126904 2.91666667,16.6666667 L2.91666667,12.5 C2.91666667,12.0397627 3.28976271,11.6666667 3.75,11.6666667 C4.21023729,11.6666667 4.58333333,12.0397627 4.58333333,12.5 L4.58266667,15.833 L15.4166667,15.833 L15.4166667,12.5 C15.4166667,12.0397627 15.7897627,11.6666667 16.25,11.6666667 C16.7102373,11.6666667 17.0833333,12.0397627 17.0833333,12.5 L17.0833333,16.6666667 C17.0833333,17.0915011 16.765429,17.442085 16.3545316,17.4935072 L16.25,17.5 L3.75,17.5 Z M10,2.5 C10.4602373,2.5 10.8333333,2.87309604 10.8333333,3.33333333 L10.834,10.904 L12.327411,9.41074435 L12.3804172,9.36206404 C12.7078286,9.08620893 13.1976137,9.1024357 13.5059223,9.41074435 C13.8313592,9.73618126 13.8313592,10.2638187 13.5059223,10.5892557 L10.5892557,13.5059223 L10.5659501,13.5283458 C10.5602582,13.5336148 10.5544926,13.5388053 10.548655,13.5439156 L10.5362495,13.5546026 L10.5121742,13.5740743 C10.4949132,13.5875412 10.4771081,13.6003432 10.4586783,13.6126074 C10.4455853,13.6212563 10.4323019,13.6294968 10.4192578,13.6370097 C10.4029078,13.6465464 10.3862038,13.6555423 10.3690405,13.664083 C10.3522054,13.6723976 10.3351478,13.6801087 10.3177097,13.6872958 C10.3045293,13.6927357 10.2911788,13.6978473 10.2777746,13.7025471 C10.2584813,13.7093513 10.2389875,13.7154237 10.2194971,13.7207897 C10.2011918,13.7257748 10.1826357,13.7301514 10.1634324,13.7339067 L10.1207556,13.7413147 C10.0813306,13.7470375 10.0410112,13.75 10,13.75 L10.0566667,13.747 L10.0399512,13.7490477 L9.96132783,13.7491078 C9.94161389,13.7481976 9.92192612,13.746591 9.89546844,13.7435072 C9.79274407,13.7306516 9.69583178,13.6990985 9.6082458,13.6523619 L9.59484365,13.6451239 C9.58442452,13.639322 9.57410342,13.6332795 9.56375825,13.6268308 C9.54437371,13.6148978 9.52551484,13.6021934 9.50686916,13.5885746 L9.48480346,13.5717051 L9.41074435,13.5059223 L6.49407768,10.5892557 L6.44539737,10.5362495 C6.16954226,10.2088381 6.18576903,9.719053 6.49407768,9.41074435 L6.54708384,9.36206404 C6.87449527,9.08620893 7.36428033,9.1024357 7.67258898,9.41074435 L9.167,10.905 L9.16666667,3.33333333 C9.16666667,2.87309604 9.53976271,2.5 10,2.5 Z",
12465
- "fill": "#FFF",
12466
- "fill-rule": "nonzero"
12467
- }, null)]);
12442
+ var __defProp$1 = Object.defineProperty;
12443
+ var __defProps$1 = Object.defineProperties;
12444
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
12445
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
12446
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
12447
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
12448
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12449
+ var __spreadValues$1 = (a, b) => {
12450
+ for (var prop in b || (b = {}))
12451
+ if (__hasOwnProp$1.call(b, prop))
12452
+ __defNormalProp$1(a, prop, b[prop]);
12453
+ if (__getOwnPropSymbols$1)
12454
+ for (var prop of __getOwnPropSymbols$1(b)) {
12455
+ if (__propIsEnum$1.call(b, prop))
12456
+ __defNormalProp$1(a, prop, b[prop]);
12457
+ }
12458
+ return a;
12459
+ };
12460
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
12468
12461
  var __async$4 = (__this, __arguments, generator) => {
12469
12462
  return new Promise((resolve, reject) => {
12470
12463
  var fulfilled = (value) => {
@@ -12485,6 +12478,72 @@ var __async$4 = (__this, __arguments, generator) => {
12485
12478
  step((generator = generator.apply(__this, __arguments)).next());
12486
12479
  });
12487
12480
  };
12481
+ function useMediaDownload(props) {
12482
+ const downloading = ref(false);
12483
+ const downloadInBrowser = (params) => {
12484
+ const link = document.createElement("a");
12485
+ link.href = params.url;
12486
+ link.download = params.fileName || "";
12487
+ document.body.appendChild(link);
12488
+ link.click();
12489
+ link.remove();
12490
+ };
12491
+ const download = (params, confirm = false) => __async$4(this, null, function* () {
12492
+ var _a, _b, _c;
12493
+ if (!props.showDownload || downloading.value || !params.url || params.url.startsWith("data:")) {
12494
+ return;
12495
+ }
12496
+ downloading.value = true;
12497
+ try {
12498
+ if (confirm) {
12499
+ try {
12500
+ yield showConfirmDialog({ message: "附件格式暂不支持预览,是否下载原文件" });
12501
+ } catch (action) {
12502
+ if (action !== "cancel") {
12503
+ throw action;
12504
+ }
12505
+ return;
12506
+ }
12507
+ }
12508
+ if (!props.showDownload || ((_a = props.downloadAction) == null ? void 0 : _a.call(props, params))) {
12509
+ return;
12510
+ }
12511
+ let file;
12512
+ try {
12513
+ const sdk = yield import("./index-096e2873.mjs");
12514
+ file = (_b = sdk.getJSI()) == null ? void 0 : _b.file;
12515
+ } catch (e) {
12516
+ downloadInBrowser(params);
12517
+ return;
12518
+ }
12519
+ if (!(file == null ? void 0 : file.download)) {
12520
+ downloadInBrowser(params);
12521
+ return;
12522
+ }
12523
+ showLoadingToast({ message: "下载中...", forbidClick: true, duration: 0 });
12524
+ try {
12525
+ const result = yield file.download({ url: params.url });
12526
+ const displayPath = (_c = result == null ? void 0 : result.tempFilePath) == null ? void 0 : _c.replace(/^\/storage\/emulated\/0\//, "");
12527
+ closeToast();
12528
+ showSuccessToast({
12529
+ message: displayPath ? `下载成功
12530
+ 保存路径:${displayPath}` : "下载成功",
12531
+ duration: 5e3
12532
+ });
12533
+ } catch (e) {
12534
+ closeToast();
12535
+ showFailToast("下载失败");
12536
+ }
12537
+ } finally {
12538
+ downloading.value = false;
12539
+ }
12540
+ });
12541
+ const downloadFile = (options) => {
12542
+ var _a;
12543
+ return download(__spreadProps$1(__spreadValues$1({}, options), { index: (_a = options.index) != null ? _a : -1 }), true);
12544
+ };
12545
+ return { downloading, download, downloadFile };
12546
+ }
12488
12547
  const [name$C, bem$B] = createNamespace("image-preview");
12489
12548
  const popupProps$1 = ["show", "transition", "overlayStyle", "closeOnPopstate", "teleport"];
12490
12549
  const imagePreviewProps = {
@@ -12521,8 +12580,13 @@ var stdin_default$T = defineComponent({
12521
12580
  slots
12522
12581
  }) {
12523
12582
  const swipeRef = ref();
12583
+ const {
12584
+ downloading,
12585
+ download,
12586
+ downloadFile
12587
+ } = useMediaDownload(props);
12524
12588
  const state = reactive({
12525
- active: 0,
12589
+ active: +props.startPosition,
12526
12590
  rootWidth: 0,
12527
12591
  rootHeight: 0,
12528
12592
  disableZoom: false
@@ -12560,71 +12624,38 @@ var stdin_default$T = defineComponent({
12560
12624
  }, [props.images[state.active].title]);
12561
12625
  }
12562
12626
  };
12563
- const onDownload = () => __async$4(this, null, function* () {
12627
+ const onDownload = () => {
12564
12628
  var _a, _b, _c;
12565
- const downloadParams = {
12629
+ return download({
12566
12630
  index: state.active,
12567
12631
  url: (_a = props.images[state.active]) == null ? void 0 : _a.url,
12568
- title: (_b = props.images[state.active]) == null ? void 0 : _b.title
12569
- };
12570
- if (props.downloadAction) {
12571
- const result = props.downloadAction(downloadParams);
12572
- if (result) {
12573
- return;
12574
- }
12575
- }
12576
- try {
12577
- let universalJsSdk = yield import("./index-096e2873.mjs");
12578
- if (universalJsSdk && universalJsSdk.getJSI && downloadParams.url) {
12579
- let fileJsi = (_c = universalJsSdk.getJSI()) == null ? void 0 : _c.file;
12580
- if (fileJsi && fileJsi.download) {
12581
- showLoadingToast({
12582
- message: "下载中...",
12583
- forbidClick: true,
12584
- duration: 0
12585
- });
12586
- fileJsi.download({
12587
- url: downloadParams.url
12588
- }).then(({
12589
- tempFilePath
12590
- }) => {
12591
- closeToast();
12592
- showSuccessToast("下载成功");
12593
- }).catch(() => {
12594
- closeToast();
12595
- showFailToast("下载失败");
12596
- });
12597
- return;
12598
- } else {
12599
- showFailToast("当前环境暂不支持下载");
12600
- }
12601
- }
12602
- } catch (e) {
12603
- console.log(e.message);
12604
- }
12605
- });
12632
+ title: (_b = props.images[state.active]) == null ? void 0 : _b.title,
12633
+ fileName: (_c = props.images[state.active]) == null ? void 0 : _c.fileName
12634
+ });
12635
+ };
12636
+ const renderDownloadIcon = () => createVNode("button", {
12637
+ "type": "button",
12638
+ "class": bem$B("download-icon"),
12639
+ "aria-label": "下载原图",
12640
+ "disabled": downloading.value,
12641
+ "onClick": onDownload
12642
+ }, [createVNode(Icon, {
12643
+ "name": "download",
12644
+ "size": "24"
12645
+ }, null)]);
12606
12646
  const renderIndex = () => {
12607
12647
  const image = props.images[state.active];
12608
- const showDownload = props.showDownload && !image.url.startsWith("data:");
12648
+ const showDownload = props.showDownload && (image == null ? void 0 : image.url) && !image.url.startsWith("data:");
12609
12649
  if (props.showIndex || showDownload) {
12610
- if (props.showIndex && slots.index) {
12611
- return createVNode("div", {
12612
- "class": bem$B("index")
12613
- }, [slots.index({
12614
- index: state.active
12615
- })]);
12616
- }
12617
12650
  return createVNode("div", {
12618
12651
  "class": bem$B("index")
12619
- }, [props.showIndex && renderIndexText(), props.showIndex && renderImageTitle(), showDownload && renderDownloadIcon()]);
12652
+ }, [props.showIndex && createVNode("div", {
12653
+ "class": bem$B("index-content")
12654
+ }, [slots.index ? slots.index({
12655
+ index: state.active
12656
+ }) : [renderIndexText(), renderImageTitle()]]), showDownload && renderDownloadIcon()]);
12620
12657
  }
12621
12658
  };
12622
- const renderDownloadIcon = () => {
12623
- return createVNode("div", {
12624
- "class": bem$B("download-icon"),
12625
- "onClick": onDownload
12626
- }, [Download(bem$B)]);
12627
- };
12628
12659
  const renderCover = () => {
12629
12660
  if (slots.cover) {
12630
12661
  return createVNode("div", {
@@ -12686,7 +12717,8 @@ var stdin_default$T = defineComponent({
12686
12717
  return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index2, options);
12687
12718
  };
12688
12719
  useExpose({
12689
- swipeTo
12720
+ swipeTo,
12721
+ downloadFile
12690
12722
  });
12691
12723
  onMounted(() => {
12692
12724
  resize();
@@ -12716,6 +12748,7 @@ var stdin_default$T = defineComponent({
12716
12748
  return () => createVNode(Popup, mergeProps({
12717
12749
  "class": [bem$B(), props.className],
12718
12750
  "overlayClass": [bem$B("overlay"), props.overlayClass],
12751
+ "onClick": (event) => event.stopPropagation(),
12719
12752
  "onClosed": onClosed,
12720
12753
  "onUpdate:show": updateShow
12721
12754
  }, pick(props, popupProps$1)), {
@@ -12736,6 +12769,8 @@ const defaultConfig = {
12736
12769
  className: "",
12737
12770
  showIndex: true,
12738
12771
  closeable: false,
12772
+ showDownload: false,
12773
+ downloadAction: void 0,
12739
12774
  closeIcon: "clear",
12740
12775
  transition: void 0,
12741
12776
  beforeClose: void 0,
@@ -12784,7 +12819,8 @@ const showImagePreview = (options, startPosition = 0) => {
12784
12819
  }
12785
12820
  return {
12786
12821
  url: opt.url,
12787
- title: opt.title || ""
12822
+ title: opt.title || "",
12823
+ fileName: opt.fileName
12788
12824
  };
12789
12825
  }),
12790
12826
  startPosition
@@ -13446,6 +13482,9 @@ const mediaPlayerProps = {
13446
13482
  show: Boolean,
13447
13483
  mediaType: makeStringProp("file"),
13448
13484
  mediaUrl: makeStringProp(""),
13485
+ fileName: makeStringProp(""),
13486
+ showDownload: Boolean,
13487
+ downloadAction: Function,
13449
13488
  /** 视频播放时的控件展示列表,参考:https://wicg.github.io/controls-list/explainer.html */
13450
13489
  controlsList: makeArrayProp([]),
13451
13490
  teleport: [String, Object]
@@ -13460,6 +13499,15 @@ var stdin_default$O = defineComponent({
13460
13499
  }) {
13461
13500
  const audioRef = ref();
13462
13501
  const videoRef = ref();
13502
+ const {
13503
+ downloading,
13504
+ download
13505
+ } = useMediaDownload(props);
13506
+ const onDownload = () => download({
13507
+ index: 0,
13508
+ url: props.mediaUrl,
13509
+ fileName: props.fileName
13510
+ });
13463
13511
  const getMediaElement = () => {
13464
13512
  let player;
13465
13513
  if (props.mediaType === "audio") {
@@ -13506,7 +13554,7 @@ var stdin_default$O = defineComponent({
13506
13554
  "src": props.mediaUrl,
13507
13555
  "ref": videoRef,
13508
13556
  "controls": true,
13509
- "controlslist": props.controlsList.join(" "),
13557
+ "controlslist": [.../* @__PURE__ */ new Set([...props.controlsList, "nodownload"])].join(" "),
13510
13558
  "autoplay": true,
13511
13559
  "id": "video",
13512
13560
  "webkit-playsinline": true,
@@ -13542,7 +13590,16 @@ var stdin_default$O = defineComponent({
13542
13590
  "type": "button",
13543
13591
  "class": bem$x("cancel-btn"),
13544
13592
  "onClick": onClose
13545
- }, [createTextVNode("关闭")])])]
13593
+ }, [createTextVNode("关闭")]), props.showDownload && props.mediaType === "video" && props.mediaUrl && !props.mediaUrl.startsWith("data:") && createVNode("button", {
13594
+ "type": "button",
13595
+ "class": bem$x("download-btn"),
13596
+ "aria-label": "下载视频",
13597
+ "disabled": downloading.value,
13598
+ "onClick": onDownload
13599
+ }, [createVNode(stdin_default$1$, {
13600
+ "name": "download",
13601
+ "size": "24"
13602
+ }, null)])])]
13546
13603
  });
13547
13604
  }
13548
13605
  });
@@ -16262,6 +16319,25 @@ _extends(Remove, {
16262
16319
  });
16263
16320
  Sortable.mount(new AutoScrollPlugin());
16264
16321
  Sortable.mount(Remove, Revert);
16322
+ var __defProp = Object.defineProperty;
16323
+ var __defProps = Object.defineProperties;
16324
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
16325
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
16326
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16327
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
16328
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16329
+ var __spreadValues = (a, b) => {
16330
+ for (var prop in b || (b = {}))
16331
+ if (__hasOwnProp.call(b, prop))
16332
+ __defNormalProp(a, prop, b[prop]);
16333
+ if (__getOwnPropSymbols)
16334
+ for (var prop of __getOwnPropSymbols(b)) {
16335
+ if (__propIsEnum.call(b, prop))
16336
+ __defNormalProp(a, prop, b[prop]);
16337
+ }
16338
+ return a;
16339
+ };
16340
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
16265
16341
  var __async$3 = (__this, __arguments, generator) => {
16266
16342
  return new Promise((resolve, reject) => {
16267
16343
  var fulfilled = (value) => {
@@ -16367,6 +16443,9 @@ var stdin_default$E = defineComponent({
16367
16443
  emit,
16368
16444
  slots
16369
16445
  }) {
16446
+ const {
16447
+ downloadFile
16448
+ } = useMediaDownload(props);
16370
16449
  const videoOptionsVisible = ref(false);
16371
16450
  const audioOptionsVisible = ref(false);
16372
16451
  const photoOptionsVisible = ref(false);
@@ -16374,6 +16453,8 @@ var stdin_default$E = defineComponent({
16374
16453
  const mediaPlayerVisible = ref(false);
16375
16454
  const mediaTypeToPlay = ref("file");
16376
16455
  const mediaUrlToPlay = ref("");
16456
+ const mediaFileNameToPlay = ref("");
16457
+ const mediaIndexToPlay = ref(0);
16377
16458
  const cameraInputRef = ref();
16378
16459
  const imageInputRef = ref();
16379
16460
  const camcorderInputRef = ref();
@@ -17059,7 +17140,6 @@ var stdin_default$E = defineComponent({
17059
17140
  deleteMedia(media, index2);
17060
17141
  });
17061
17142
  const previewMedia = (index2) => __async$3(this, null, function* () {
17062
- var _a;
17063
17143
  if (props.preview && (yield props.preview(props.mediaList, index2))) {
17064
17144
  return;
17065
17145
  }
@@ -17068,7 +17148,9 @@ var stdin_default$E = defineComponent({
17068
17148
  const imageIndex = imageList.value.indexOf(media);
17069
17149
  showImagePreview({
17070
17150
  images: imageList.value.map((image) => ({
17071
- url: image.url || image.showSrc || ""
17151
+ url: image.url || image.showSrc || "",
17152
+ title: image.label,
17153
+ fileName: image.originalName || image.fileName
17072
17154
  })),
17073
17155
  showDownload: props.showDownload,
17074
17156
  downloadAction: props.downloadAction,
@@ -17080,45 +17162,28 @@ var stdin_default$E = defineComponent({
17080
17162
  showFailToast("文件参数缺失");
17081
17163
  } else {
17082
17164
  mediaTypeToPlay.value = media.type;
17165
+ mediaFileNameToPlay.value = media.originalName || media.fileName;
17166
+ mediaIndexToPlay.value = index2;
17083
17167
  mediaUrlToPlay.value = media.url || (URL || webkitURL).createObjectURL(media.file);
17084
17168
  mediaPlayerVisible.value = true;
17085
17169
  }
17086
17170
  } else if (media.type === "file") {
17087
- try {
17088
- let universalJsSdk = yield import("./index-096e2873.mjs");
17089
- if (universalJsSdk && universalJsSdk.getJSI && media.url) {
17090
- let fileJsi = (_a = universalJsSdk.getJSI()) == null ? void 0 : _a.file;
17091
- if (fileJsi && fileJsi.download && fileJsi.openDocument) {
17092
- showLoadingToast({
17093
- message: "打开中...",
17094
- forbidClick: true,
17095
- duration: 0
17096
- });
17097
- fileJsi.download({
17098
- url: media.url
17099
- }).then(({
17100
- tempFilePath
17101
- }) => {
17102
- if (fileJsi && fileJsi.openDocument) {
17103
- fileJsi.openDocument({
17104
- localFilePath: tempFilePath
17105
- }).finally(() => {
17106
- closeToast();
17107
- });
17108
- } else {
17109
- closeToast();
17110
- }
17111
- }).catch(() => {
17112
- closeToast();
17113
- showFailToast("下载失败");
17114
- });
17115
- return;
17171
+ if (props.showDownload) {
17172
+ const url = media.url || (media.file ? URL.createObjectURL(media.file) : "");
17173
+ try {
17174
+ yield downloadFile({
17175
+ url,
17176
+ fileName: media.originalName || media.fileName,
17177
+ index: index2
17178
+ });
17179
+ } finally {
17180
+ if (!media.url && url) {
17181
+ URL.revokeObjectURL(url);
17116
17182
  }
17117
17183
  }
17118
- } catch (e) {
17119
- console.log(e.message);
17184
+ } else {
17185
+ showFailToast("暂不支持此类文件的预览");
17120
17186
  }
17121
- showFailToast("暂不支持此类文件的预览");
17122
17187
  }
17123
17188
  });
17124
17189
  const renderMediaListPlaceholder = () => {
@@ -17185,7 +17250,16 @@ var stdin_default$E = defineComponent({
17185
17250
  "mediaType": mediaTypeToPlay.value,
17186
17251
  "mediaUrl": mediaUrlToPlay.value,
17187
17252
  "teleport": "body"
17188
- }, props.mediaPlayerProps), null), createVNode(stdin_default$1U, {
17253
+ }, props.mediaPlayerProps, {
17254
+ "showDownload": props.showDownload,
17255
+ "fileName": mediaFileNameToPlay.value,
17256
+ "downloadAction": (params) => {
17257
+ var _a, _b, _c;
17258
+ return (_c = (_b = props.downloadAction || ((_a = props.mediaPlayerProps) == null ? void 0 : _a.downloadAction)) == null ? void 0 : _b(__spreadProps(__spreadValues({}, params), {
17259
+ index: mediaIndexToPlay.value
17260
+ }))) != null ? _c : false;
17261
+ }
17262
+ }), null), createVNode(stdin_default$1U, {
17189
17263
  "show": actionVisible.value,
17190
17264
  "onUpdate:show": ($event) => actionVisible.value = $event,
17191
17265
  "actions": actionOptions.value,
@@ -24422,7 +24496,7 @@ const Lazyload = {
24422
24496
  });
24423
24497
  }
24424
24498
  };
24425
- const version = "3.1.92";
24499
+ const version = "3.1.94";
24426
24500
  function install(app) {
24427
24501
  const components = [
24428
24502
  ActionSheet,