knt-shared 1.10.6 → 1.10.8
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.
- package/dist/components/Form/componentMap.d.ts +5 -15
- package/dist/components/Form/componentMap.d.ts.map +1 -1
- package/dist/components/Image/BasicImage.vue.d.ts.map +1 -1
- package/dist/components/Image/useImage.d.ts.map +1 -1
- package/dist/components/Table/components/componentMap.d.ts +5 -15
- package/dist/components/Table/components/componentMap.d.ts.map +1 -1
- package/dist/components/Upload/BasicUpload.vue.d.ts +2 -6
- package/dist/components/Upload/BasicUpload.vue.d.ts.map +1 -1
- package/dist/components/Upload/components/VideoPreview.vue.d.ts +2 -7
- package/dist/components/Upload/components/VideoPreview.vue.d.ts.map +1 -1
- package/dist/components/Upload/components/VideoPreviewModal.vue.d.ts +2 -7
- package/dist/components/Upload/components/VideoPreviewModal.vue.d.ts.map +1 -1
- package/dist/components/Upload/types.d.ts +1 -5
- package/dist/components/Upload/types.d.ts.map +1 -1
- package/dist/components/Upload/useUpload.d.ts.map +1 -1
- package/dist/index.cjs.js +168 -118
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +168 -118
- package/dist/index.esm.js.map +1 -1
- package/dist/style.css +86 -79
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -2460,7 +2460,7 @@ const _hoisted_4$4 = {
|
|
|
2460
2460
|
const _hoisted_5$4 = { class: "progress-bar" };
|
|
2461
2461
|
const _hoisted_6$3 = { class: "controls-bottom" };
|
|
2462
2462
|
const _hoisted_7$2 = { class: "controls-left" };
|
|
2463
|
-
const _hoisted_8$
|
|
2463
|
+
const _hoisted_8$2 = { class: "volume-slider-container" };
|
|
2464
2464
|
const _hoisted_9 = { class: "time-display" };
|
|
2465
2465
|
const _hoisted_10 = { class: "controls-right" };
|
|
2466
2466
|
const _hoisted_11 = { class: "control-button" };
|
|
@@ -2485,6 +2485,7 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
|
|
|
2485
2485
|
const props = __props;
|
|
2486
2486
|
const emit = __emit;
|
|
2487
2487
|
const videoRef = vue.ref();
|
|
2488
|
+
const progressBarRef = vue.ref();
|
|
2488
2489
|
const isPlaying = vue.ref(false);
|
|
2489
2490
|
const isLoading = vue.ref(true);
|
|
2490
2491
|
const currentTime = vue.ref(0);
|
|
@@ -2513,7 +2514,11 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
|
|
|
2513
2514
|
videoRef.value.pause();
|
|
2514
2515
|
emit("pause");
|
|
2515
2516
|
} else {
|
|
2516
|
-
videoRef.value.play()
|
|
2517
|
+
videoRef.value.play().catch((err) => {
|
|
2518
|
+
if (err.name !== "AbortError") {
|
|
2519
|
+
console.error("[VideoPreview] play() 失败:", err);
|
|
2520
|
+
}
|
|
2521
|
+
});
|
|
2517
2522
|
emit("play");
|
|
2518
2523
|
}
|
|
2519
2524
|
};
|
|
@@ -2581,11 +2586,8 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
|
|
|
2581
2586
|
document.addEventListener("mouseup", handleProgressMouseUp);
|
|
2582
2587
|
};
|
|
2583
2588
|
const handleProgressMouseMove = (event) => {
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
const container = (_b = (_a2 = videoRef.value.parentElement) == null ? void 0 : _a2.parentElement) == null ? void 0 : _b.querySelector(".progress-bar-container");
|
|
2587
|
-
if (!container) return;
|
|
2588
|
-
const rect = container.getBoundingClientRect();
|
|
2589
|
+
if (!isDraggingProgress.value || !videoRef.value || !progressBarRef.value) return;
|
|
2590
|
+
const rect = progressBarRef.value.getBoundingClientRect();
|
|
2589
2591
|
let percent = (event.clientX - rect.left) / rect.width;
|
|
2590
2592
|
percent = Math.max(0, Math.min(1, percent));
|
|
2591
2593
|
videoRef.value.currentTime = percent * duration.value;
|
|
@@ -2698,6 +2700,8 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
|
|
|
2698
2700
|
}, ["stop"]))
|
|
2699
2701
|
}, [
|
|
2700
2702
|
vue.createElementVNode("div", {
|
|
2703
|
+
ref_key: "progressBarRef",
|
|
2704
|
+
ref: progressBarRef,
|
|
2701
2705
|
class: "progress-bar-container",
|
|
2702
2706
|
onClick: handleProgressClick
|
|
2703
2707
|
}, [
|
|
@@ -2716,7 +2720,7 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
|
|
|
2716
2720
|
onMousedown: handleProgressMouseDown
|
|
2717
2721
|
}, null, 36)
|
|
2718
2722
|
])
|
|
2719
|
-
]),
|
|
2723
|
+
], 512),
|
|
2720
2724
|
vue.createElementVNode("div", _hoisted_6$3, [
|
|
2721
2725
|
vue.createElementVNode("div", _hoisted_7$2, [
|
|
2722
2726
|
vue.createElementVNode("button", {
|
|
@@ -2748,7 +2752,7 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
|
|
|
2748
2752
|
size: 20
|
|
2749
2753
|
}))
|
|
2750
2754
|
]),
|
|
2751
|
-
vue.withDirectives(vue.createElementVNode("div", _hoisted_8$
|
|
2755
|
+
vue.withDirectives(vue.createElementVNode("div", _hoisted_8$2, [
|
|
2752
2756
|
vue.withDirectives(vue.createElementVNode("input", {
|
|
2753
2757
|
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => volume.value = $event),
|
|
2754
2758
|
type: "range",
|
|
@@ -2810,7 +2814,7 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
|
|
|
2810
2814
|
};
|
|
2811
2815
|
}
|
|
2812
2816
|
});
|
|
2813
|
-
const VideoPreview = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-
|
|
2817
|
+
const VideoPreview = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-d4fd2c00"]]);
|
|
2814
2818
|
const _hoisted_1$a = { class: "video-modal-title" };
|
|
2815
2819
|
const _hoisted_2$7 = { class: "file-name" };
|
|
2816
2820
|
const _hoisted_3$5 = { class: "video-modal-content" };
|
|
@@ -2833,7 +2837,6 @@ const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
|
|
|
2833
2837
|
},
|
|
2834
2838
|
emits: ["update:visible", "play", "pause", "ended"],
|
|
2835
2839
|
setup(__props, { emit: __emit }) {
|
|
2836
|
-
const props = __props;
|
|
2837
2840
|
const emit = __emit;
|
|
2838
2841
|
const handleClose = () => {
|
|
2839
2842
|
emit("update:visible", false);
|
|
@@ -2847,11 +2850,6 @@ const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
|
|
|
2847
2850
|
const handleEnded = () => {
|
|
2848
2851
|
emit("ended");
|
|
2849
2852
|
};
|
|
2850
|
-
vue.watch(
|
|
2851
|
-
() => props.visible,
|
|
2852
|
-
(newVisible) => {
|
|
2853
|
-
}
|
|
2854
|
-
);
|
|
2855
2853
|
return (_ctx, _cache) => {
|
|
2856
2854
|
return vue.openBlock(), vue.createBlock(vue.unref(ArcoVue.Modal), {
|
|
2857
2855
|
visible: __props.visible,
|
|
@@ -2885,7 +2883,7 @@ const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
|
|
|
2885
2883
|
};
|
|
2886
2884
|
}
|
|
2887
2885
|
});
|
|
2888
|
-
const VideoPreviewModal = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["__scopeId", "data-v-
|
|
2886
|
+
const VideoPreviewModal = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["__scopeId", "data-v-db151e2d"]]);
|
|
2889
2887
|
const _hoisted_1$9 = { class: "basic-upload" };
|
|
2890
2888
|
const _hoisted_2$6 = {
|
|
2891
2889
|
key: 0,
|
|
@@ -2908,7 +2906,7 @@ const _hoisted_7$1 = {
|
|
|
2908
2906
|
key: 1,
|
|
2909
2907
|
class: "upload-tip sortable-tip"
|
|
2910
2908
|
};
|
|
2911
|
-
const _hoisted_8 = {
|
|
2909
|
+
const _hoisted_8$1 = {
|
|
2912
2910
|
key: 5,
|
|
2913
2911
|
class: "inline-video-preview"
|
|
2914
2912
|
};
|
|
@@ -2973,10 +2971,10 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
2973
2971
|
showErrorMessage: { type: Boolean, default: true },
|
|
2974
2972
|
showSuccessMessage: { type: Boolean, default: true }
|
|
2975
2973
|
},
|
|
2976
|
-
emits: ["register", "update:modelValue", "change", "
|
|
2974
|
+
emits: ["register", "update:modelValue", "change", "handleSuccess", "handleError", "progress", "remove", "preview", "exceed", "sortChange"],
|
|
2977
2975
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2978
2976
|
vue.useCssVars((_ctx) => ({
|
|
2979
|
-
"
|
|
2977
|
+
"v0a277aea": cardSizeValue.value
|
|
2980
2978
|
}));
|
|
2981
2979
|
const MAX_SIZE_UNIT_BYTES = {
|
|
2982
2980
|
B: 1,
|
|
@@ -3146,6 +3144,11 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
3146
3144
|
}
|
|
3147
3145
|
return defaultUpload(options);
|
|
3148
3146
|
};
|
|
3147
|
+
const isSafeUrl = (url) => {
|
|
3148
|
+
if (!url || typeof url !== "string") return false;
|
|
3149
|
+
const lower = url.trim().toLowerCase();
|
|
3150
|
+
return !lower.startsWith("javascript:") && !lower.startsWith("data:");
|
|
3151
|
+
};
|
|
3149
3152
|
const extractUrlFromResponse = (response) => {
|
|
3150
3153
|
const urlPaths = [
|
|
3151
3154
|
"url",
|
|
@@ -3157,11 +3160,11 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
3157
3160
|
];
|
|
3158
3161
|
for (const path of urlPaths) {
|
|
3159
3162
|
const value = path.split(".").reduce((obj, key) => obj == null ? void 0 : obj[key], response);
|
|
3160
|
-
if (value && typeof value === "string") {
|
|
3163
|
+
if (value && typeof value === "string" && isSafeUrl(value)) {
|
|
3161
3164
|
return value;
|
|
3162
3165
|
}
|
|
3163
3166
|
}
|
|
3164
|
-
if (response.data && typeof response.data === "string") {
|
|
3167
|
+
if (response.data && typeof response.data === "string" && isSafeUrl(response.data)) {
|
|
3165
3168
|
return response.data;
|
|
3166
3169
|
}
|
|
3167
3170
|
return null;
|
|
@@ -3184,11 +3187,8 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
3184
3187
|
}, 3e3);
|
|
3185
3188
|
}
|
|
3186
3189
|
onError(new Error("上传地址未配置"));
|
|
3187
|
-
return {
|
|
3188
|
-
|
|
3189
|
-
xhr.abort();
|
|
3190
|
-
}
|
|
3191
|
-
};
|
|
3190
|
+
return { abort() {
|
|
3191
|
+
} };
|
|
3192
3192
|
}
|
|
3193
3193
|
const formData = new FormData();
|
|
3194
3194
|
formData.append(propsData.name || "file", fileItem.file);
|
|
@@ -3254,23 +3254,17 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
3254
3254
|
}
|
|
3255
3255
|
};
|
|
3256
3256
|
};
|
|
3257
|
+
const VIDEO_EXTENSIONS = [".mp4", ".avi", ".mov", ".wmv", ".flv", ".webm", ".mkv", ".m4v"];
|
|
3257
3258
|
const addVideoFileClass = () => {
|
|
3258
3259
|
vue.nextTick(() => {
|
|
3259
|
-
|
|
3260
|
+
var _a;
|
|
3261
|
+
const root = ((_a = uploadRef.value) == null ? void 0 : _a.$el) ?? null;
|
|
3262
|
+
const scope = root ?? document;
|
|
3263
|
+
const uploadItems = scope.querySelectorAll(".arco-upload-list-picture");
|
|
3260
3264
|
uploadItems.forEach((item) => {
|
|
3261
3265
|
const img = item.querySelector("img");
|
|
3262
3266
|
if (img && img.src) {
|
|
3263
|
-
const
|
|
3264
|
-
".mp4",
|
|
3265
|
-
".avi",
|
|
3266
|
-
".mov",
|
|
3267
|
-
".wmv",
|
|
3268
|
-
".flv",
|
|
3269
|
-
".webm",
|
|
3270
|
-
".mkv",
|
|
3271
|
-
".m4v"
|
|
3272
|
-
];
|
|
3273
|
-
const isVideo = videoExtensions.some(
|
|
3267
|
+
const isVideo = VIDEO_EXTENSIONS.some(
|
|
3274
3268
|
(ext) => img.src.toLowerCase().includes(ext)
|
|
3275
3269
|
);
|
|
3276
3270
|
if (isVideo) {
|
|
@@ -3284,14 +3278,15 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
3284
3278
|
};
|
|
3285
3279
|
const handleChange = (fileList, currentFile) => {
|
|
3286
3280
|
const oldLength = fileListRef.value.length;
|
|
3287
|
-
const
|
|
3281
|
+
const newFileList = currentFile.status === "error" ? fileList.filter((f) => f.uid !== currentFile.uid) : fileList;
|
|
3282
|
+
const newLength = newFileList.length;
|
|
3288
3283
|
if (newLength > oldLength) {
|
|
3289
3284
|
const added = newLength - oldLength;
|
|
3290
3285
|
pendingCount.value = Math.max(0, pendingCount.value - added);
|
|
3291
3286
|
}
|
|
3292
|
-
fileListRef.value =
|
|
3287
|
+
fileListRef.value = newFileList;
|
|
3293
3288
|
addVideoFileClass();
|
|
3294
|
-
emit("change",
|
|
3289
|
+
emit("change", newFileList);
|
|
3295
3290
|
const isRemove = newLength < oldLength;
|
|
3296
3291
|
const fileKey = currentFile.uid || `file-${Date.now()}-${Math.random()}`;
|
|
3297
3292
|
const lastStatus = processedFiles.value.get(fileKey);
|
|
@@ -3299,19 +3294,18 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
3299
3294
|
processedFiles.value.set(fileKey, "done");
|
|
3300
3295
|
emit("handleSuccess", currentFile.response, currentFile);
|
|
3301
3296
|
} else if (currentFile.status === "error" && lastStatus !== "error") {
|
|
3302
|
-
processedFiles.value.set(fileKey, "error");
|
|
3303
3297
|
const error = new Error("上传失败");
|
|
3304
|
-
emit("
|
|
3298
|
+
emit("handleError", error, currentFile);
|
|
3305
3299
|
}
|
|
3306
3300
|
if (isRemove) {
|
|
3307
|
-
const fileUids = new Set(
|
|
3301
|
+
const fileUids = new Set(newFileList.map((f) => f.uid));
|
|
3308
3302
|
processedFiles.value.forEach((_value, uid) => {
|
|
3309
3303
|
if (!fileUids.has(uid)) {
|
|
3310
3304
|
processedFiles.value.delete(uid);
|
|
3311
3305
|
}
|
|
3312
3306
|
});
|
|
3313
3307
|
}
|
|
3314
|
-
updateModelValue(
|
|
3308
|
+
updateModelValue(newFileList);
|
|
3315
3309
|
};
|
|
3316
3310
|
const handleProgress = (currentFile) => {
|
|
3317
3311
|
const percent = currentFile.percent || 0;
|
|
@@ -3382,14 +3376,17 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
3382
3376
|
(item) => item.url === fileItem.url && item.path === fileItem.path
|
|
3383
3377
|
);
|
|
3384
3378
|
};
|
|
3379
|
+
const stableUid = (url, index) => `url-${index}-${url.replace(/[^a-zA-Z0-9.\-_]/g, "_")}`;
|
|
3385
3380
|
const parseModelValue = (value) => {
|
|
3386
3381
|
if (!value) return [];
|
|
3387
|
-
if (Array.isArray(value) && value.length > 0 && typeof value[0] === "object") {
|
|
3388
|
-
return value.map(normalizeFileItem);
|
|
3389
|
-
}
|
|
3390
3382
|
if (Array.isArray(value)) {
|
|
3391
|
-
|
|
3392
|
-
|
|
3383
|
+
if (value.length === 0) return [];
|
|
3384
|
+
const first = value[0];
|
|
3385
|
+
if (first !== null && first !== void 0 && typeof first === "object") {
|
|
3386
|
+
return value.filter((item) => item !== null && item !== void 0).map(normalizeFileItem);
|
|
3387
|
+
}
|
|
3388
|
+
return value.filter((url) => url && typeof url === "string").map((url, index) => ({
|
|
3389
|
+
uid: stableUid(url.trim(), index),
|
|
3393
3390
|
name: url.split("/").pop() || `file-${index}`,
|
|
3394
3391
|
url,
|
|
3395
3392
|
status: "done"
|
|
@@ -3398,8 +3395,8 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
3398
3395
|
if (typeof value === "string") {
|
|
3399
3396
|
const urls = value.split(",").filter(Boolean);
|
|
3400
3397
|
return urls.map((url, index) => ({
|
|
3401
|
-
uid:
|
|
3402
|
-
name: url.split("/").pop() || `file-${index}`,
|
|
3398
|
+
uid: stableUid(url.trim(), index),
|
|
3399
|
+
name: url.trim().split("/").pop() || `file-${index}`,
|
|
3403
3400
|
url: url.trim(),
|
|
3404
3401
|
status: "done"
|
|
3405
3402
|
}));
|
|
@@ -3483,10 +3480,23 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
3483
3480
|
vue.watch(
|
|
3484
3481
|
() => getProps.value.modelValue,
|
|
3485
3482
|
(val) => {
|
|
3486
|
-
|
|
3483
|
+
const parsed = parseModelValue(val);
|
|
3484
|
+
const isExternalClear = !val || Array.isArray(val) && val.length === 0 || typeof val === "string" && val.trim() === "";
|
|
3485
|
+
if (!isExternalClear) {
|
|
3486
|
+
const hasUploading = fileListRef.value.some(
|
|
3487
|
+
(f) => f.status === "uploading" || f.status === "init"
|
|
3488
|
+
);
|
|
3489
|
+
if (hasUploading) return;
|
|
3490
|
+
}
|
|
3491
|
+
const isSame = parsed.length === fileListRef.value.length && parsed.every((newItem, i) => {
|
|
3492
|
+
const oldItem = fileListRef.value[i];
|
|
3493
|
+
return newItem.uid === (oldItem == null ? void 0 : oldItem.uid) && newItem.url === (oldItem == null ? void 0 : oldItem.url);
|
|
3494
|
+
});
|
|
3495
|
+
if (isSame) return;
|
|
3496
|
+
fileListRef.value = parsed;
|
|
3487
3497
|
addVideoFileClass();
|
|
3488
3498
|
},
|
|
3489
|
-
{ immediate: true }
|
|
3499
|
+
{ immediate: true, deep: true }
|
|
3490
3500
|
);
|
|
3491
3501
|
vue.onMounted(() => {
|
|
3492
3502
|
vue.nextTick(() => {
|
|
@@ -3634,7 +3644,7 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
3634
3644
|
"file-name": previewFileName.value,
|
|
3635
3645
|
"player-options": getProps.value.videoPlayerOptions
|
|
3636
3646
|
}, null, 8, ["visible", "video-url", "file-name", "player-options"])) : vue.createCommentVNode("", true),
|
|
3637
|
-
getProps.value.videoPreviewMode === "inline" && previewVideoVisible.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_8, [
|
|
3647
|
+
getProps.value.videoPreviewMode === "inline" && previewVideoVisible.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_8$1, [
|
|
3638
3648
|
vue.createVNode(VideoPreview, {
|
|
3639
3649
|
"video-url": previewVideoUrl.value,
|
|
3640
3650
|
"player-options": getProps.value.videoPlayerOptions
|
|
@@ -3653,7 +3663,7 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
3653
3663
|
};
|
|
3654
3664
|
}
|
|
3655
3665
|
});
|
|
3656
|
-
const BasicUpload = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-
|
|
3666
|
+
const BasicUpload = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-d256c7da"]]);
|
|
3657
3667
|
function useUpload(props) {
|
|
3658
3668
|
const uploadRef = vue.ref(null);
|
|
3659
3669
|
const fileListRef = vue.ref((props == null ? void 0 : props.defaultFileList) || []);
|
|
@@ -3663,7 +3673,7 @@ function useUpload(props) {
|
|
|
3663
3673
|
uploadInstance.setFileList(props.defaultFileList);
|
|
3664
3674
|
}
|
|
3665
3675
|
if (props && Object.keys(props).length > 0) {
|
|
3666
|
-
const { defaultFileList, ...restProps } = props;
|
|
3676
|
+
const { defaultFileList: _, ...restProps } = props;
|
|
3667
3677
|
if (Object.keys(restProps).length > 0) {
|
|
3668
3678
|
setProps(restProps);
|
|
3669
3679
|
}
|
|
@@ -3687,48 +3697,36 @@ function useUpload(props) {
|
|
|
3687
3697
|
fileListRef.value = [];
|
|
3688
3698
|
};
|
|
3689
3699
|
const getFileList = () => {
|
|
3690
|
-
|
|
3700
|
+
const list = getUpload().getFileList();
|
|
3701
|
+
fileListRef.value = list;
|
|
3702
|
+
return list;
|
|
3691
3703
|
};
|
|
3692
3704
|
const upload = (fileItem) => {
|
|
3693
3705
|
getUpload().upload(fileItem);
|
|
3694
3706
|
};
|
|
3695
3707
|
const setFileList = (files) => {
|
|
3696
|
-
|
|
3708
|
+
var _a;
|
|
3697
3709
|
const upload2 = getUpload();
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
}
|
|
3710
|
+
(_a = upload2.setFileList) == null ? void 0 : _a.call(upload2, files);
|
|
3711
|
+
fileListRef.value = upload2.getFileList();
|
|
3701
3712
|
};
|
|
3702
3713
|
const addFile = (file) => {
|
|
3703
|
-
|
|
3714
|
+
var _a;
|
|
3704
3715
|
const upload2 = getUpload();
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
}
|
|
3716
|
+
(_a = upload2.addFile) == null ? void 0 : _a.call(upload2, file);
|
|
3717
|
+
fileListRef.value = upload2.getFileList();
|
|
3708
3718
|
};
|
|
3709
3719
|
const removeFile = (fileItem) => {
|
|
3710
|
-
|
|
3711
|
-
(item) => item.uid === fileItem.uid
|
|
3712
|
-
);
|
|
3713
|
-
if (index !== -1) {
|
|
3714
|
-
fileListRef.value.splice(index, 1);
|
|
3715
|
-
}
|
|
3720
|
+
var _a;
|
|
3716
3721
|
const upload2 = getUpload();
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
}
|
|
3722
|
+
(_a = upload2.removeFile) == null ? void 0 : _a.call(upload2, fileItem);
|
|
3723
|
+
fileListRef.value = upload2.getFileList();
|
|
3720
3724
|
};
|
|
3721
3725
|
const updateFile = (fileItem) => {
|
|
3722
|
-
|
|
3723
|
-
(item) => item.uid === fileItem.uid
|
|
3724
|
-
);
|
|
3725
|
-
if (index !== -1) {
|
|
3726
|
-
fileListRef.value[index] = { ...fileListRef.value[index], ...fileItem };
|
|
3727
|
-
}
|
|
3726
|
+
var _a;
|
|
3728
3727
|
const upload2 = getUpload();
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
}
|
|
3728
|
+
(_a = upload2.updateFile) == null ? void 0 : _a.call(upload2, fileItem);
|
|
3729
|
+
fileListRef.value = upload2.getFileList();
|
|
3732
3730
|
};
|
|
3733
3731
|
const setProps = (uploadProps) => {
|
|
3734
3732
|
getUpload().setProps(uploadProps);
|
|
@@ -10199,17 +10197,17 @@ function useDescription(props) {
|
|
|
10199
10197
|
}
|
|
10200
10198
|
];
|
|
10201
10199
|
}
|
|
10202
|
-
const _hoisted_1$2 = {
|
|
10203
|
-
const _hoisted_2$1 = {
|
|
10200
|
+
const _hoisted_1$2 = {
|
|
10204
10201
|
key: 0,
|
|
10205
10202
|
class: "basic-image-empty"
|
|
10206
10203
|
};
|
|
10207
|
-
const
|
|
10208
|
-
const
|
|
10204
|
+
const _hoisted_2$1 = { class: "empty-text" };
|
|
10205
|
+
const _hoisted_3$1 = {
|
|
10209
10206
|
key: 0,
|
|
10210
10207
|
class: "basic-image-simple"
|
|
10211
10208
|
};
|
|
10212
|
-
const
|
|
10209
|
+
const _hoisted_4 = { class: "image-wrapper" };
|
|
10210
|
+
const _hoisted_5 = ["src", "width", "height", "alt"];
|
|
10213
10211
|
const _hoisted_6 = {
|
|
10214
10212
|
key: 0,
|
|
10215
10213
|
class: "image-count-badge"
|
|
@@ -10218,6 +10216,7 @@ const _hoisted_7 = {
|
|
|
10218
10216
|
key: 0,
|
|
10219
10217
|
style: { "display": "none" }
|
|
10220
10218
|
};
|
|
10219
|
+
const _hoisted_8 = ["src", "width", "height", "alt"];
|
|
10221
10220
|
const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
|
|
10222
10221
|
...{
|
|
10223
10222
|
name: "BasicImage"
|
|
@@ -10245,21 +10244,45 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
|
|
|
10245
10244
|
const getProps = vue.computed(() => {
|
|
10246
10245
|
return { ...props, ...innerPropsRef.value };
|
|
10247
10246
|
});
|
|
10247
|
+
function isSafeImageUrl(url) {
|
|
10248
|
+
if (!url || typeof url !== "string") return false;
|
|
10249
|
+
const trimmed = url.trim();
|
|
10250
|
+
if (trimmed.startsWith("/") || trimmed.startsWith("./") || trimmed.startsWith("../")) {
|
|
10251
|
+
return true;
|
|
10252
|
+
}
|
|
10253
|
+
if (/^data:/i.test(trimmed)) {
|
|
10254
|
+
return /^data:image\/(?!svg\+xml)/i.test(trimmed);
|
|
10255
|
+
}
|
|
10256
|
+
try {
|
|
10257
|
+
const { protocol } = new URL(trimmed);
|
|
10258
|
+
return protocol === "http:" || protocol === "https:" || protocol === "blob:";
|
|
10259
|
+
} catch {
|
|
10260
|
+
return false;
|
|
10261
|
+
}
|
|
10262
|
+
}
|
|
10248
10263
|
const normalizedImages = vue.computed(() => {
|
|
10249
10264
|
const images = getProps.value.images || [];
|
|
10250
10265
|
if (!Array.isArray(images) || images.length === 0) {
|
|
10251
10266
|
return [];
|
|
10252
10267
|
}
|
|
10253
10268
|
return images.map((item) => {
|
|
10254
|
-
|
|
10255
|
-
|
|
10269
|
+
const normalized = typeof item === "string" ? { url: item } : item;
|
|
10270
|
+
if (!isSafeImageUrl(normalized.url)) {
|
|
10271
|
+
return { ...normalized, url: "" };
|
|
10256
10272
|
}
|
|
10257
|
-
return
|
|
10273
|
+
return normalized;
|
|
10258
10274
|
});
|
|
10259
10275
|
});
|
|
10276
|
+
const safeErrorImage = vue.computed(() => {
|
|
10277
|
+
const url = getProps.value.errorImage;
|
|
10278
|
+
if (!url || !isSafeImageUrl(url)) return void 0;
|
|
10279
|
+
return url;
|
|
10280
|
+
});
|
|
10260
10281
|
const gridStyle = vue.computed(() => {
|
|
10282
|
+
const rawGap = getProps.value.gap ?? 8;
|
|
10283
|
+
const gap = Number.isFinite(rawGap) ? Math.max(0, rawGap) : 8;
|
|
10261
10284
|
return {
|
|
10262
|
-
gap: `${
|
|
10285
|
+
gap: `${gap}px`
|
|
10263
10286
|
};
|
|
10264
10287
|
});
|
|
10265
10288
|
const handleImageClick = (item, index) => {
|
|
@@ -10267,6 +10290,9 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
|
|
|
10267
10290
|
return;
|
|
10268
10291
|
}
|
|
10269
10292
|
emit("click", item, index);
|
|
10293
|
+
if (getProps.value.preview) {
|
|
10294
|
+
emit("preview", item, index);
|
|
10295
|
+
}
|
|
10270
10296
|
};
|
|
10271
10297
|
const getImages = () => {
|
|
10272
10298
|
return normalizedImages.value;
|
|
@@ -10286,41 +10312,52 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
|
|
|
10286
10312
|
getProps: getPropsValue,
|
|
10287
10313
|
setProps
|
|
10288
10314
|
};
|
|
10289
|
-
vue.watch(
|
|
10290
|
-
() => props,
|
|
10291
|
-
() => {
|
|
10292
|
-
},
|
|
10293
|
-
{ deep: true }
|
|
10294
|
-
);
|
|
10295
10315
|
vue.onMounted(() => {
|
|
10296
10316
|
emit("register", methods);
|
|
10297
10317
|
});
|
|
10298
10318
|
__expose(methods);
|
|
10299
10319
|
return (_ctx, _cache) => {
|
|
10300
|
-
return vue.openBlock(), vue.createElementBlock("div",
|
|
10301
|
-
|
|
10320
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
10321
|
+
class: vue.normalizeClass(["basic-image", { "basic-image--disabled": getProps.value.disabled }])
|
|
10322
|
+
}, [
|
|
10323
|
+
normalizedImages.value.length === 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
|
|
10302
10324
|
vue.renderSlot(_ctx.$slots, "empty", {}, () => [
|
|
10303
|
-
vue.createElementVNode("span",
|
|
10325
|
+
vue.createElementVNode("span", _hoisted_2$1, vue.toDisplayString(getProps.value.emptyText), 1)
|
|
10304
10326
|
], true)
|
|
10305
10327
|
])) : (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(getProps.value.preview ? vue.unref(ArcoVue.ImagePreviewGroup) : "div"), { key: 1 }, {
|
|
10306
10328
|
default: vue.withCtx(() => [
|
|
10307
|
-
!getProps.value.showAll ? (vue.openBlock(), vue.createElementBlock("div",
|
|
10308
|
-
vue.createElementVNode("div",
|
|
10329
|
+
!getProps.value.showAll ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$1, [
|
|
10330
|
+
vue.createElementVNode("div", _hoisted_4, [
|
|
10309
10331
|
vue.createVNode(vue.unref(ArcoVue.Image), {
|
|
10310
10332
|
src: normalizedImages.value[0].url,
|
|
10311
10333
|
width: getProps.value.width,
|
|
10312
10334
|
height: getProps.value.height,
|
|
10313
10335
|
fit: getProps.value.fit,
|
|
10314
10336
|
preview: getProps.value.preview,
|
|
10337
|
+
"show-loader": getProps.value.loading,
|
|
10315
10338
|
alt: normalizedImages.value[0].name || "图片",
|
|
10316
10339
|
onClick: _cache[0] || (_cache[0] = ($event) => handleImageClick(normalizedImages.value[0], 0))
|
|
10317
|
-
},
|
|
10318
|
-
|
|
10340
|
+
}, vue.createSlots({ _: 2 }, [
|
|
10341
|
+
safeErrorImage.value ? {
|
|
10342
|
+
name: "error",
|
|
10343
|
+
fn: vue.withCtx(() => [
|
|
10344
|
+
vue.createElementVNode("img", {
|
|
10345
|
+
src: safeErrorImage.value,
|
|
10346
|
+
width: getProps.value.width,
|
|
10347
|
+
height: getProps.value.height,
|
|
10348
|
+
style: vue.normalizeStyle({ display: "block", objectFit: getProps.value.fit }),
|
|
10349
|
+
alt: normalizedImages.value[0].name || "图片"
|
|
10350
|
+
}, null, 12, _hoisted_5)
|
|
10351
|
+
]),
|
|
10352
|
+
key: "0"
|
|
10353
|
+
} : void 0
|
|
10354
|
+
]), 1032, ["src", "width", "height", "fit", "preview", "show-loader", "alt"]),
|
|
10355
|
+
normalizedImages.value.length > (getProps.value.maxCount ?? 1) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_6, " +" + vue.toDisplayString(normalizedImages.value.length - (getProps.value.maxCount ?? 1)), 1)) : vue.createCommentVNode("", true)
|
|
10319
10356
|
]),
|
|
10320
|
-
getProps.value.preview && normalizedImages.value.length > 1 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7, [
|
|
10321
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(normalizedImages.value.slice(1), (item, index) => {
|
|
10357
|
+
getProps.value.preview && normalizedImages.value.length > (getProps.value.maxCount ?? 1) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7, [
|
|
10358
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(normalizedImages.value.slice(getProps.value.maxCount ?? 1), (item, index) => {
|
|
10322
10359
|
return vue.openBlock(), vue.createBlock(vue.unref(ArcoVue.Image), {
|
|
10323
|
-
key: index
|
|
10360
|
+
key: `${item.url}-${index}`,
|
|
10324
10361
|
src: item.url,
|
|
10325
10362
|
alt: item.name || "图片"
|
|
10326
10363
|
}, null, 8, ["src", "alt"]);
|
|
@@ -10333,7 +10370,7 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
|
|
|
10333
10370
|
}, [
|
|
10334
10371
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(normalizedImages.value, (item, index) => {
|
|
10335
10372
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
10336
|
-
key: index
|
|
10373
|
+
key: `${item.url}-${index}`,
|
|
10337
10374
|
class: "image-item"
|
|
10338
10375
|
}, [
|
|
10339
10376
|
vue.createVNode(vue.unref(ArcoVue.Image), {
|
|
@@ -10342,33 +10379,46 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
|
|
|
10342
10379
|
height: getProps.value.height,
|
|
10343
10380
|
fit: getProps.value.fit,
|
|
10344
10381
|
preview: getProps.value.preview,
|
|
10382
|
+
"show-loader": getProps.value.loading,
|
|
10345
10383
|
alt: item.name || "图片",
|
|
10346
10384
|
onClick: ($event) => handleImageClick(item, index)
|
|
10347
|
-
},
|
|
10385
|
+
}, vue.createSlots({ _: 2 }, [
|
|
10386
|
+
safeErrorImage.value ? {
|
|
10387
|
+
name: "error",
|
|
10388
|
+
fn: vue.withCtx(() => [
|
|
10389
|
+
vue.createElementVNode("img", {
|
|
10390
|
+
src: safeErrorImage.value,
|
|
10391
|
+
width: getProps.value.width,
|
|
10392
|
+
height: getProps.value.height,
|
|
10393
|
+
style: vue.normalizeStyle({ display: "block", objectFit: getProps.value.fit }),
|
|
10394
|
+
alt: item.name || "图片"
|
|
10395
|
+
}, null, 12, _hoisted_8)
|
|
10396
|
+
]),
|
|
10397
|
+
key: "0"
|
|
10398
|
+
} : void 0
|
|
10399
|
+
]), 1032, ["src", "width", "height", "fit", "preview", "show-loader", "alt", "onClick"])
|
|
10348
10400
|
]);
|
|
10349
10401
|
}), 128))
|
|
10350
10402
|
], 4))
|
|
10351
10403
|
]),
|
|
10352
10404
|
_: 1
|
|
10353
10405
|
}))
|
|
10354
|
-
]);
|
|
10406
|
+
], 2);
|
|
10355
10407
|
};
|
|
10356
10408
|
}
|
|
10357
10409
|
});
|
|
10358
|
-
const BasicImage = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-
|
|
10410
|
+
const BasicImage = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-71d2eff3"]]);
|
|
10359
10411
|
function useImage(options) {
|
|
10360
10412
|
const imageRef = vue.ref(null);
|
|
10361
10413
|
const loadedRef = vue.ref(false);
|
|
10362
10414
|
const register = (instance) => {
|
|
10363
|
-
if (
|
|
10415
|
+
if (instance === vue.unref(imageRef)) {
|
|
10364
10416
|
return;
|
|
10365
10417
|
}
|
|
10366
10418
|
imageRef.value = instance;
|
|
10367
10419
|
loadedRef.value = true;
|
|
10368
10420
|
if (options) {
|
|
10369
|
-
|
|
10370
|
-
instance.setProps(options);
|
|
10371
|
-
});
|
|
10421
|
+
instance.setProps(options);
|
|
10372
10422
|
}
|
|
10373
10423
|
};
|
|
10374
10424
|
const getInstance = () => {
|