From 16425e5c62f3e65a0e529d7c0ab851fa49b88ef0 Mon Sep 17 00:00:00 2001
From: lsh <lsh@163.com>
Date: 星期一, 18 八月 2025 18:32:19 +0800
Subject: [PATCH] *
---
src/main/webapp/views/index.html | 124 +++++++++++++++++++++++++++++++---------
1 files changed, 95 insertions(+), 29 deletions(-)
diff --git a/src/main/webapp/views/index.html b/src/main/webapp/views/index.html
index b2aeede..c0cb1c5 100644
--- a/src/main/webapp/views/index.html
+++ b/src/main/webapp/views/index.html
@@ -35,7 +35,7 @@
.map {
position: relative;
width: 52vw;
- height: 80vh;
+ height: 72vh;
border-radius: 50%;
display: flex;
justify-content: center;
@@ -163,7 +163,7 @@
background: #f0f9eb;
}
.container {
- width: 100vh;
+ width: 52vw;
height: 72vh;
position: absolute;
/*background: #8c939d;*/
@@ -204,7 +204,7 @@
}
</style>
</head>
-<body>
+<body id="app1">
<!--<header>-->
<!-- 鐜舰绌挎杞︽櫤鑳界郴缁�-->
<!--</header>-->
@@ -217,19 +217,9 @@
<!-- <div class="outer-ring"></div>-->
<!-- <div v-for="track in energyGatheringRing" class="inner-ring" :style="{ borderColor: track.trackColor , boxShadow : 'inset 0 0 30px '+track.radiationColor+', 0 0 20px '+track.radiationColor}"></div>-->
<!-- <div v-for="track in energyGatheringRing" class="outer-ring" :style="{ borderColor: track.trackColor , boxShadow : 'inset 0 0 30px '+track.radiationColor+', 0 0 20px '+track.radiationColor}"></div>-->
- <svg class="container">
-<!-- <path d="M 100,250-->
-<!-- L 100,800-->
-<!-- C 100,800 100,850 150,850-->
-<!-- C 150,850 200,850 200,800-->
-<!-- L 200,250-->
-<!-- C 200,250 200,200 250,200-->
-<!-- L 1100,200-->
-<!-- C 1100,200 1150,200 1150,150-->
-<!-- C 1150,150 1150,100 1100,100-->
-<!-- L 250,100-->
-<!-- C 250,100 90,90 100,250 z"-->
-<!-- style="fill:none; stroke:blue; stroke-width:4;" />-->
+ <svg class="container"
+ viewBox="0 0 1200 850"
+ preserveAspectRatio="xMidYMid meet">
<path d="M 1200,750
L 1200,100
C 1200,100 1200,50 1150,50
@@ -244,17 +234,11 @@
"
style="fill:none; stroke:blue; stroke-width:4;" />
</svg>
-<!-- <div class="bus-station">-->
-<!-- <div v-for="(item,i) in devpPos1" class="bus-item-top" :style="'left:' + (75 + i * 15) + 'px'">{{item.dev_no}}</div>-->
-<!-- </div>-->
-<!-- <div class="bus-station" style="flex-direction: column">-->
-<!-- <div v-for="(item,i) in devpPos2" class="bus-item-left" :style="'top:' + (200 + i * 50) + 'px'">{{item.dev_no}}</div>-->
-<!-- </div>-->
-<!-- <div class="bus-station" style="flex-direction: column">-->
-<!-- <div v-for="(item,i) in devpPos3" class="bus-item-left2" :style="'top:' + (100 + i * 10) + 'px'">{{item.dev_no}}</div>-->
-<!-- </div>-->
-<!-- Stations on outer ring-->
- <div v-for="station in tableDataDev" class="station" :style="{ top: station.valueY + 'px', left: station.valueX + 'px' }">{{ station.index }}</div>
+<!-- <div v-for="station in tableDataDev" class="station" :style="{ top: station.valueY + 'px', left: station.valueX + 'px' , backgroundColor: station.modeColor}">{{ station.index }}</div>-->
+ <div v-for="station in tableDataDev" class="station" :style="{
+ top: convertToCSSPosition(station.valueX, station.valueY).y + 'px',
+ left: convertToCSSPosition(station.valueX, station.valueY).x + 'px',
+ backgroundColor: station.modeColor}">{{ station.index }}</div>
<div>
<el-switch
style="display: block"
@@ -267,7 +251,11 @@
</el-switch>
</div>
<!-- Buses -->
- <div v-for="bus in tableDataRgv" class="bus" :style="{ top: bus.valueY + 'px', left: bus.valueX + 'px' , borderColor: bus.modeColor, backgroundColor: bus.statusColor}">{{ bus.index }}</div>
+<!-- <div v-for="bus in tableDataRgv" class="bus" :style="{ top: bus.valueY + 'px', left: bus.valueX + 'px' , borderColor: bus.modeColor, backgroundColor: bus.statusColor}">{{ bus.index }}</div>-->
+ <div v-for="bus in tableDataRgv" class="bus" :style="{
+ top: convertToCSSPosition(bus.valueX, bus.valueY).y + 'px',
+ left: convertToCSSPosition(bus.valueX, bus.valueY).x + 'px',
+ borderColor: bus.modeColor, backgroundColor: bus.statusColor}">{{ bus.index }}</div>
</div>
<!-- Left Task Bar -->
@@ -477,9 +465,18 @@
</div>
<script>
+ // 鍦╒ue瀹炰緥澶栬幏鍙朾ody灏哄
+ function getBodySize() {
+ return {
+ width: document.body.clientWidth,
+ height: document.body.clientHeight
+ };
+ }
var app = new Vue({
el: '#app',
data: {
+ containerSize: { width: 0, height: 0},
+ bodySize: { width: 0, height: 0 },
activeNames: ['1'],
valueLeft: '0',
valueLeft1: '0',
@@ -543,6 +540,24 @@
watch: {
},
+
+ // 鍦� mounted 涓垵濮嬪寲灏哄鍜岀洃鍚�
+ mounted() {
+ this.updateContainerSize();
+ this.updateBodySize();
+ window.addEventListener('resize', this.handleResize);
+ },
+ beforeDestroy() {
+ window.removeEventListener('resize', this.handleResize);
+ },
+ computed: {
+ mappedStations() {
+ return this.tableDataDev.map(station => ({
+ ...station,
+ position: this.convertToCSSPosition(station.valueX, station.valueY)
+ }));
+ }
+ },
methods: {
init(){
this.getTableDataRgv()
@@ -569,6 +584,52 @@
}, 1000)
},
+ // 鑾峰彇瀹瑰櫒瀹為檯灏哄
+ updateContainerSize() {
+ const mapEl = this.$el.querySelector('.map');
+ this.containerSize = {
+ width: mapEl.clientWidth,
+ height: mapEl.clientHeight
+ };
+ },
+
+ // 鏇存柊body灏哄
+ updateBodySize() {
+ this.bodySize = getBodySize();
+ },
+
+ // 鍧愭爣杞崲鍑芥暟
+ convertToCSSPosition(svgX, svgY) {
+ const svgWidth = 1200; // SVG 鍘熷瀹藉害
+ let svgWidthR = 0; //
+ const svgHeight = 850; // SVG 鍘熷楂樺害
+ let svgHeightR = 0; //
+ if (svgX>svgWidth/2){
+ svgWidthR = (((svgX-svgWidth/2)/svgWidth) * this.containerSize.width) + this.bodySize.width/2 - this.bodySize.width*((1-0.52)/2);
+ } else {
+ svgWidthR = this.bodySize.width/2 - (((svgWidth/2 - svgX)/svgWidth) * this.containerSize.width) - this.bodySize.width*((1-0.52)/2);
+ }
+ if (svgY>svgHeight/2){
+ svgHeightR = (((svgY-svgHeight/2)/svgHeight) * this.containerSize.height) + this.bodySize.height/2 - this.bodySize.height*((1-0.72)/2);
+ } else {
+ svgHeightR = this.bodySize.height/2 - (((svgHeight/2 - svgY)/svgHeight) * this.containerSize.height) - this.bodySize.height*((1-0.72)/2);
+ }
+ return {
+ x: svgWidthR,
+ y: svgHeightR
+ };
+ },
+
+ handleZoom(e) {
+ const scaleDelta = e.deltaY > 0 ? 0.9 : 1.1;
+ const currentScale = this.scale || 1;
+ const newScale = Math.max(0.5, Math.min(2, currentScale * scaleDelta));
+
+ // 搴旂敤缂╂斁
+ const svgEl = this.$el.querySelector('.container');
+ svgEl.style.transform = `scale(${newScale})`;
+ this.scale = newScale;
+ },
verifyPassword(callback) {
this.$prompt('璇疯緭鍏ョ鐞嗗憳瀵嗙爜: root', '楠岃瘉', {
confirmButtonText: '纭畾',
@@ -877,7 +938,12 @@
that.energyGatheringRing = res.data
}
});
- }
+ },
+ // 澶勭悊绐楀彛澶у皬鍙樺寲
+ handleResize: _.debounce(function() {
+ this.updateContainerSize();
+ this.updateBodySize();
+ }, 100)
}
})
--
Gitblit v1.9.1