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.js CHANGED
@@ -9332,7 +9332,6 @@ var __publicField = (obj, key, value) => {
9332
9332
  const commonTypesListRef = vue.ref();
9333
9333
  const showLeftCommonTypesMask = vue.ref(false);
9334
9334
  const showRightCommonTypesMask = vue.ref(false);
9335
- let commonTypesResizeObserver;
9336
9335
  const defaultTreeNode = vue.ref(props.treeData);
9337
9336
  const fields = vue.computed(() => assignDefaultFields$1(props.treeFieldName));
9338
9337
  const visibleCommonTypeList = vue.computed(() => {
@@ -9347,35 +9346,25 @@ var __publicField = (obj, key, value) => {
9347
9346
  children,
9348
9347
  text: key
9349
9348
  } = fields.value;
9349
+ const syncSelectCommonId = (node) => {
9350
+ const selectedId = node == null ? void 0 : node[value];
9351
+ selectCommonId.value = typeof selectedId === "string" || typeof selectedId === "number" ? selectedId : -1;
9352
+ };
9353
+ syncSelectCommonId(props.defaultSelectNode);
9354
+ vue.watch(() => props.defaultSelectNode, (node) => {
9355
+ selectNode.value = node;
9356
+ syncSelectCommonId(node);
9357
+ });
9350
9358
  const updateCommonTypesMask = () => {
9351
9359
  const list = commonTypesListRef.value;
9352
- if (!list) {
9353
- showLeftCommonTypesMask.value = false;
9354
- showRightCommonTypesMask.value = false;
9360
+ if (!list)
9355
9361
  return;
9356
- }
9357
- const remainingScrollWidth = list.scrollWidth - list.clientWidth - list.scrollLeft;
9358
9362
  showLeftCommonTypesMask.value = list.scrollLeft > 0;
9359
- showRightCommonTypesMask.value = remainingScrollWidth > 1;
9363
+ showRightCommonTypesMask.value = list.scrollLeft + list.clientWidth < list.scrollWidth;
9360
9364
  };
9361
9365
  const onCommonTypesScroll = () => {
9362
9366
  updateCommonTypesMask();
9363
9367
  };
9364
- const observeCommonTypesList = () => {
9365
- commonTypesResizeObserver == null ? void 0 : commonTypesResizeObserver.disconnect();
9366
- const list = commonTypesListRef.value;
9367
- if (!list || typeof ResizeObserver === "undefined") {
9368
- return;
9369
- }
9370
- commonTypesResizeObserver = new ResizeObserver(updateCommonTypesMask);
9371
- commonTypesResizeObserver.observe(list);
9372
- };
9373
- const updateCommonTypesLayout = () => {
9374
- vue.nextTick(() => {
9375
- observeCommonTypesList();
9376
- updateCommonTypesMask();
9377
- });
9378
- };
9379
9368
  const allData = {
9380
9369
  [value]: -1,
9381
9370
  [key]: "全部",
@@ -9452,13 +9441,7 @@ var __publicField = (obj, key, value) => {
9452
9441
  };
9453
9442
  flatData(props.treeData);
9454
9443
  updateOffset();
9455
- updateCommonTypesLayout();
9456
- });
9457
- vue.watch(visibleCommonTypeList, updateCommonTypesLayout, {
9458
- flush: "post"
9459
- });
9460
- vue.onBeforeUnmount(() => {
9461
- commonTypesResizeObserver == null ? void 0 : commonTypesResizeObserver.disconnect();
9444
+ vue.nextTick(updateCommonTypesMask);
9462
9445
  });
9463
9446
  const isEmpty = (item) => !item[children] || item[children].length === 0;
9464
9447
  const syncExpandNodeByParent = (item) => {
@@ -12701,15 +12684,25 @@ var __publicField = (obj, key, value) => {
12701
12684
  };
12702
12685
  }
12703
12686
  });
12704
- const Download = (bem2) => vue.createVNode("svg", {
12705
- "class": bem2("svg-download-icon"),
12706
- "xmlns": "http://www.w3.org/2000/svg",
12707
- "viewBox": "0 0 20 20"
12708
- }, [vue.createVNode("path", {
12709
- "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",
12710
- "fill": "#FFF",
12711
- "fill-rule": "nonzero"
12712
- }, 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));
12713
12706
  var __async$5 = (__this, __arguments, generator) => {
12714
12707
  return new Promise((resolve, reject) => {
12715
12708
  var fulfilled = (value) => {
@@ -12730,6 +12723,72 @@ var __publicField = (obj, key, value) => {
12730
12723
  step((generator = generator.apply(__this, __arguments)).next());
12731
12724
  });
12732
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
+ }
12733
12792
  const [name$C, bem$B] = createNamespace("image-preview");
12734
12793
  const popupProps$1 = ["show", "transition", "overlayStyle", "closeOnPopstate", "teleport"];
12735
12794
  const imagePreviewProps = {
@@ -12766,8 +12825,13 @@ var __publicField = (obj, key, value) => {
12766
12825
  slots
12767
12826
  }) {
12768
12827
  const swipeRef = vue.ref();
12828
+ const {
12829
+ downloading,
12830
+ download: download2,
12831
+ downloadFile
12832
+ } = useMediaDownload(props);
12769
12833
  const state = vue.reactive({
12770
- active: 0,
12834
+ active: +props.startPosition,
12771
12835
  rootWidth: 0,
12772
12836
  rootHeight: 0,
12773
12837
  disableZoom: false
@@ -12805,71 +12869,38 @@ var __publicField = (obj, key, value) => {
12805
12869
  }, [props.images[state.active].title]);
12806
12870
  }
12807
12871
  };
12808
- const onDownload = () => __async$5(this, null, function* () {
12872
+ const onDownload = () => {
12809
12873
  var _a, _b, _c;
12810
- const downloadParams = {
12874
+ return download2({
12811
12875
  index: state.active,
12812
12876
  url: (_a = props.images[state.active]) == null ? void 0 : _a.url,
12813
- title: (_b = props.images[state.active]) == null ? void 0 : _b.title
12814
- };
12815
- if (props.downloadAction) {
12816
- const result = props.downloadAction(downloadParams);
12817
- if (result) {
12818
- return;
12819
- }
12820
- }
12821
- try {
12822
- let universalJsSdk = yield Promise.resolve().then(() => index);
12823
- if (universalJsSdk && universalJsSdk.getJSI && downloadParams.url) {
12824
- let fileJsi = (_c = universalJsSdk.getJSI()) == null ? void 0 : _c.file;
12825
- if (fileJsi && fileJsi.download) {
12826
- showLoadingToast({
12827
- message: "下载中...",
12828
- forbidClick: true,
12829
- duration: 0
12830
- });
12831
- fileJsi.download({
12832
- url: downloadParams.url
12833
- }).then(({
12834
- tempFilePath
12835
- }) => {
12836
- closeToast();
12837
- showSuccessToast("下载成功");
12838
- }).catch(() => {
12839
- closeToast();
12840
- showFailToast("下载失败");
12841
- });
12842
- return;
12843
- } else {
12844
- showFailToast("当前环境暂不支持下载");
12845
- }
12846
- }
12847
- } catch (e) {
12848
- console.log(e.message);
12849
- }
12850
- });
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)]);
12851
12891
  const renderIndex = () => {
12852
12892
  const image2 = props.images[state.active];
12853
- const showDownload = props.showDownload && !image2.url.startsWith("data:");
12893
+ const showDownload = props.showDownload && (image2 == null ? void 0 : image2.url) && !image2.url.startsWith("data:");
12854
12894
  if (props.showIndex || showDownload) {
12855
- if (props.showIndex && slots.index) {
12856
- return vue.createVNode("div", {
12857
- "class": bem$B("index")
12858
- }, [slots.index({
12859
- index: state.active
12860
- })]);
12861
- }
12862
12895
  return vue.createVNode("div", {
12863
12896
  "class": bem$B("index")
12864
- }, [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()]);
12865
12902
  }
12866
12903
  };
12867
- const renderDownloadIcon = () => {
12868
- return vue.createVNode("div", {
12869
- "class": bem$B("download-icon"),
12870
- "onClick": onDownload
12871
- }, [Download(bem$B)]);
12872
- };
12873
12904
  const renderCover = () => {
12874
12905
  if (slots.cover) {
12875
12906
  return vue.createVNode("div", {
@@ -12931,7 +12962,8 @@ var __publicField = (obj, key, value) => {
12931
12962
  return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index2, options);
12932
12963
  };
12933
12964
  useExpose({
12934
- swipeTo
12965
+ swipeTo,
12966
+ downloadFile
12935
12967
  });
12936
12968
  vue.onMounted(() => {
12937
12969
  resize2();
@@ -12961,6 +12993,7 @@ var __publicField = (obj, key, value) => {
12961
12993
  return () => vue.createVNode(Popup, vue.mergeProps({
12962
12994
  "class": [bem$B(), props.className],
12963
12995
  "overlayClass": [bem$B("overlay"), props.overlayClass],
12996
+ "onClick": (event) => event.stopPropagation(),
12964
12997
  "onClosed": onClosed,
12965
12998
  "onUpdate:show": updateShow
12966
12999
  }, pick(props, popupProps$1)), {
@@ -12981,6 +13014,8 @@ var __publicField = (obj, key, value) => {
12981
13014
  className: "",
12982
13015
  showIndex: true,
12983
13016
  closeable: false,
13017
+ showDownload: false,
13018
+ downloadAction: void 0,
12984
13019
  closeIcon: "clear",
12985
13020
  transition: void 0,
12986
13021
  beforeClose: void 0,
@@ -13029,7 +13064,8 @@ var __publicField = (obj, key, value) => {
13029
13064
  }
13030
13065
  return {
13031
13066
  url: opt.url,
13032
- title: opt.title || ""
13067
+ title: opt.title || "",
13068
+ fileName: opt.fileName
13033
13069
  };
13034
13070
  }),
13035
13071
  startPosition
@@ -17050,6 +17086,9 @@ var __publicField = (obj, key, value) => {
17050
17086
  show: Boolean,
17051
17087
  mediaType: makeStringProp("file"),
17052
17088
  mediaUrl: makeStringProp(""),
17089
+ fileName: makeStringProp(""),
17090
+ showDownload: Boolean,
17091
+ downloadAction: Function,
17053
17092
  /** 视频播放时的控件展示列表,参考:https://wicg.github.io/controls-list/explainer.html */
17054
17093
  controlsList: makeArrayProp([]),
17055
17094
  teleport: [String, Object]
@@ -17064,6 +17103,15 @@ var __publicField = (obj, key, value) => {
17064
17103
  }) {
17065
17104
  const audioRef = vue.ref();
17066
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
+ });
17067
17115
  const getMediaElement = () => {
17068
17116
  let player;
17069
17117
  if (props.mediaType === "audio") {
@@ -17110,7 +17158,7 @@ var __publicField = (obj, key, value) => {
17110
17158
  "src": props.mediaUrl,
17111
17159
  "ref": videoRef,
17112
17160
  "controls": true,
17113
- "controlslist": props.controlsList.join(" "),
17161
+ "controlslist": [.../* @__PURE__ */ new Set([...props.controlsList, "nodownload"])].join(" "),
17114
17162
  "autoplay": true,
17115
17163
  "id": "video",
17116
17164
  "webkit-playsinline": true,
@@ -17146,7 +17194,16 @@ var __publicField = (obj, key, value) => {
17146
17194
  "type": "button",
17147
17195
  "class": bem$x("cancel-btn"),
17148
17196
  "onClick": onClose
17149
- }, [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)])])]
17150
17207
  });
17151
17208
  }
17152
17209
  });
@@ -17604,19 +17661,19 @@ var __publicField = (obj, key, value) => {
17604
17661
  });
17605
17662
  }
17606
17663
  var __create = Object.create;
17607
- var __defProp2 = Object.defineProperty;
17664
+ var __defProp$1 = Object.defineProperty;
17608
17665
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
17609
17666
  var __getOwnPropNames = Object.getOwnPropertyNames;
17610
17667
  var __getProtoOf = Object.getPrototypeOf;
17611
- var __hasOwnProp = Object.prototype.hasOwnProperty;
17668
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
17612
17669
  var __commonJS = (cb, mod) => function __require() {
17613
17670
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17614
17671
  };
17615
17672
  var __copyProps = (to, from, except, desc) => {
17616
17673
  if (from && typeof from === "object" || typeof from === "function") {
17617
17674
  for (let key of __getOwnPropNames(from))
17618
- if (!__hasOwnProp.call(to, key) && key !== except)
17619
- __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 });
17620
17677
  }
17621
17678
  return to;
17622
17679
  };
@@ -17625,7 +17682,7 @@ var __publicField = (obj, key, value) => {
17625
17682
  // file that has been converted to a CommonJS file using a Babel-
17626
17683
  // compatible transform (i.e. "__esModule" has not been set), then set
17627
17684
  // "default" to the CommonJS "module.exports" for node compatibility.
17628
- 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,
17629
17686
  mod
17630
17687
  ));
17631
17688
  var __async$4 = (__this, __arguments, generator) => {
@@ -21493,6 +21550,25 @@ var __publicField = (obj, key, value) => {
21493
21550
  });
21494
21551
  Sortable.mount(new AutoScrollPlugin());
21495
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));
21496
21572
  var __async$3 = (__this, __arguments, generator) => {
21497
21573
  return new Promise((resolve, reject) => {
21498
21574
  var fulfilled = (value) => {
@@ -21598,6 +21674,9 @@ var __publicField = (obj, key, value) => {
21598
21674
  emit,
21599
21675
  slots
21600
21676
  }) {
21677
+ const {
21678
+ downloadFile
21679
+ } = useMediaDownload(props);
21601
21680
  const videoOptionsVisible = vue.ref(false);
21602
21681
  const audioOptionsVisible = vue.ref(false);
21603
21682
  const photoOptionsVisible = vue.ref(false);
@@ -21605,6 +21684,8 @@ var __publicField = (obj, key, value) => {
21605
21684
  const mediaPlayerVisible = vue.ref(false);
21606
21685
  const mediaTypeToPlay = vue.ref("file");
21607
21686
  const mediaUrlToPlay = vue.ref("");
21687
+ const mediaFileNameToPlay = vue.ref("");
21688
+ const mediaIndexToPlay = vue.ref(0);
21608
21689
  const cameraInputRef = vue.ref();
21609
21690
  const imageInputRef = vue.ref();
21610
21691
  const camcorderInputRef = vue.ref();
@@ -22289,17 +22370,18 @@ var __publicField = (obj, key, value) => {
22289
22370
  }
22290
22371
  deleteMedia(media, index2);
22291
22372
  });
22292
- const previewMedia = (index$12) => __async$3(this, null, function* () {
22293
- var _a;
22294
- 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))) {
22295
22375
  return;
22296
22376
  }
22297
- const media = props.mediaList[index$12];
22377
+ const media = props.mediaList[index2];
22298
22378
  if (media.type === "photo") {
22299
22379
  const imageIndex = imageList.value.indexOf(media);
22300
22380
  showImagePreview({
22301
22381
  images: imageList.value.map((image2) => ({
22302
- url: image2.url || image2.showSrc || ""
22382
+ url: image2.url || image2.showSrc || "",
22383
+ title: image2.label,
22384
+ fileName: image2.originalName || image2.fileName
22303
22385
  })),
22304
22386
  showDownload: props.showDownload,
22305
22387
  downloadAction: props.downloadAction,
@@ -22311,45 +22393,28 @@ var __publicField = (obj, key, value) => {
22311
22393
  showFailToast("文件参数缺失");
22312
22394
  } else {
22313
22395
  mediaTypeToPlay.value = media.type;
22396
+ mediaFileNameToPlay.value = media.originalName || media.fileName;
22397
+ mediaIndexToPlay.value = index2;
22314
22398
  mediaUrlToPlay.value = media.url || (URL || webkitURL).createObjectURL(media.file);
22315
22399
  mediaPlayerVisible.value = true;
22316
22400
  }
22317
22401
  } else if (media.type === "file") {
22318
- try {
22319
- let universalJsSdk = yield Promise.resolve().then(() => index);
22320
- if (universalJsSdk && universalJsSdk.getJSI && media.url) {
22321
- let fileJsi = (_a = universalJsSdk.getJSI()) == null ? void 0 : _a.file;
22322
- if (fileJsi && fileJsi.download && fileJsi.openDocument) {
22323
- showLoadingToast({
22324
- message: "打开中...",
22325
- forbidClick: true,
22326
- duration: 0
22327
- });
22328
- fileJsi.download({
22329
- url: media.url
22330
- }).then(({
22331
- tempFilePath
22332
- }) => {
22333
- if (fileJsi && fileJsi.openDocument) {
22334
- fileJsi.openDocument({
22335
- localFilePath: tempFilePath
22336
- }).finally(() => {
22337
- closeToast();
22338
- });
22339
- } else {
22340
- closeToast();
22341
- }
22342
- }).catch(() => {
22343
- closeToast();
22344
- showFailToast("下载失败");
22345
- });
22346
- 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);
22347
22413
  }
22348
22414
  }
22349
- } catch (e) {
22350
- console.log(e.message);
22415
+ } else {
22416
+ showFailToast("暂不支持此类文件的预览");
22351
22417
  }
22352
- showFailToast("暂不支持此类文件的预览");
22353
22418
  }
22354
22419
  });
22355
22420
  const renderMediaListPlaceholder = () => {
@@ -22416,7 +22481,16 @@ var __publicField = (obj, key, value) => {
22416
22481
  "mediaType": mediaTypeToPlay.value,
22417
22482
  "mediaUrl": mediaUrlToPlay.value,
22418
22483
  "teleport": "body"
22419
- }, 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, {
22420
22494
  "show": actionVisible.value,
22421
22495
  "onUpdate:show": ($event) => actionVisible.value = $event,
22422
22496
  "actions": actionOptions.value,
@@ -31937,7 +32011,7 @@ var __publicField = (obj, key, value) => {
31937
32011
  });
31938
32012
  }
31939
32013
  };
31940
- const version = "3.1.92";
32014
+ const version = "3.1.94";
31941
32015
  function install(app) {
31942
32016
  const components = [
31943
32017
  ActionSheet,