修改驾驶舱zoom缩放问题

This commit is contained in:
guanj
2025-12-04 09:37:38 +08:00
parent 5db43cd4b1
commit b8ee530557
3 changed files with 16 additions and 13 deletions

View File

@@ -16,7 +16,6 @@
<el-button type="primary" icon="el-icon-Tools" @click="settings">设置</el-button>
</template>
</TableHeader>
<GridLayout
v-model:layout="layout"
:row-height="rowHeight"
@@ -26,6 +25,7 @@
:vertical-compact="false"
prevent-collision
:col-num="12"
:style="{ zoom: zoom }"
>
<template #item="{ item }">
<div class="box">
@@ -34,8 +34,8 @@
<Icon class="HelpFilled" :name="(item as LayoutItem).icon" />
{{ (item as LayoutItem).name }}
</div>
<!-- <FullScreen class="HelpFilled" style="cursor: pointer" @click="zoom(item)" /> -->
<img :src="flag ? img : img1" style="cursor: pointer; height: 16px" @click="zoom(item)" />
<!-- <FullScreen class="HelpFilled" style="cursor: pointer" @click="setZoom(item)" /> -->
<img :src="flag ? img : img1" style="cursor: pointer; height: 16px" @click="setZoom(item)" />
</div>
<div>
<component
@@ -80,6 +80,7 @@ const timeCacheStore = useTimeCacheStore()
defineOptions({
// name: 'dashboard/index'
})
// 定义类型
interface LayoutItem {
x: number
@@ -95,6 +96,7 @@ interface LayoutItem {
loading?: boolean
error?: any
}
const zoom = ref(1)
const RoutingConfigRef = ref()
const key = ref(0)
const img = new URL(`@/assets/img/amplify.png`, import.meta.url).href
@@ -120,13 +122,15 @@ const componentMap = reactive(new Map<string, Component | string>())
const dataList: any = ref({})
// 获取主内容区域高度
const getMainHeight = () => {
const elMain = document.querySelector('.el-main')
return (elMain?.offsetHeight || 0) - 70
const elMain = document.querySelector('.el-main') as HTMLElement | null
zoom.value = layout.value.length==1?1: (elMain?.offsetHeight ?? 0) / 1080
// console.log('🚀 ~ getMainHeight ~ elMain:', elMain?.offsetHeight)
return ((elMain?.offsetHeight || 0) - 70) / zoom.value
}
// 获取主内容区域高度
const getMainWidth = () => {
const elMain = document.querySelector('.el-main')
return (elMain?.offsetWidth || 0) - 20
const elMain = document.querySelector('.el-main') as HTMLElement | null
return ((elMain?.offsetWidth || 0) - 20) / zoom.value
}
// 初始化行高
@@ -170,8 +174,9 @@ const registerComponent = (path: string): Component | string | null => {
return null
}
}
// 缩放
const zoom = (value: any) => {
const setZoom = (value: any) => {
if (flag.value) {
layout.value = [{ ...value, x: 0, y: 0, w: 12, h: 6 }]
} else {
@@ -181,7 +186,6 @@ const zoom = (value: any) => {
component: registerComponent(item.path)
}))
}
console.log("🚀 ~ zoom ~ layout.value:", layout.value)
flag.value = !flag.value