diff --git a/src/assets/img/default_doc.png b/src/assets/img/default_doc.png new file mode 100644 index 0000000..256a29d Binary files /dev/null and b/src/assets/img/default_doc.png differ diff --git a/src/views/healthConsultation/components/healthContentMiddle.vue b/src/views/healthConsultation/components/healthContentMiddle.vue index 536a137..0bb68dc 100644 --- a/src/views/healthConsultation/components/healthContentMiddle.vue +++ b/src/views/healthConsultation/components/healthContentMiddle.vue @@ -11,7 +11,7 @@
- +
@@ -42,7 +42,8 @@ import SwiperCore from 'swiper'; import { Autoplay, Navigation } from 'swiper/modules'; // 修改此处导入路径 // import defaultPng from '/@/assets/health/default.png'; - import { Image as AImage } from 'ant-design-vue'; + import defaultAvatar from '/@/assets/img/default_doc.png'; + // import { Image as AImage } from 'ant-design-vue'; import { getDocList } from '/@/views/healthConsultation/api/health'; import { getAppEnvConfig } from '/@/utils/env.ts'; @@ -64,10 +65,15 @@ const { VITE_GLOB_API_URL } = getAppEnvConfig(); function getFileUrl(path?: string) { const GATEWAY_URL = VITE_GLOB_API_URL; - if (!path) return '/@/assets/health/default.png'; // 使用默认图片 + if (!path) return defaultAvatar; return `${GATEWAY_URL}/file/show/${path}`; } + // 图片加载失败时回退到默认头像 + function onImgError(e: Event) { + (e.target as HTMLImageElement).src = defaultAvatar; + } + // 安装 Swiper 模块 SwiperCore.use([Autoplay, Navigation]); interface Doctor {