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