knt-shared 1.10.7 → 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/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 +79 -81
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +79 -81
- package/dist/index.esm.js.map +1 -1
- package/dist/style.css +67 -67
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -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", {
|
|
@@ -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,
|
|
@@ -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(() => {
|
|
@@ -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);
|