diff --git a/src/components/about/Map.vue b/src/components/about/Map.vue
index 08d9da5..5cdc491 100644
--- a/src/components/about/Map.vue
+++ b/src/components/about/Map.vue
@@ -75,7 +75,7 @@ watch(() => props.zoom, (newZoom) => {
onBeforeUnmount(() => {
if (map.value) {
map.value.clearOverlays();
- map.value.removeEventListener();
+ // map.value.removeEventListener();
map.value = null;
}
});
@@ -106,9 +106,28 @@ defineExpose({
-
+
diff --git a/src/utils/function.js b/src/utils/function.js
index 4eab3e1..490244d 100644
--- a/src/utils/function.js
+++ b/src/utils/function.js
@@ -1,15 +1,42 @@
+// 导出获取图片URL的函数
export const getImageUrl = (path) => {
- // 如果是绝对URL,直接返回
+ // 如果path不存在或不是字符串,直接返回空字符串
+ if (!path || typeof path !== 'string') {
+ console.error('getImageUrl: path 参数无效或为空', path);
+ return '';
+ }
+
+ // 如果是绝对URL(http://或https://开头),直接返回
if (path.startsWith('http://') || path.startsWith('https://')) {
- return path
+ return path;
}
// 否则处理为本地资源
+ // 使用Vite支持的动态导入方式
try {
- // return new URL(`/src/assets/${path}`, import.meta.url).href
- return `/src/assets/${path}`
+ // 根据不同的图片路径,返回对应的导入URL
+ // 注意:这种方式需要为每个图片路径单独添加映射
+ // 您可以根据实际需要扩展这个映射表
+ const imageMap = {
+ 'img/honor1.png': new URL('../assets/img/honor1.png', import.meta.url).href,
+ 'img/honor2.png': new URL('../assets/img/honor2.png', import.meta.url).href,
+ 'img/honor3.png': new URL('../assets/img/honor3.png', import.meta.url).href,
+ 'img/dynamic1.png': new URL('../assets/img/dynamic1.png', import.meta.url).href,
+ 'img/dynamic2.png': new URL('../assets/img/dynamic2.png', import.meta.url).href,
+ // 可以根据需要添加更多图片路径映射
+ };
+
+ // 如果找到对应的映射,返回映射的URL
+ if (imageMap[path]) {
+ return imageMap[path];
+ } else {
+ // 如果没有找到映射,尝试使用默认方式
+ console.warn('图片路径未在映射表中找到:', path);
+ return new URL(`../assets/${path}`, import.meta.url).href;
+ }
} catch (error) {
- console.error('图片加载失败:', error)
- return ''
+ // 如果构建失败,打印错误信息并返回空字符串
+ console.error('图片加载失败:', error, '路径:', path);
+ return '';
}
}
diff --git a/src/views/AboutUs.vue b/src/views/AboutUs.vue
index b27a1f8..b91deb0 100644
--- a/src/views/AboutUs.vue
+++ b/src/views/AboutUs.vue
@@ -1,11 +1,14 @@