zartui 3.1.93 → 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 (53) 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/image-preview/ImagePreview.d.ts +2 -5
  4. package/es/image-preview/ImagePreview.mjs +32 -79
  5. package/es/image-preview/function-call.mjs +4 -1
  6. package/es/image-preview/index.css +1 -1
  7. package/es/image-preview/index.d.ts +1 -2
  8. package/es/image-preview/style/index.mjs +2 -0
  9. package/es/image-preview/types.d.ts +3 -1
  10. package/es/index.d.ts +1 -1
  11. package/es/index.mjs +1 -1
  12. package/es/media-picker/MediaPicker.d.ts +1 -1
  13. package/es/media-picker/MediaPicker.mjs +54 -36
  14. package/es/media-picker/index.d.ts +2 -2
  15. package/es/media-picker/style/index.mjs +3 -1
  16. package/es/media-player/MediaPlayer.d.ts +21 -0
  17. package/es/media-player/MediaPlayer.mjs +25 -2
  18. package/es/media-player/index.css +1 -1
  19. package/es/media-player/index.d.ts +14 -0
  20. package/es/media-player/style/index.mjs +4 -0
  21. package/es/photo-picker/index.d.ts +2 -2
  22. package/es/photo-picker/style/index.mjs +2 -0
  23. package/es/uploader/style/index.mjs +2 -0
  24. package/lib/composables/use-media-download.d.ts +20 -0
  25. package/lib/composables/use-media-download.js +138 -0
  26. package/lib/image-preview/ImagePreview.d.ts +2 -5
  27. package/lib/image-preview/ImagePreview.js +32 -79
  28. package/lib/image-preview/function-call.js +4 -1
  29. package/lib/image-preview/index.css +1 -1
  30. package/lib/image-preview/index.d.ts +1 -2
  31. package/lib/image-preview/style/index.js +2 -0
  32. package/lib/image-preview/types.d.ts +3 -1
  33. package/lib/index.css +1 -1
  34. package/lib/index.d.ts +1 -1
  35. package/lib/index.js +1 -1
  36. package/lib/media-picker/MediaPicker.d.ts +1 -1
  37. package/lib/media-picker/MediaPicker.js +51 -35
  38. package/lib/media-picker/index.d.ts +2 -2
  39. package/lib/media-picker/style/index.js +3 -1
  40. package/lib/media-player/MediaPlayer.d.ts +21 -0
  41. package/lib/media-player/MediaPlayer.js +25 -2
  42. package/lib/media-player/index.css +1 -1
  43. package/lib/media-player/index.d.ts +14 -0
  44. package/lib/media-player/style/index.js +4 -0
  45. package/lib/photo-picker/index.d.ts +2 -2
  46. package/lib/photo-picker/style/index.js +2 -0
  47. package/lib/uploader/style/index.js +2 -0
  48. package/lib/web-types.json +1 -1
  49. package/lib/zartui.cjs.js +196 -105
  50. package/lib/zartui.es.js +196 -105
  51. package/lib/zartui.js +204 -113
  52. package/lib/zartui.min.js +2 -2
  53. package/package.json +2 -2
package/lib/zartui.js CHANGED
@@ -12684,15 +12684,25 @@ var __publicField = (obj, key, value) => {
12684
12684
  };
12685
12685
  }
12686
12686
  });
12687
- const Download = (bem2) => vue.createVNode("svg", {
12688
- "class": bem2("svg-download-icon"),
12689
- "xmlns": "http://www.w3.org/2000/svg",
12690
- "viewBox": "0 0 20 20"
12691
- }, [vue.createVNode("path", {
12692
- "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",
12693
- "fill": "#FFF",
12694
- "fill-rule": "nonzero"
12695
- }, null)]);
12687
+ var __defProp$2 = Object.defineProperty;
12688
+ var __defProps$1 = Object.defineProperties;
12689
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
12690
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
12691
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
12692
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
12693
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12694
+ var __spreadValues$1 = (a2, b) => {
12695
+ for (var prop in b || (b = {}))
12696
+ if (__hasOwnProp$2.call(b, prop))
12697
+ __defNormalProp$1(a2, prop, b[prop]);
12698
+ if (__getOwnPropSymbols$1)
12699
+ for (var prop of __getOwnPropSymbols$1(b)) {
12700
+ if (__propIsEnum$1.call(b, prop))
12701
+ __defNormalProp$1(a2, prop, b[prop]);
12702
+ }
12703
+ return a2;
12704
+ };
12705
+ var __spreadProps$1 = (a2, b) => __defProps$1(a2, __getOwnPropDescs$1(b));
12696
12706
  var __async$5 = (__this, __arguments, generator) => {
12697
12707
  return new Promise((resolve, reject) => {
12698
12708
  var fulfilled = (value) => {
@@ -12713,6 +12723,72 @@ var __publicField = (obj, key, value) => {
12713
12723
  step((generator = generator.apply(__this, __arguments)).next());
12714
12724
  });
12715
12725
  };
12726
+ function useMediaDownload(props) {
12727
+ const downloading = vue.ref(false);
12728
+ const downloadInBrowser = (params) => {
12729
+ const link = document.createElement("a");
12730
+ link.href = params.url;
12731
+ link.download = params.fileName || "";
12732
+ document.body.appendChild(link);
12733
+ link.click();
12734
+ link.remove();
12735
+ };
12736
+ const download2 = (params, confirm = false) => __async$5(this, null, function* () {
12737
+ var _a, _b, _c;
12738
+ if (!props.showDownload || downloading.value || !params.url || params.url.startsWith("data:")) {
12739
+ return;
12740
+ }
12741
+ downloading.value = true;
12742
+ try {
12743
+ if (confirm) {
12744
+ try {
12745
+ yield showConfirmDialog({ message: "附件格式暂不支持预览,是否下载原文件" });
12746
+ } catch (action) {
12747
+ if (action !== "cancel") {
12748
+ throw action;
12749
+ }
12750
+ return;
12751
+ }
12752
+ }
12753
+ if (!props.showDownload || ((_a = props.downloadAction) == null ? void 0 : _a.call(props, params))) {
12754
+ return;
12755
+ }
12756
+ let file;
12757
+ try {
12758
+ const sdk = yield Promise.resolve().then(() => index);
12759
+ file = (_b = sdk.getJSI()) == null ? void 0 : _b.file;
12760
+ } catch (e) {
12761
+ downloadInBrowser(params);
12762
+ return;
12763
+ }
12764
+ if (!(file == null ? void 0 : file.download)) {
12765
+ downloadInBrowser(params);
12766
+ return;
12767
+ }
12768
+ showLoadingToast({ message: "下载中...", forbidClick: true, duration: 0 });
12769
+ try {
12770
+ const result = yield file.download({ url: params.url });
12771
+ const displayPath = (_c = result == null ? void 0 : result.tempFilePath) == null ? void 0 : _c.replace(/^\/storage\/emulated\/0\//, "");
12772
+ closeToast();
12773
+ showSuccessToast({
12774
+ message: displayPath ? `下载成功
12775
+ 保存路径:${displayPath}` : "下载成功",
12776
+ duration: 5e3
12777
+ });
12778
+ } catch (e) {
12779
+ closeToast();
12780
+ showFailToast("下载失败");
12781
+ }
12782
+ } finally {
12783
+ downloading.value = false;
12784
+ }
12785
+ });
12786
+ const downloadFile = (options) => {
12787
+ var _a;
12788
+ return download2(__spreadProps$1(__spreadValues$1({}, options), { index: (_a = options.index) != null ? _a : -1 }), true);
12789
+ };
12790
+ return { downloading, download: download2, downloadFile };
12791
+ }
12716
12792
  const [name$C, bem$B] = createNamespace("image-preview");
12717
12793
  const popupProps$1 = ["show", "transition", "overlayStyle", "closeOnPopstate", "teleport"];
12718
12794
  const imagePreviewProps = {
@@ -12749,8 +12825,13 @@ var __publicField = (obj, key, value) => {
12749
12825
  slots
12750
12826
  }) {
12751
12827
  const swipeRef = vue.ref();
12828
+ const {
12829
+ downloading,
12830
+ download: download2,
12831
+ downloadFile
12832
+ } = useMediaDownload(props);
12752
12833
  const state = vue.reactive({
12753
- active: 0,
12834
+ active: +props.startPosition,
12754
12835
  rootWidth: 0,
12755
12836
  rootHeight: 0,
12756
12837
  disableZoom: false
@@ -12788,71 +12869,38 @@ var __publicField = (obj, key, value) => {
12788
12869
  }, [props.images[state.active].title]);
12789
12870
  }
12790
12871
  };
12791
- const onDownload = () => __async$5(this, null, function* () {
12872
+ const onDownload = () => {
12792
12873
  var _a, _b, _c;
12793
- const downloadParams = {
12874
+ return download2({
12794
12875
  index: state.active,
12795
12876
  url: (_a = props.images[state.active]) == null ? void 0 : _a.url,
12796
- title: (_b = props.images[state.active]) == null ? void 0 : _b.title
12797
- };
12798
- if (props.downloadAction) {
12799
- const result = props.downloadAction(downloadParams);
12800
- if (result) {
12801
- return;
12802
- }
12803
- }
12804
- try {
12805
- let universalJsSdk = yield Promise.resolve().then(() => index);
12806
- if (universalJsSdk && universalJsSdk.getJSI && downloadParams.url) {
12807
- let fileJsi = (_c = universalJsSdk.getJSI()) == null ? void 0 : _c.file;
12808
- if (fileJsi && fileJsi.download) {
12809
- showLoadingToast({
12810
- message: "下载中...",
12811
- forbidClick: true,
12812
- duration: 0
12813
- });
12814
- fileJsi.download({
12815
- url: downloadParams.url
12816
- }).then(({
12817
- tempFilePath
12818
- }) => {
12819
- closeToast();
12820
- showSuccessToast("下载成功");
12821
- }).catch(() => {
12822
- closeToast();
12823
- showFailToast("下载失败");
12824
- });
12825
- return;
12826
- } else {
12827
- showFailToast("当前环境暂不支持下载");
12828
- }
12829
- }
12830
- } catch (e) {
12831
- console.log(e.message);
12832
- }
12833
- });
12877
+ title: (_b = props.images[state.active]) == null ? void 0 : _b.title,
12878
+ fileName: (_c = props.images[state.active]) == null ? void 0 : _c.fileName
12879
+ });
12880
+ };
12881
+ const renderDownloadIcon = () => vue.createVNode("button", {
12882
+ "type": "button",
12883
+ "class": bem$B("download-icon"),
12884
+ "aria-label": "下载原图",
12885
+ "disabled": downloading.value,
12886
+ "onClick": onDownload
12887
+ }, [vue.createVNode(Icon, {
12888
+ "name": "download",
12889
+ "size": "24"
12890
+ }, null)]);
12834
12891
  const renderIndex = () => {
12835
12892
  const image2 = props.images[state.active];
12836
- const showDownload = props.showDownload && !image2.url.startsWith("data:");
12893
+ const showDownload = props.showDownload && (image2 == null ? void 0 : image2.url) && !image2.url.startsWith("data:");
12837
12894
  if (props.showIndex || showDownload) {
12838
- if (props.showIndex && slots.index) {
12839
- return vue.createVNode("div", {
12840
- "class": bem$B("index")
12841
- }, [slots.index({
12842
- index: state.active
12843
- })]);
12844
- }
12845
12895
  return vue.createVNode("div", {
12846
12896
  "class": bem$B("index")
12847
- }, [props.showIndex && renderIndexText(), props.showIndex && renderImageTitle(), showDownload && renderDownloadIcon()]);
12897
+ }, [props.showIndex && vue.createVNode("div", {
12898
+ "class": bem$B("index-content")
12899
+ }, [slots.index ? slots.index({
12900
+ index: state.active
12901
+ }) : [renderIndexText(), renderImageTitle()]]), showDownload && renderDownloadIcon()]);
12848
12902
  }
12849
12903
  };
12850
- const renderDownloadIcon = () => {
12851
- return vue.createVNode("div", {
12852
- "class": bem$B("download-icon"),
12853
- "onClick": onDownload
12854
- }, [Download(bem$B)]);
12855
- };
12856
12904
  const renderCover = () => {
12857
12905
  if (slots.cover) {
12858
12906
  return vue.createVNode("div", {
@@ -12914,7 +12962,8 @@ var __publicField = (obj, key, value) => {
12914
12962
  return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index2, options);
12915
12963
  };
12916
12964
  useExpose({
12917
- swipeTo
12965
+ swipeTo,
12966
+ downloadFile
12918
12967
  });
12919
12968
  vue.onMounted(() => {
12920
12969
  resize2();
@@ -12944,6 +12993,7 @@ var __publicField = (obj, key, value) => {
12944
12993
  return () => vue.createVNode(Popup, vue.mergeProps({
12945
12994
  "class": [bem$B(), props.className],
12946
12995
  "overlayClass": [bem$B("overlay"), props.overlayClass],
12996
+ "onClick": (event) => event.stopPropagation(),
12947
12997
  "onClosed": onClosed,
12948
12998
  "onUpdate:show": updateShow
12949
12999
  }, pick(props, popupProps$1)), {
@@ -12964,6 +13014,8 @@ var __publicField = (obj, key, value) => {
12964
13014
  className: "",
12965
13015
  showIndex: true,
12966
13016
  closeable: false,
13017
+ showDownload: false,
13018
+ downloadAction: void 0,
12967
13019
  closeIcon: "clear",
12968
13020
  transition: void 0,
12969
13021
  beforeClose: void 0,
@@ -13012,7 +13064,8 @@ var __publicField = (obj, key, value) => {
13012
13064
  }
13013
13065
  return {
13014
13066
  url: opt.url,
13015
- title: opt.title || ""
13067
+ title: opt.title || "",
13068
+ fileName: opt.fileName
13016
13069
  };
13017
13070
  }),
13018
13071
  startPosition
@@ -17033,6 +17086,9 @@ var __publicField = (obj, key, value) => {
17033
17086
  show: Boolean,
17034
17087
  mediaType: makeStringProp("file"),
17035
17088
  mediaUrl: makeStringProp(""),
17089
+ fileName: makeStringProp(""),
17090
+ showDownload: Boolean,
17091
+ downloadAction: Function,
17036
17092
  /** 视频播放时的控件展示列表,参考:https://wicg.github.io/controls-list/explainer.html */
17037
17093
  controlsList: makeArrayProp([]),
17038
17094
  teleport: [String, Object]
@@ -17047,6 +17103,15 @@ var __publicField = (obj, key, value) => {
17047
17103
  }) {
17048
17104
  const audioRef = vue.ref();
17049
17105
  const videoRef = vue.ref();
17106
+ const {
17107
+ downloading,
17108
+ download: download2
17109
+ } = useMediaDownload(props);
17110
+ const onDownload = () => download2({
17111
+ index: 0,
17112
+ url: props.mediaUrl,
17113
+ fileName: props.fileName
17114
+ });
17050
17115
  const getMediaElement = () => {
17051
17116
  let player;
17052
17117
  if (props.mediaType === "audio") {
@@ -17093,7 +17158,7 @@ var __publicField = (obj, key, value) => {
17093
17158
  "src": props.mediaUrl,
17094
17159
  "ref": videoRef,
17095
17160
  "controls": true,
17096
- "controlslist": props.controlsList.join(" "),
17161
+ "controlslist": [.../* @__PURE__ */ new Set([...props.controlsList, "nodownload"])].join(" "),
17097
17162
  "autoplay": true,
17098
17163
  "id": "video",
17099
17164
  "webkit-playsinline": true,
@@ -17129,7 +17194,16 @@ var __publicField = (obj, key, value) => {
17129
17194
  "type": "button",
17130
17195
  "class": bem$x("cancel-btn"),
17131
17196
  "onClick": onClose
17132
- }, [vue.createTextVNode("关闭")])])]
17197
+ }, [vue.createTextVNode("关闭")]), props.showDownload && props.mediaType === "video" && props.mediaUrl && !props.mediaUrl.startsWith("data:") && vue.createVNode("button", {
17198
+ "type": "button",
17199
+ "class": bem$x("download-btn"),
17200
+ "aria-label": "下载视频",
17201
+ "disabled": downloading.value,
17202
+ "onClick": onDownload
17203
+ }, [vue.createVNode(stdin_default$1$, {
17204
+ "name": "download",
17205
+ "size": "24"
17206
+ }, null)])])]
17133
17207
  });
17134
17208
  }
17135
17209
  });
@@ -17587,19 +17661,19 @@ var __publicField = (obj, key, value) => {
17587
17661
  });
17588
17662
  }
17589
17663
  var __create = Object.create;
17590
- var __defProp2 = Object.defineProperty;
17664
+ var __defProp$1 = Object.defineProperty;
17591
17665
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
17592
17666
  var __getOwnPropNames = Object.getOwnPropertyNames;
17593
17667
  var __getProtoOf = Object.getPrototypeOf;
17594
- var __hasOwnProp = Object.prototype.hasOwnProperty;
17668
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
17595
17669
  var __commonJS = (cb, mod) => function __require() {
17596
17670
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17597
17671
  };
17598
17672
  var __copyProps = (to, from, except, desc) => {
17599
17673
  if (from && typeof from === "object" || typeof from === "function") {
17600
17674
  for (let key of __getOwnPropNames(from))
17601
- if (!__hasOwnProp.call(to, key) && key !== except)
17602
- __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17675
+ if (!__hasOwnProp$1.call(to, key) && key !== except)
17676
+ __defProp$1(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17603
17677
  }
17604
17678
  return to;
17605
17679
  };
@@ -17608,7 +17682,7 @@ var __publicField = (obj, key, value) => {
17608
17682
  // file that has been converted to a CommonJS file using a Babel-
17609
17683
  // compatible transform (i.e. "__esModule" has not been set), then set
17610
17684
  // "default" to the CommonJS "module.exports" for node compatibility.
17611
- isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
17685
+ isNodeMode || !mod || !mod.__esModule ? __defProp$1(target, "default", { value: mod, enumerable: true }) : target,
17612
17686
  mod
17613
17687
  ));
17614
17688
  var __async$4 = (__this, __arguments, generator) => {
@@ -21476,6 +21550,25 @@ var __publicField = (obj, key, value) => {
21476
21550
  });
21477
21551
  Sortable.mount(new AutoScrollPlugin());
21478
21552
  Sortable.mount(Remove, Revert);
21553
+ var __defProp2 = Object.defineProperty;
21554
+ var __defProps = Object.defineProperties;
21555
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
21556
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
21557
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
21558
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
21559
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
21560
+ var __spreadValues = (a2, b) => {
21561
+ for (var prop in b || (b = {}))
21562
+ if (__hasOwnProp.call(b, prop))
21563
+ __defNormalProp2(a2, prop, b[prop]);
21564
+ if (__getOwnPropSymbols)
21565
+ for (var prop of __getOwnPropSymbols(b)) {
21566
+ if (__propIsEnum.call(b, prop))
21567
+ __defNormalProp2(a2, prop, b[prop]);
21568
+ }
21569
+ return a2;
21570
+ };
21571
+ var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
21479
21572
  var __async$3 = (__this, __arguments, generator) => {
21480
21573
  return new Promise((resolve, reject) => {
21481
21574
  var fulfilled = (value) => {
@@ -21581,6 +21674,9 @@ var __publicField = (obj, key, value) => {
21581
21674
  emit,
21582
21675
  slots
21583
21676
  }) {
21677
+ const {
21678
+ downloadFile
21679
+ } = useMediaDownload(props);
21584
21680
  const videoOptionsVisible = vue.ref(false);
21585
21681
  const audioOptionsVisible = vue.ref(false);
21586
21682
  const photoOptionsVisible = vue.ref(false);
@@ -21588,6 +21684,8 @@ var __publicField = (obj, key, value) => {
21588
21684
  const mediaPlayerVisible = vue.ref(false);
21589
21685
  const mediaTypeToPlay = vue.ref("file");
21590
21686
  const mediaUrlToPlay = vue.ref("");
21687
+ const mediaFileNameToPlay = vue.ref("");
21688
+ const mediaIndexToPlay = vue.ref(0);
21591
21689
  const cameraInputRef = vue.ref();
21592
21690
  const imageInputRef = vue.ref();
21593
21691
  const camcorderInputRef = vue.ref();
@@ -22272,17 +22370,18 @@ var __publicField = (obj, key, value) => {
22272
22370
  }
22273
22371
  deleteMedia(media, index2);
22274
22372
  });
22275
- const previewMedia = (index$12) => __async$3(this, null, function* () {
22276
- var _a;
22277
- if (props.preview && (yield props.preview(props.mediaList, index$12))) {
22373
+ const previewMedia = (index2) => __async$3(this, null, function* () {
22374
+ if (props.preview && (yield props.preview(props.mediaList, index2))) {
22278
22375
  return;
22279
22376
  }
22280
- const media = props.mediaList[index$12];
22377
+ const media = props.mediaList[index2];
22281
22378
  if (media.type === "photo") {
22282
22379
  const imageIndex = imageList.value.indexOf(media);
22283
22380
  showImagePreview({
22284
22381
  images: imageList.value.map((image2) => ({
22285
- url: image2.url || image2.showSrc || ""
22382
+ url: image2.url || image2.showSrc || "",
22383
+ title: image2.label,
22384
+ fileName: image2.originalName || image2.fileName
22286
22385
  })),
22287
22386
  showDownload: props.showDownload,
22288
22387
  downloadAction: props.downloadAction,
@@ -22294,45 +22393,28 @@ var __publicField = (obj, key, value) => {
22294
22393
  showFailToast("文件参数缺失");
22295
22394
  } else {
22296
22395
  mediaTypeToPlay.value = media.type;
22396
+ mediaFileNameToPlay.value = media.originalName || media.fileName;
22397
+ mediaIndexToPlay.value = index2;
22297
22398
  mediaUrlToPlay.value = media.url || (URL || webkitURL).createObjectURL(media.file);
22298
22399
  mediaPlayerVisible.value = true;
22299
22400
  }
22300
22401
  } else if (media.type === "file") {
22301
- try {
22302
- let universalJsSdk = yield Promise.resolve().then(() => index);
22303
- if (universalJsSdk && universalJsSdk.getJSI && media.url) {
22304
- let fileJsi = (_a = universalJsSdk.getJSI()) == null ? void 0 : _a.file;
22305
- if (fileJsi && fileJsi.download && fileJsi.openDocument) {
22306
- showLoadingToast({
22307
- message: "打开中...",
22308
- forbidClick: true,
22309
- duration: 0
22310
- });
22311
- fileJsi.download({
22312
- url: media.url
22313
- }).then(({
22314
- tempFilePath
22315
- }) => {
22316
- if (fileJsi && fileJsi.openDocument) {
22317
- fileJsi.openDocument({
22318
- localFilePath: tempFilePath
22319
- }).finally(() => {
22320
- closeToast();
22321
- });
22322
- } else {
22323
- closeToast();
22324
- }
22325
- }).catch(() => {
22326
- closeToast();
22327
- showFailToast("下载失败");
22328
- });
22329
- return;
22402
+ if (props.showDownload) {
22403
+ const url = media.url || (media.file ? URL.createObjectURL(media.file) : "");
22404
+ try {
22405
+ yield downloadFile({
22406
+ url,
22407
+ fileName: media.originalName || media.fileName,
22408
+ index: index2
22409
+ });
22410
+ } finally {
22411
+ if (!media.url && url) {
22412
+ URL.revokeObjectURL(url);
22330
22413
  }
22331
22414
  }
22332
- } catch (e) {
22333
- console.log(e.message);
22415
+ } else {
22416
+ showFailToast("暂不支持此类文件的预览");
22334
22417
  }
22335
- showFailToast("暂不支持此类文件的预览");
22336
22418
  }
22337
22419
  });
22338
22420
  const renderMediaListPlaceholder = () => {
@@ -22399,7 +22481,16 @@ var __publicField = (obj, key, value) => {
22399
22481
  "mediaType": mediaTypeToPlay.value,
22400
22482
  "mediaUrl": mediaUrlToPlay.value,
22401
22483
  "teleport": "body"
22402
- }, props.mediaPlayerProps), null), vue.createVNode(stdin_default$1U, {
22484
+ }, props.mediaPlayerProps, {
22485
+ "showDownload": props.showDownload,
22486
+ "fileName": mediaFileNameToPlay.value,
22487
+ "downloadAction": (params) => {
22488
+ var _a, _b, _c;
22489
+ return (_c = (_b = props.downloadAction || ((_a = props.mediaPlayerProps) == null ? void 0 : _a.downloadAction)) == null ? void 0 : _b(__spreadProps(__spreadValues({}, params), {
22490
+ index: mediaIndexToPlay.value
22491
+ }))) != null ? _c : false;
22492
+ }
22493
+ }), null), vue.createVNode(stdin_default$1U, {
22403
22494
  "show": actionVisible.value,
22404
22495
  "onUpdate:show": ($event) => actionVisible.value = $event,
22405
22496
  "actions": actionOptions.value,
@@ -31920,7 +32011,7 @@ var __publicField = (obj, key, value) => {
31920
32011
  });
31921
32012
  }
31922
32013
  };
31923
- const version = "3.1.93";
32014
+ const version = "3.1.94";
31924
32015
  function install(app) {
31925
32016
  const components = [
31926
32017
  ActionSheet,