From fdb7fb79b71f7ef10d84a5f4ca7de69cf1bbbf18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=82=96=E6=99=8B=E9=A3=9E?= <378266566@qq.com>
Date: Wed, 19 Nov 2025 11:33:20 +0800
Subject: [PATCH] =?UTF-8?q?fix:svg=E5=92=8C=E8=A1=A8=E6=A0=BC=E9=AB=98?=
=?UTF-8?q?=E5=BA=A6=E8=87=AA=E9=80=82=E5=BA=94?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/测试.svg | 2 +-
.../demo/components/ParameterInfo.vue | 1 -
.../dashboard/demo/components/staticSvg.vue | 2 +-
src/views/dashboard/demo/components/svg.vue | 31 +++++++++++++------
4 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/public/测试.svg b/public/测试.svg
index f898eff..6beb1d0 100644
--- a/public/测试.svg
+++ b/public/测试.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/views/dashboard/demo/components/ParameterInfo.vue b/src/views/dashboard/demo/components/ParameterInfo.vue
index cad2940..285d3b9 100644
--- a/src/views/dashboard/demo/components/ParameterInfo.vue
+++ b/src/views/dashboard/demo/components/ParameterInfo.vue
@@ -89,7 +89,6 @@ onBeforeUpdate(async () => {
-->
diff --git a/src/views/dashboard/demo/components/staticSvg.vue b/src/views/dashboard/demo/components/staticSvg.vue
index f455fb0..b54644c 100644
--- a/src/views/dashboard/demo/components/staticSvg.vue
+++ b/src/views/dashboard/demo/components/staticSvg.vue
@@ -44,6 +44,6 @@ function fullScreen() {
diff --git a/src/views/dashboard/demo/components/svg.vue b/src/views/dashboard/demo/components/svg.vue
index d2d4f3f..21e2856 100644
--- a/src/views/dashboard/demo/components/svg.vue
+++ b/src/views/dashboard/demo/components/svg.vue
@@ -59,9 +59,9 @@ async function loadSvg() {
// 等待DOM更新后应用实时数据
await nextTick()
- document.querySelector('.svg-container > svg')?.removeAttribute('width')
- document.querySelector('.svg-container > svg')?.removeAttribute('height')
-
+ document.querySelector('.svg-container > svg')?.setAttribute('width', '100%')
+ document.querySelector('.svg-container > svg')?.setAttribute('height', '100%')
+ document.querySelector('.svg-container > svg')?.setAttribute('preserveAspectRatio', 'none')
// updateRealtimeValues()
}
catch (error) {
@@ -76,8 +76,10 @@ async function updateRealtimeValues() {
return
try {
const svgElement = document.querySelector('.svg-container > svg')
- svgElement?.removeAttribute('width')
- svgElement?.removeAttribute('height')
+ svgElement?.setAttribute('width', '100%')
+ svgElement?.setAttribute('height', '100%')
+ svgElement?.setAttribute('preserveAspectRatio', 'none')
+
// 获取SVG元素
if (!svgElement)
return
@@ -212,9 +214,12 @@ defineExpose({