From 84cad75d6ee589ca6801bc3bb8649da424c2d73f Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期一, 01 六月 2026 11:04:10 +0800
Subject: [PATCH] 兼容问题
---
src/views/systemArchitecture/index.vue | 79 +++++++++++++++++++++++++++------------
1 files changed, 55 insertions(+), 24 deletions(-)
diff --git a/src/views/systemArchitecture/index.vue b/src/views/systemArchitecture/index.vue
index 9bfcb76..6ed31f6 100644
--- a/src/views/systemArchitecture/index.vue
+++ b/src/views/systemArchitecture/index.vue
@@ -1,24 +1,30 @@
<template>
<div class="scale-container">
- <div class="architecture-scaling-container"
- :style="{ transform: `scale(${scaleRatio})` }">
- <div class="architecture-container">
- <div class="header">
- <span class="title-bar"></span>
- <h1 class="title-text">绯荤粺鏋舵瀯鍥�</h1>
- </div>
- <div class="image-wrapper">
- <div class="hotspot-container">
- <img :src="architectureImg"
- alt="绯荤粺鏋舵瀯鍥�"
- class="architecture-img" />
- <!-- 鐑偣鍖哄煙 -->
- <div v-for="spot in hotspots"
- :key="spot.id"
- class="hotspot"
- :style="{ top: spot.top, left: spot.left, width: spot.width, height: spot.height }"
- @click="handleSpotClick(spot)"
- :title="'璺宠浆鑷�: ' + spot.name">
+ <div class="scroll-content"
+ :style="{
+ height: `${designHeight * scaleRatio}px`,
+ width: `${designWidth * scaleRatio}px`
+ }">
+ <div class="architecture-scaling-container"
+ :style="{ transform: `scale(${scaleRatio})` }">
+ <div class="architecture-container">
+ <div class="header">
+ <span class="title-bar"></span>
+ <h1 class="title-text">绯荤粺鏋舵瀯鍥�</h1>
+ </div>
+ <div class="image-wrapper">
+ <div class="hotspot-container">
+ <img :src="architectureImg"
+ alt="绯荤粺鏋舵瀯鍥�"
+ class="architecture-img" />
+ <!-- 鐑偣鍖哄煙 -->
+ <div v-for="spot in hotspots"
+ :key="spot.id"
+ class="hotspot"
+ :style="{ top: spot.top, left: spot.left, width: spot.width, height: spot.height }"
+ @click="handleSpotClick(spot)"
+ :title="'璺宠浆鑷�: ' + spot.name">
+ </div>
</div>
</div>
</div>
@@ -255,16 +261,18 @@
// 鑾峰彇瀹瑰櫒鐨勫疄闄呭昂瀵�
const containerWidth = container.clientWidth;
+ const containerHeight = container.clientHeight;
- if (containerWidth === 0) {
+ if (containerWidth === 0 || containerHeight === 0) {
// 濡傛灉杩樻病娓叉煋鍑烘潵锛屽欢杩熶竴涓嬪啀璁$畻
setTimeout(calculateScale, 100);
return;
}
- // 璁$畻瀹藉害缂╂斁姣斾緥锛屼娇鍏跺缁堝崰婊″搴�
+ // 璁$畻缂╂斁姣斾緥锛屽彇瀹介珮姣斾緥涓殑杈冨ぇ鍊硷紝纭繚濮嬬粓鎾戞弧鏁翠釜瀹瑰櫒
const scaleX = containerWidth / designWidth;
- scaleRatio.value = scaleX;
+ const scaleY = containerHeight / designHeight;
+ scaleRatio.value = Math.max(scaleX, scaleY);
};
// 绐楀彛澶у皬鍙樺寲澶勭悊
@@ -273,6 +281,7 @@
};
// 鐢熷懡鍛ㄦ湡
+ let resizeObserver = null;
onMounted(() => {
// 璁$畻鍒濆缂╂斁姣斾緥
nextTick(() => {
@@ -281,10 +290,22 @@
// 鐩戝惉绐楀彛澶у皬鍙樺寲
window.addEventListener("resize", handleResize);
+
+ // 浣跨敤 ResizeObserver 鐩戝惉瀹瑰櫒灏哄鍙樺寲锛堣В鍐充晶杈规爮鍒囨崲闂锛�
+ const container = document.querySelector(".scale-container");
+ if (container && window.ResizeObserver) {
+ resizeObserver = new ResizeObserver(() => {
+ calculateScale();
+ });
+ resizeObserver.observe(container);
+ }
});
onBeforeUnmount(() => {
window.removeEventListener("resize", handleResize);
+ if (resizeObserver) {
+ resizeObserver.disconnect();
+ }
});
</script>
@@ -294,11 +315,21 @@
width: 100%;
height: calc(100vh - 84px);
background-color: #f5f7fa;
- overflow: hidden;
+ overflow: auto;
+ display: flex;
+ justify-content: center;
+ align-items: flex-start;
+ }
+
+ .scroll-content {
+ position: relative;
+ flex-shrink: 0;
}
.architecture-scaling-container {
- position: relative;
+ position: absolute;
+ top: 0;
+ left: 0;
width: 1920px;
height: 980px;
transform-origin: left top;
--
Gitblit v1.9.3