From ca14ea140ff12f2f48f78ac47f40e3770c5c81cc Mon Sep 17 00:00:00 2001 From: huliyong <2783385703@qq.com> Date: Thu, 18 Sep 2025 22:45:16 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E9=A1=B5=E9=9D=A2):=20=E9=87=8D=E6=9E=84=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E5=92=8C=E8=A7=86=E9=A2=91=E4=B8=8A=E4=BC=A0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用JImageUpload和JUpload组件替换原有的a-upload实现 移除不必要的文件上传前处理逻辑和状态管理 简化图片和视频上传处理函数 --- .../applet/course-page/AppletCoursePageList.vue | 87 +++++++--------------- 1 file changed, 26 insertions(+), 61 deletions(-) diff --git a/jeecgboot-vue3/src/views/applet/course-page/AppletCoursePageList.vue b/jeecgboot-vue3/src/views/applet/course-page/AppletCoursePageList.vue index 9055b29..4ef457e 100644 --- a/jeecgboot-vue3/src/views/applet/course-page/AppletCoursePageList.vue +++ b/jeecgboot-vue3/src/views/applet/course-page/AppletCoursePageList.vue @@ -27,9 +27,9 @@
-
+
{{ page.title || `${index + 1}` }}
@@ -114,17 +114,15 @@
- -
- uploaded -
-
- -
上传图片
-
-
+
@@ -137,15 +135,13 @@
- - - - - 上传视频 - - +
@@ -250,6 +246,7 @@ import { ref, reactive, computed, unref, onMounted, watch } from 'vue'; import { useRoute, useRouter } from 'vue-router'; import { useMessage } from '/@/hooks/web/useMessage'; import { Icon } from '/@/components/Icon'; +import { JImageUpload, JUpload } from '/@/components/Form'; import { saveOrUpdate, getById, list, deleteOne, add, edit } from './AppletCoursePage.api'; import { initDictOptions } from '/@/utils/dict/JDictSelectUtil'; @@ -596,8 +593,7 @@ function addImageContent() { contentComponents.value.push({ type: 'image', imageUrl: '', - alt: '', - fileList: [] + alt: '' }); } @@ -607,8 +603,7 @@ function addImageContent() { function addVideoContent() { contentComponents.value.push({ type: 'video', - url: '', - fileList: [] + url: '' }); } @@ -619,49 +614,19 @@ function removeComponent(index: number) { contentComponents.value.splice(index, 1); } -/** - * 文件上传前处理 - */ -function beforeUpload(file: any) { - const isImage = file.type.indexOf('image/') === 0; - const isVideo = file.type.indexOf('video/') === 0; - - if (!isImage && !isVideo) { - createMessage.error('只能上传图片或视频文件!'); - return false; - } - - const isLt10M = file.size / 1024 / 1024 < 10; - if (!isLt10M) { - createMessage.error('文件大小不能超过 10MB!'); - return false; - } - - return true; -} - /** * 图片上传变化处理 */ -function handleImageChange(info: any, component: any) { - if (info.file.status === 'done') { - // 这里应该从服务器响应中获取图片URL - component.imageUrl = info.file.response?.url || URL.createObjectURL(info.file.originFileObj); - } else if (info.file.status === 'error') { - createMessage.error('图片上传失败'); - } +function handleImageChange(value: string, component: any) { + // JImageUpload组件直接返回图片URL字符串 + component.imageUrl = value; } /** * 视频上传变化处理 */ -function handleVideoChange(info: any, component: any) { - if (info.file.status === 'done') { - // 这里应该从服务器响应中获取视频URL - component.url = info.file.response?.url || URL.createObjectURL(info.file.originFileObj); - } else if (info.file.status === 'error') { - createMessage.error('视频上传失败'); - } +function handleVideoChange(value: string, component: any) { + component.url = value; } /**