yuang-framework-ui-pc 1.1.50 → 1.1.52

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 (38) hide show
  1. package/es/core-components.d.ts +1 -2
  2. package/es/core-components.js +2 -4
  3. package/es/ele-upload-list/components/list-item.d.ts +1 -0
  4. package/es/ele-upload-list/components/list-item.js +11 -3
  5. package/es/ele-upload-list/index.d.ts +2 -0
  6. package/es/ele-upload-list/index.js +16 -3
  7. package/es/ele-upload-list/types.d.ts +2 -0
  8. package/es/{yu-framework-attachment-image-upload → yu-framework-attachment-upload}/index.js +45 -55
  9. package/es/yu-framework-slider-captcha-dialog/{SliderCaptcha.js → components/SliderCaptcha.js} +1 -1
  10. package/es/yu-framework-slider-captcha-dialog/index.js +1 -1
  11. package/lib/core-components.cjs +2 -4
  12. package/lib/core-components.d.ts +1 -2
  13. package/lib/ele-upload-list/components/list-item.cjs +11 -3
  14. package/lib/ele-upload-list/components/list-item.d.ts +1 -0
  15. package/lib/ele-upload-list/index.cjs +16 -3
  16. package/lib/ele-upload-list/index.d.ts +2 -0
  17. package/lib/ele-upload-list/types.d.ts +2 -0
  18. package/lib/{yu-framework-attachment-image-upload → yu-framework-attachment-upload}/index.cjs +45 -55
  19. package/lib/yu-framework-slider-captcha-dialog/{SliderCaptcha.cjs → components/SliderCaptcha.cjs} +1 -1
  20. package/lib/yu-framework-slider-captcha-dialog/index.cjs +1 -1
  21. package/package.json +2 -2
  22. package/typings/global.d.ts +1 -2
  23. package/es/yu-framework-attachment-file-upload/CommonUpload/index.d.ts +0 -161
  24. package/es/yu-framework-attachment-file-upload/CommonUpload/index.js +0 -173
  25. package/es/yu-framework-attachment-file-upload/FileUpload/index.d.ts +0 -143
  26. package/es/yu-framework-attachment-file-upload/FileUpload/index.js +0 -219
  27. package/es/yu-framework-attachment-file-upload/index.d.ts +0 -16
  28. package/es/yu-framework-attachment-file-upload/index.js +0 -55
  29. package/lib/yu-framework-attachment-file-upload/CommonUpload/index.cjs +0 -172
  30. package/lib/yu-framework-attachment-file-upload/CommonUpload/index.d.ts +0 -161
  31. package/lib/yu-framework-attachment-file-upload/FileUpload/index.cjs +0 -218
  32. package/lib/yu-framework-attachment-file-upload/FileUpload/index.d.ts +0 -143
  33. package/lib/yu-framework-attachment-file-upload/index.cjs +0 -54
  34. package/lib/yu-framework-attachment-file-upload/index.d.ts +0 -16
  35. /package/es/{yu-framework-attachment-image-upload → yu-framework-attachment-upload}/index.d.ts +0 -0
  36. /package/es/yu-framework-slider-captcha-dialog/{SliderCaptcha.d.ts → components/SliderCaptcha.d.ts} +0 -0
  37. /package/lib/{yu-framework-attachment-image-upload → yu-framework-attachment-upload}/index.d.ts +0 -0
  38. /package/lib/yu-framework-slider-captcha-dialog/{SliderCaptcha.d.ts → components/SliderCaptcha.d.ts} +0 -0
@@ -53,5 +53,4 @@ export { default as EleWatermark } from './ele-watermark/index';
53
53
  export { default as EleTest } from './ele-test/index';
54
54
  export { default as YuTest } from './yu-test/index';
55
55
  export { default as YuFrameworkSliderCaptchaDialog } from './yu-framework-slider-captcha-dialog/index';
56
- export { default as YuFrameworkAttachmentFileUpload } from './yu-framework-attachment-file-upload/index';
57
- export { default as YuFrameworkAttachmentImageUpload } from './yu-framework-attachment-image-upload/index';
56
+ export { default as YuFrameworkAttachmentUpload } from './yu-framework-attachment-upload/index';
@@ -53,8 +53,7 @@ import { default as default53 } from "./ele-watermark/index";
53
53
  import { default as default54 } from "./ele-test/index";
54
54
  import { default as default55 } from "./yu-test/index";
55
55
  import { default as default56 } from "./yu-framework-slider-captcha-dialog/index";
56
- import { default as default57 } from "./yu-framework-attachment-file-upload/index";
57
- import { default as default58 } from "./yu-framework-attachment-image-upload/index";
56
+ import { default as default57 } from "./yu-framework-attachment-upload/index";
58
57
  export {
59
58
  default2 as EleAdminLayout,
60
59
  default3 as EleAlert,
@@ -109,8 +108,7 @@ export {
109
108
  default51 as EleUploadList,
110
109
  default52 as EleVirtualTable,
111
110
  default53 as EleWatermark,
112
- default57 as YuFrameworkAttachmentFileUpload,
113
- default58 as YuFrameworkAttachmentImageUpload,
111
+ default57 as YuFrameworkAttachmentUpload,
114
112
  default56 as YuFrameworkSliderCaptchaDialog,
115
113
  default55 as YuTest
116
114
  };
@@ -37,6 +37,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
37
37
  handleEdit: () => void;
38
38
  handlePreview: () => void;
39
39
  handleRetry: () => void;
40
+ isImage: (url?: string) => boolean | "" | undefined;
40
41
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
41
42
  itemClick: (_item: UploadItem) => true;
42
43
  remove: (_item: UploadItem) => true;
@@ -81,6 +81,12 @@ const _sfc_main = defineComponent({
81
81
  const handleRetry = () => {
82
82
  emit("retry", props.item);
83
83
  };
84
+ const isImage = (url) => {
85
+ var _a, _b;
86
+ const parts = url ? url.split(".") : [];
87
+ const suffix = parts.length <= 1 || parts[0] === "" && parts.length === 2 ? "" : (_b = (_a = parts.pop()) == null ? void 0 : _a.toLowerCase) == null ? void 0 : _b.call(_a);
88
+ return suffix && ["png", "jpg", "jpeg", "gif", "svg"].includes(suffix);
89
+ };
84
90
  return {
85
91
  imageUrl,
86
92
  uploadProgress,
@@ -88,7 +94,8 @@ const _sfc_main = defineComponent({
88
94
  handleRemove,
89
95
  handleEdit,
90
96
  handlePreview,
91
- handleRetry
97
+ handleRetry,
98
+ isImage
92
99
  };
93
100
  }
94
101
  });
@@ -182,7 +189,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
182
189
  ], 8, _hoisted_6)) : createCommentVNode("", true)
183
190
  ])
184
191
  ])) : _ctx.tools && !_ctx.readonly && !_ctx.disabled && !_ctx.item.readonly ? (openBlock(), createElementBlock("div", _hoisted_8, [
185
- createElementVNode("div", {
192
+ _ctx.isImage(_ctx.item.url) ? (openBlock(), createElementBlock("div", {
193
+ key: 0,
186
194
  title: _ctx.locale.preview,
187
195
  class: "ele-upload-tool",
188
196
  onClick: _cache[1] || (_cache[1] = withModifiers((...args) => _ctx.handlePreview && _ctx.handlePreview(...args), ["stop"]))
@@ -194,7 +202,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
194
202
  _: 1
195
203
  }),
196
204
  createElementVNode("div", _hoisted_10, toDisplayString(_ctx.locale.preview), 1)
197
- ], 8, _hoisted_9),
205
+ ], 8, _hoisted_9)) : createCommentVNode("", true),
198
206
  createElementVNode("div", {
199
207
  title: _ctx.locale.edit,
200
208
  class: "ele-upload-tool",
@@ -79,6 +79,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
79
79
  handleInputChange: (e: Event) => void;
80
80
  handleUploadClick: (e: MouseEvent) => void;
81
81
  openImagePreview: (urls: string[], index: number) => void;
82
+ isImage: (url?: string) => boolean | "" | undefined;
82
83
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
83
84
  'update:modelValue': (_value: UploadItem[]) => boolean;
84
85
  itemClick: (_item: UploadItem) => boolean;
@@ -1594,6 +1595,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
1594
1595
  handleEdit: () => void;
1595
1596
  handlePreview: () => void;
1596
1597
  handleRetry: () => void;
1598
+ isImage: (url?: string) => boolean | "" | undefined;
1597
1599
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
1598
1600
  itemClick: (_item: UploadItem) => true;
1599
1601
  remove: (_item: UploadItem) => true;
@@ -88,7 +88,11 @@ const _sfc_main = defineComponent({
88
88
  };
89
89
  const handleItemClick = (item) => {
90
90
  if (props.preview) {
91
- previewItem(item);
91
+ if (isImage(item.url)) {
92
+ previewItem(item);
93
+ } else {
94
+ window.open(item.url);
95
+ }
92
96
  }
93
97
  emit("itemClick", item);
94
98
  };
@@ -107,7 +111,9 @@ const _sfc_main = defineComponent({
107
111
  }
108
112
  };
109
113
  const handleItemPreview = (item) => {
110
- previewItem(item);
114
+ if (isImage(item.url)) {
115
+ previewItem(item);
116
+ }
111
117
  emit("preview", item);
112
118
  };
113
119
  const handleItemRetry = (item) => {
@@ -128,6 +134,12 @@ const _sfc_main = defineComponent({
128
134
  e.preventDefault();
129
135
  }
130
136
  };
137
+ const isImage = (url) => {
138
+ var _a, _b;
139
+ const parts = url ? url.split(".") : [];
140
+ const suffix = parts.length <= 1 || parts[0] === "" && parts.length === 2 ? "" : (_b = (_a = parts.pop()) == null ? void 0 : _a.toLowerCase) == null ? void 0 : _b.call(_a);
141
+ return suffix && ["png", "jpg", "jpeg", "gif", "svg"].includes(suffix);
142
+ };
131
143
  watch(
132
144
  () => props.modelValue,
133
145
  () => {
@@ -166,7 +178,8 @@ const _sfc_main = defineComponent({
166
178
  handleItemRetry,
167
179
  handleInputChange,
168
180
  handleUploadClick,
169
- openImagePreview
181
+ openImagePreview,
182
+ isImage
170
183
  };
171
184
  }
172
185
  });
@@ -4,6 +4,8 @@
4
4
  export interface UploadItem extends Record<keyof any, any> {
5
5
  /** 唯一标识 */
6
6
  key: string | number | symbol;
7
+ /** id */
8
+ id: string;
7
9
  /** 显示的图片地址, 为空时显示文件图标 */
8
10
  url?: string;
9
11
  /** 文件名称 */
@@ -5,7 +5,7 @@ import { http } from "yuang-framework-ui-common/lib/config/httpConfig";
5
5
  import { getShortUuid } from "yuang-framework-ui-common/lib/utils/uuidUtils";
6
6
  import { application } from "yuang-framework-ui-common/lib/config/applicationConfig";
7
7
  const _sfc_main = /* @__PURE__ */ defineComponent({
8
- ...{ name: "YuFrameworkAttachmentImageUpload" },
8
+ ...{ name: "YuFrameworkAttachmentUpload" },
9
9
  __name: "index",
10
10
  props: /* @__PURE__ */ mergeModels({
11
11
  modelValue: {},
@@ -16,19 +16,30 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16
16
  }),
17
17
  emits: /* @__PURE__ */ mergeModels(["change"], ["update:modelValue"]),
18
18
  setup(__props, { emit: __emit }) {
19
+ const props = __props;
19
20
  const emit = __emit;
21
+ props.param.mode = props.param.mode ?? "file";
22
+ props.param.maxCount = props.param.maxCount ?? 5;
23
+ props.param.maxSize = props.param.maxSize ?? 5;
20
24
  const images = ref([]);
25
+ const listType = ref(props.param.mode);
26
+ const accept = ref("");
27
+ if (props.param.mode == "file") {
28
+ accept.value = ".txt,.xlsx";
29
+ } else if (props.param.mode == "image") {
30
+ accept.value = ".png,.jpg,.jpeg,.gif,.svg";
31
+ }
21
32
  const isLoading = ref(false);
22
33
  const checkFile = (file) => {
23
34
  if (!file) {
24
35
  return;
25
36
  }
26
- if (!file.type.startsWith("image")) {
37
+ if (props.param.mode === "image" && !file.type.startsWith("image")) {
27
38
  EleMessage.error("只能选择图片");
28
39
  return;
29
40
  }
30
- if (file.size / 1024 / 1024 > 2) {
31
- EleMessage.error("大小不能超过 2MB");
41
+ if (file.size / 1024 / 1024 > props.param.maxSize) {
42
+ EleMessage.error(`图片大小不能超过${props.param.maxSize}MB`);
32
43
  return;
33
44
  }
34
45
  return true;
@@ -36,6 +47,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
36
47
  const model = useModel(__props, "modelValue");
37
48
  model.value = model.value ?? getShortUuid();
38
49
  onMounted(() => {
50
+ init();
51
+ });
52
+ const init = () => {
53
+ images.value = [];
39
54
  http.post(`${application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/selectPage`, { code: model.value, pageSize: 100 }).then((res) => {
40
55
  let attachemtList = res.data.data.records;
41
56
  for (let i = 0; i < attachemtList.length; i++) {
@@ -48,15 +63,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
48
63
  });
49
64
  }
50
65
  });
51
- });
52
- const handleUpload = (uploadItem2, retry) => {
53
- if (!checkFile(uploadItem2.file)) {
66
+ };
67
+ const handleUpload = (uploadItem, retry) => {
68
+ if (!checkFile(uploadItem.file)) {
54
69
  return;
55
70
  }
56
71
  if (!retry) {
57
- images.value.push({ ...uploadItem2 });
72
+ images.value.push({ ...uploadItem });
58
73
  }
59
- const item = images.value.find((t) => t.key === uploadItem2.key);
74
+ const item = images.value.find((t) => t.key === uploadItem.key);
60
75
  console.log(JSON.parse(JSON.stringify(item)));
61
76
  if (!item) {
62
77
  return;
@@ -65,7 +80,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
65
80
  item.progress = 0;
66
81
  let formData = new FormData();
67
82
  formData.append("code", model.value);
68
- formData.append("multipartFile", uploadItem2.file, uploadItem2.file.name);
83
+ formData.append("multipartFile", uploadItem.file, uploadItem.file.name);
69
84
  http({
70
85
  url: `${application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/uploadAttachment`,
71
86
  method: "post",
@@ -77,11 +92,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
77
92
  EleMessage.success(res.data.message);
78
93
  item.progress = 100;
79
94
  item.status = "done";
95
+ item.id = res.data.data.id;
80
96
  item.url = res.data.data.fullUrl;
81
- http.post(`${application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/selectPage`, { code: model.value, pageSize: 100 }).then((res2) => {
82
- let attachemtList = res2.data.data.records;
83
- emit("change", attachemtList);
84
- });
97
+ emitChange();
85
98
  }).catch((e) => {
86
99
  item.status = "exception";
87
100
  EleMessage.error(e.message);
@@ -116,56 +129,30 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
116
129
  oldItem.status = void 0;
117
130
  oldItem.progress = 0;
118
131
  }
132
+ emitChange();
119
133
  }).catch((e) => {
120
134
  item.status = "exception";
121
135
  EleMessage.error(e.message);
122
136
  });
123
137
  };
124
- const handleRemove = (uploadItem2) => {
125
- let id = uploadItem2.id;
138
+ const emitChange = () => {
139
+ http.post(`${application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/selectPage`, { code: model.value, pageSize: 100 }).then((res) => {
140
+ let attachemtList = res.data.data.records;
141
+ emit("change", attachemtList);
142
+ });
143
+ };
144
+ const handleRemove = (uploadItem) => {
145
+ let id = uploadItem.id;
126
146
  ElMessageBox.confirm("确定要删除吗?", "系统提示", { type: "warning", draggable: true }).then(() => {
127
147
  http.get(`${application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/deleteInfo`, { params: { id } }).then((res) => {
128
148
  EleMessage.success(res.data.message);
129
- images.value.splice(images.value.indexOf(uploadItem2), 1);
149
+ images.value.splice(images.value.indexOf(uploadItem), 1);
150
+ emitChange();
130
151
  });
131
152
  });
132
153
  };
133
- const uploadItem = (item) => {
134
- item.status = "uploading";
135
- if (item.progress == null) {
136
- item.progress = 20;
137
- }
138
- const timer = setInterval(
139
- () => {
140
- if (Math.round(Math.random() * 10) < 3) {
141
- item.status = "exception";
142
- EleMessage.error("上传失败, 服务器繁忙,请重试");
143
- clearInterval(timer);
144
- return;
145
- }
146
- if (item.progress == null) {
147
- item.progress = 20;
148
- } else {
149
- item.progress += 20;
150
- }
151
- if (item.progress === 100) {
152
- item.status = "done";
153
- clearInterval(timer);
154
- if (checkDone()) {
155
- submitForm();
156
- }
157
- }
158
- },
159
- Math.round(Math.random() * 2500) + 500
160
- );
161
- };
162
- const checkDone = () => {
163
- return !images.value.some((d) => d.status !== "done");
164
- };
165
- const submitForm = () => {
166
- EleMessage.success("已全部上传完毕");
167
- console.log(JSON.parse(JSON.stringify(images.value)));
168
- isLoading.value = false;
154
+ const handleRetryUpload = (uploadItem) => {
155
+ handleUpload(uploadItem, true);
169
156
  };
170
157
  return (_ctx, _cache) => {
171
158
  const _component_ele_upload_list = resolveComponent("ele-upload-list");
@@ -175,14 +162,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
175
162
  tools: true,
176
163
  modelValue: images.value,
177
164
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => images.value = $event),
165
+ limit: _ctx.param.maxCount,
166
+ listType: listType.value,
167
+ accept: accept.value,
178
168
  readonly: isLoading.value,
179
169
  disabled: _ctx.param.type != "edit",
180
170
  sortable: { forceFallback: true },
181
171
  onUpload: handleUpload,
182
- onRetry: uploadItem,
172
+ onRetry: handleRetryUpload,
183
173
  onRemove: handleRemove,
184
174
  onEditUpload: handleEditUpload
185
- }, null, 8, ["modelValue", "readonly", "disabled"])
175
+ }, null, 8, ["modelValue", "limit", "listType", "accept", "readonly", "disabled"])
186
176
  ]);
187
177
  };
188
178
  }
@@ -2,7 +2,7 @@ import { defineComponent, ref, onMounted, nextTick, createElementBlock, openBloc
2
2
  import { http } from "yuang-framework-ui-common/lib/config/httpConfig";
3
3
  import { application } from "yuang-framework-ui-common/lib/config/applicationConfig";
4
4
  import { RefreshRight, CircleClose } from "@element-plus/icons-vue";
5
- import { SliderArrowStatic, SliderArrowSlide } from "../icons";
5
+ import { SliderArrowStatic, SliderArrowSlide } from "../../icons";
6
6
  const _hoisted_1 = { class: "yu-framework-slider-captcha" };
7
7
  const _hoisted_2 = { class: "yu-framework-slider-captcha-title" };
8
8
  const _hoisted_3 = ["width", "height"];
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, ref, createElementBlock, createCommentVNode, openBlock, createElementVNode, createVNode } from "vue";
2
- import SliderCaptcha from "./SliderCaptcha";
2
+ import SliderCaptcha from "./components/SliderCaptcha";
3
3
  const _hoisted_1 = {
4
4
  key: 0,
5
5
  class: "yu-framework-slider-captcha-dialog"
@@ -55,8 +55,7 @@ const index$P = require("./ele-watermark/index");
55
55
  const index$Q = require("./ele-test/index");
56
56
  const index$R = require("./yu-test/index");
57
57
  const index$S = require("./yu-framework-slider-captcha-dialog/index");
58
- const index$T = require("./yu-framework-attachment-file-upload/index");
59
- const index$U = require("./yu-framework-attachment-image-upload/index");
58
+ const index$T = require("./yu-framework-attachment-upload/index");
60
59
  exports.EleAdminLayout = index;
61
60
  exports.EleAlert = index$1;
62
61
  exports.EleApp = index$2;
@@ -112,5 +111,4 @@ exports.EleWatermark = index$P;
112
111
  exports.EleTest = index$Q;
113
112
  exports.YuTest = index$R;
114
113
  exports.YuFrameworkSliderCaptchaDialog = index$S;
115
- exports.YuFrameworkAttachmentFileUpload = index$T;
116
- exports.YuFrameworkAttachmentImageUpload = index$U;
114
+ exports.YuFrameworkAttachmentUpload = index$T;
@@ -53,5 +53,4 @@ export { default as EleWatermark } from './ele-watermark/index';
53
53
  export { default as EleTest } from './ele-test/index';
54
54
  export { default as YuTest } from './yu-test/index';
55
55
  export { default as YuFrameworkSliderCaptchaDialog } from './yu-framework-slider-captcha-dialog/index';
56
- export { default as YuFrameworkAttachmentFileUpload } from './yu-framework-attachment-file-upload/index';
57
- export { default as YuFrameworkAttachmentImageUpload } from './yu-framework-attachment-image-upload/index';
56
+ export { default as YuFrameworkAttachmentUpload } from './yu-framework-attachment-upload/index';
@@ -82,6 +82,12 @@ const _sfc_main = vue.defineComponent({
82
82
  const handleRetry = () => {
83
83
  emit("retry", props.item);
84
84
  };
85
+ const isImage = (url) => {
86
+ var _a, _b;
87
+ const parts = url ? url.split(".") : [];
88
+ const suffix = parts.length <= 1 || parts[0] === "" && parts.length === 2 ? "" : (_b = (_a = parts.pop()) == null ? void 0 : _a.toLowerCase) == null ? void 0 : _b.call(_a);
89
+ return suffix && ["png", "jpg", "jpeg", "gif", "svg"].includes(suffix);
90
+ };
85
91
  return {
86
92
  imageUrl,
87
93
  uploadProgress,
@@ -89,7 +95,8 @@ const _sfc_main = vue.defineComponent({
89
95
  handleRemove,
90
96
  handleEdit,
91
97
  handlePreview,
92
- handleRetry
98
+ handleRetry,
99
+ isImage
93
100
  };
94
101
  }
95
102
  });
@@ -183,7 +190,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
183
190
  ], 8, _hoisted_6)) : vue.createCommentVNode("", true)
184
191
  ])
185
192
  ])) : _ctx.tools && !_ctx.readonly && !_ctx.disabled && !_ctx.item.readonly ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_8, [
186
- vue.createElementVNode("div", {
193
+ _ctx.isImage(_ctx.item.url) ? (vue.openBlock(), vue.createElementBlock("div", {
194
+ key: 0,
187
195
  title: _ctx.locale.preview,
188
196
  class: "ele-upload-tool",
189
197
  onClick: _cache[1] || (_cache[1] = vue.withModifiers((...args) => _ctx.handlePreview && _ctx.handlePreview(...args), ["stop"]))
@@ -195,7 +203,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
195
203
  _: 1
196
204
  }),
197
205
  vue.createElementVNode("div", _hoisted_10, vue.toDisplayString(_ctx.locale.preview), 1)
198
- ], 8, _hoisted_9),
206
+ ], 8, _hoisted_9)) : vue.createCommentVNode("", true),
199
207
  vue.createElementVNode("div", {
200
208
  title: _ctx.locale.edit,
201
209
  class: "ele-upload-tool",
@@ -37,6 +37,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
37
37
  handleEdit: () => void;
38
38
  handlePreview: () => void;
39
39
  handleRetry: () => void;
40
+ isImage: (url?: string) => boolean | "" | undefined;
40
41
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
41
42
  itemClick: (_item: UploadItem) => true;
42
43
  remove: (_item: UploadItem) => true;
@@ -89,7 +89,11 @@ const _sfc_main = vue.defineComponent({
89
89
  };
90
90
  const handleItemClick = (item) => {
91
91
  if (props2.preview) {
92
- previewItem(item);
92
+ if (isImage(item.url)) {
93
+ previewItem(item);
94
+ } else {
95
+ window.open(item.url);
96
+ }
93
97
  }
94
98
  emit("itemClick", item);
95
99
  };
@@ -108,7 +112,9 @@ const _sfc_main = vue.defineComponent({
108
112
  }
109
113
  };
110
114
  const handleItemPreview = (item) => {
111
- previewItem(item);
115
+ if (isImage(item.url)) {
116
+ previewItem(item);
117
+ }
112
118
  emit("preview", item);
113
119
  };
114
120
  const handleItemRetry = (item) => {
@@ -129,6 +135,12 @@ const _sfc_main = vue.defineComponent({
129
135
  e.preventDefault();
130
136
  }
131
137
  };
138
+ const isImage = (url) => {
139
+ var _a, _b;
140
+ const parts = url ? url.split(".") : [];
141
+ const suffix = parts.length <= 1 || parts[0] === "" && parts.length === 2 ? "" : (_b = (_a = parts.pop()) == null ? void 0 : _a.toLowerCase) == null ? void 0 : _b.call(_a);
142
+ return suffix && ["png", "jpg", "jpeg", "gif", "svg"].includes(suffix);
143
+ };
132
144
  vue.watch(
133
145
  () => props2.modelValue,
134
146
  () => {
@@ -167,7 +179,8 @@ const _sfc_main = vue.defineComponent({
167
179
  handleItemRetry,
168
180
  handleInputChange,
169
181
  handleUploadClick,
170
- openImagePreview
182
+ openImagePreview,
183
+ isImage
171
184
  };
172
185
  }
173
186
  });
@@ -79,6 +79,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
79
79
  handleInputChange: (e: Event) => void;
80
80
  handleUploadClick: (e: MouseEvent) => void;
81
81
  openImagePreview: (urls: string[], index: number) => void;
82
+ isImage: (url?: string) => boolean | "" | undefined;
82
83
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
83
84
  'update:modelValue': (_value: UploadItem[]) => boolean;
84
85
  itemClick: (_item: UploadItem) => boolean;
@@ -1594,6 +1595,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
1594
1595
  handleEdit: () => void;
1595
1596
  handlePreview: () => void;
1596
1597
  handleRetry: () => void;
1598
+ isImage: (url?: string) => boolean | "" | undefined;
1597
1599
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
1598
1600
  itemClick: (_item: UploadItem) => true;
1599
1601
  remove: (_item: UploadItem) => true;
@@ -4,6 +4,8 @@
4
4
  export interface UploadItem extends Record<keyof any, any> {
5
5
  /** 唯一标识 */
6
6
  key: string | number | symbol;
7
+ /** id */
8
+ id: string;
7
9
  /** 显示的图片地址, 为空时显示文件图标 */
8
10
  url?: string;
9
11
  /** 文件名称 */