From 356dcf4fa51b226463fd80d5bc625ac94bd7b1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=90=A6?= Date: Mon, 19 Jan 2026 21:19:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/InquiryModal.vue | 4 +- client/src/components/SnippetModal.vue | 12 +- .../admin/AttachmentDetailModal.vue | 4 +- .../admin/AttachmentLibraryModal.vue | 297 ++++++++++++++++++ client/src/components/admin/ImageUpload.vue | 66 ++++ .../components/admin/PostRelationModal.vue | 4 +- client/src/pages/Home.vue | 2 +- client/src/pages/WorkDetail.vue | 43 ++- client/src/pages/Works.vue | 33 ++ client/src/services/api.ts | 42 ++- server/nl_blog.sql | 95 ++++-- ...NbjCmbBatx3S4t6958b017537b6_1768828219.jpg | Bin 0 -> 104725 bytes ...NbjCmbBatx3S4t6958b017537b6_1768828707.jpg | Bin 0 -> 104725 bytes ...7ls1spvgI0uDk56958b02daaf14_1768828219.jpg | Bin 0 -> 305101 bytes 14 files changed, 557 insertions(+), 45 deletions(-) create mode 100644 client/src/components/admin/AttachmentLibraryModal.vue create mode 100644 server/uploads/2026/01/19/cc_upload_7BNbjCmbBatx3S4t6958b017537b6_1768828219.jpg create mode 100644 server/uploads/2026/01/19/cc_upload_7BNbjCmbBatx3S4t6958b017537b6_1768828707.jpg create mode 100644 server/uploads/2026/01/19/cc_upload_P17ls1spvgI0uDk56958b02daaf14_1768828219.jpg diff --git a/client/src/components/InquiryModal.vue b/client/src/components/InquiryModal.vue index e001446..57095cb 100644 --- a/client/src/components/InquiryModal.vue +++ b/client/src/components/InquiryModal.vue @@ -1,5 +1,6 @@ + diff --git a/client/src/components/admin/ImageUpload.vue b/client/src/components/admin/ImageUpload.vue index f157c85..f40c709 100644 --- a/client/src/components/admin/ImageUpload.vue +++ b/client/src/components/admin/ImageUpload.vue @@ -37,6 +37,18 @@ + +
+ +
+
Preview
@@ -132,6 +144,18 @@

+ + +
+ +
@@ -147,6 +171,16 @@
+ + + @@ -154,6 +188,7 @@ import { ref, watch, computed } from 'vue' import { useToast } from '../../composables/useToast' import { API_BASE } from '../../services/api' +import AttachmentLibraryModal from './AttachmentLibraryModal.vue' const props = withDefaults(defineProps<{ modelValue?: string | string[] @@ -177,6 +212,7 @@ const uploading = ref(false) const uploadingCount = ref(0) const error = ref('') const isDragging = ref(false) +const showLibraryModal = ref(false) const toast = useToast() @@ -365,6 +401,36 @@ const removeImage = (index?: number) => { } } } + +const openLibraryModal = () => { + if (props.disabled) return + showLibraryModal.value = true +} + +const handleLibrarySelect = (urls: string[]) => { + if (props.multiple) { + // 批量模式:添加选中的图片,考虑maxCount限制 + const currentCount = imageUrls.value.length + const remainingCount = props.maxCount ? props.maxCount - currentCount : Infinity + const urlsToAdd = urls.slice(0, remainingCount) + + if (urlsToAdd.length > 0) { + const newUrls = [...imageUrls.value, ...urlsToAdd] + imageUrls.value = newUrls + toast.showToast(`已添加 ${urlsToAdd.length} 张图片`, 'success') + } + + if (urls.length > urlsToAdd.length) { + toast.showToast(`最多只能添加 ${props.maxCount} 张图片,已添加 ${urlsToAdd.length} 张`, 'error') + } + } else { + // 单个模式:直接设置选中的第一张图片 + if (urls.length > 0) { + imageUrl.value = urls[0] + toast.showToast('图片选择成功', 'success') + } + } +}