diff --git a/src/directives/drag-height/index.ts b/src/directives/drag-height/index.ts index e281ece..f1c3a37 100644 --- a/src/directives/drag-height/index.ts +++ b/src/directives/drag-height/index.ts @@ -8,7 +8,6 @@ if (binding.value) { minHeight = parseInt(binding.value, 10) } - // 拖拽触发元素 const dragItem = document.createElement('div') dragItem.id = 'dragItem-height' @@ -44,6 +43,7 @@ height = minHeight } el.style.height = `${height}px` + window.sessionStorage.setItem('drag-height', String(height)) // 将width赋值到CSS自定义属性 el.style.setProperty('--el-height', `${height}px`) @@ -57,6 +57,7 @@ document.onmouseup = null document.body.style.userSelect = 'auto' isPress = false + window.sessionStorage.removeItem('drag-height') } // 阻止默认行为 return false diff --git a/src/directives/drag-height/index.ts b/src/directives/drag-height/index.ts index e281ece..f1c3a37 100644 --- a/src/directives/drag-height/index.ts +++ b/src/directives/drag-height/index.ts @@ -8,7 +8,6 @@ if (binding.value) { minHeight = parseInt(binding.value, 10) } - // 拖拽触发元素 const dragItem = document.createElement('div') dragItem.id = 'dragItem-height' @@ -44,6 +43,7 @@ height = minHeight } el.style.height = `${height}px` + window.sessionStorage.setItem('drag-height', String(height)) // 将width赋值到CSS自定义属性 el.style.setProperty('--el-height', `${height}px`) @@ -57,6 +57,7 @@ document.onmouseup = null document.body.style.userSelect = 'auto' isPress = false + window.sessionStorage.removeItem('drag-height') } // 阻止默认行为 return false diff --git a/src/views/home/pipeline/index.vue b/src/views/home/pipeline/index.vue index 4449b2e..c11d2e9 100644 --- a/src/views/home/pipeline/index.vue +++ b/src/views/home/pipeline/index.vue @@ -176,10 +176,10 @@ monitorStateList.value = res.data }) } -onMounted(() => { - fetchDict() - fetchData() -}) +// onMounted(() => { +// fetchDict() +// fetchData() +// }) // 切换地图标识 const switchMode = (type: string) => { @@ -260,6 +260,24 @@ window.addEventListener('resize', () => { tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 }) +// 监听地图高度 +const watchMapHeight = () => { + // 创建一个ResizeObserver实例 + const observer = new ResizeObserver((entries: any) => { + for (const entry of entries) { + // 获取div元素的新高度 + const newHeight = entry.contentRect.height + // 执行相应的操作,比如更新UI或调用其他函数 + console.log(`元素新高度为:${newHeight}`) + if (newHeight < 350) { + tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 + (350 - newHeight) + } + } + }) + // 监听目标div元素的宽度变化 + const targetDiv = document.getElementById('map-container-height') as Element + observer.observe(targetDiv) +} watch(() => tableFlag.value, (newVal) => { if (newVal === 'map') { tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 @@ -268,6 +286,11 @@ tableHeight.value = window.innerHeight - 60 - 50 - 10 - 98 - 10 - 52 - 52 - 10 } }) +onMounted(() => { + fetchDict() + fetchData() + watchMapHeight() +}) const { proxy } = getCurrentInstance() as any @@ -275,7 +298,7 @@ -
+
diff --git a/src/directives/drag-height/index.ts b/src/directives/drag-height/index.ts index e281ece..f1c3a37 100644 --- a/src/directives/drag-height/index.ts +++ b/src/directives/drag-height/index.ts @@ -8,7 +8,6 @@ if (binding.value) { minHeight = parseInt(binding.value, 10) } - // 拖拽触发元素 const dragItem = document.createElement('div') dragItem.id = 'dragItem-height' @@ -44,6 +43,7 @@ height = minHeight } el.style.height = `${height}px` + window.sessionStorage.setItem('drag-height', String(height)) // 将width赋值到CSS自定义属性 el.style.setProperty('--el-height', `${height}px`) @@ -57,6 +57,7 @@ document.onmouseup = null document.body.style.userSelect = 'auto' isPress = false + window.sessionStorage.removeItem('drag-height') } // 阻止默认行为 return false diff --git a/src/views/home/pipeline/index.vue b/src/views/home/pipeline/index.vue index 4449b2e..c11d2e9 100644 --- a/src/views/home/pipeline/index.vue +++ b/src/views/home/pipeline/index.vue @@ -176,10 +176,10 @@ monitorStateList.value = res.data }) } -onMounted(() => { - fetchDict() - fetchData() -}) +// onMounted(() => { +// fetchDict() +// fetchData() +// }) // 切换地图标识 const switchMode = (type: string) => { @@ -260,6 +260,24 @@ window.addEventListener('resize', () => { tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 }) +// 监听地图高度 +const watchMapHeight = () => { + // 创建一个ResizeObserver实例 + const observer = new ResizeObserver((entries: any) => { + for (const entry of entries) { + // 获取div元素的新高度 + const newHeight = entry.contentRect.height + // 执行相应的操作,比如更新UI或调用其他函数 + console.log(`元素新高度为:${newHeight}`) + if (newHeight < 350) { + tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 + (350 - newHeight) + } + } + }) + // 监听目标div元素的宽度变化 + const targetDiv = document.getElementById('map-container-height') as Element + observer.observe(targetDiv) +} watch(() => tableFlag.value, (newVal) => { if (newVal === 'map') { tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 @@ -268,6 +286,11 @@ tableHeight.value = window.innerHeight - 60 - 50 - 10 - 98 - 10 - 52 - 52 - 10 } }) +onMounted(() => { + fetchDict() + fetchData() + watchMapHeight() +}) const { proxy } = getCurrentInstance() as any @@ -275,7 +298,7 @@ -
+
diff --git a/src/views/home/station/station/index.vue b/src/views/home/station/station/index.vue index b2c4a93..4ef2ce3 100644 --- a/src/views/home/station/station/index.vue +++ b/src/views/home/station/station/index.vue @@ -141,10 +141,6 @@ monitorStateList.value = res.data }) } -onMounted(() => { - fetchDict() - fetchData() -}) // 切换地图标识 const switchMode = (type: string) => { @@ -185,14 +181,40 @@ window.addEventListener('resize', () => { tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 }) +// 监听地图高度 +const watchMapHeight = () => { + // 创建一个ResizeObserver实例 + const observer = new ResizeObserver((entries: any) => { + for (const entry of entries) { + // 获取div元素的新高度 + const newHeight = entry.contentRect.height + // 执行相应的操作,比如更新UI或调用其他函数 + console.log(`元素新高度为:${newHeight}`) + if (newHeight < 350) { + tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 + (350 - newHeight) + } + } + }) + // 监听目标div元素的宽度变化 + const targetDiv = document.getElementById('map-container-height') as Element + observer.observe(targetDiv) +} watch(() => tableFlag.value, (newVal) => { if (newVal === 'map') { tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 + setTimeout(() => { + watchMapHeight() + }) } else if (newVal === 'normal') { tableHeight.value = window.innerHeight - 60 - 50 - 10 - 98 - 10 - 52 - 52 - 10 } }) +onMounted(() => { + fetchDict() + fetchData() + watchMapHeight() +}) const { proxy } = getCurrentInstance() as any @@ -200,7 +222,7 @@ -
+
diff --git a/src/directives/drag-height/index.ts b/src/directives/drag-height/index.ts index e281ece..f1c3a37 100644 --- a/src/directives/drag-height/index.ts +++ b/src/directives/drag-height/index.ts @@ -8,7 +8,6 @@ if (binding.value) { minHeight = parseInt(binding.value, 10) } - // 拖拽触发元素 const dragItem = document.createElement('div') dragItem.id = 'dragItem-height' @@ -44,6 +43,7 @@ height = minHeight } el.style.height = `${height}px` + window.sessionStorage.setItem('drag-height', String(height)) // 将width赋值到CSS自定义属性 el.style.setProperty('--el-height', `${height}px`) @@ -57,6 +57,7 @@ document.onmouseup = null document.body.style.userSelect = 'auto' isPress = false + window.sessionStorage.removeItem('drag-height') } // 阻止默认行为 return false diff --git a/src/views/home/pipeline/index.vue b/src/views/home/pipeline/index.vue index 4449b2e..c11d2e9 100644 --- a/src/views/home/pipeline/index.vue +++ b/src/views/home/pipeline/index.vue @@ -176,10 +176,10 @@ monitorStateList.value = res.data }) } -onMounted(() => { - fetchDict() - fetchData() -}) +// onMounted(() => { +// fetchDict() +// fetchData() +// }) // 切换地图标识 const switchMode = (type: string) => { @@ -260,6 +260,24 @@ window.addEventListener('resize', () => { tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 }) +// 监听地图高度 +const watchMapHeight = () => { + // 创建一个ResizeObserver实例 + const observer = new ResizeObserver((entries: any) => { + for (const entry of entries) { + // 获取div元素的新高度 + const newHeight = entry.contentRect.height + // 执行相应的操作,比如更新UI或调用其他函数 + console.log(`元素新高度为:${newHeight}`) + if (newHeight < 350) { + tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 + (350 - newHeight) + } + } + }) + // 监听目标div元素的宽度变化 + const targetDiv = document.getElementById('map-container-height') as Element + observer.observe(targetDiv) +} watch(() => tableFlag.value, (newVal) => { if (newVal === 'map') { tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 @@ -268,6 +286,11 @@ tableHeight.value = window.innerHeight - 60 - 50 - 10 - 98 - 10 - 52 - 52 - 10 } }) +onMounted(() => { + fetchDict() + fetchData() + watchMapHeight() +}) const { proxy } = getCurrentInstance() as any @@ -275,7 +298,7 @@ -
+
diff --git a/src/views/home/station/station/index.vue b/src/views/home/station/station/index.vue index b2c4a93..4ef2ce3 100644 --- a/src/views/home/station/station/index.vue +++ b/src/views/home/station/station/index.vue @@ -141,10 +141,6 @@ monitorStateList.value = res.data }) } -onMounted(() => { - fetchDict() - fetchData() -}) // 切换地图标识 const switchMode = (type: string) => { @@ -185,14 +181,40 @@ window.addEventListener('resize', () => { tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 }) +// 监听地图高度 +const watchMapHeight = () => { + // 创建一个ResizeObserver实例 + const observer = new ResizeObserver((entries: any) => { + for (const entry of entries) { + // 获取div元素的新高度 + const newHeight = entry.contentRect.height + // 执行相应的操作,比如更新UI或调用其他函数 + console.log(`元素新高度为:${newHeight}`) + if (newHeight < 350) { + tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 + (350 - newHeight) + } + } + }) + // 监听目标div元素的宽度变化 + const targetDiv = document.getElementById('map-container-height') as Element + observer.observe(targetDiv) +} watch(() => tableFlag.value, (newVal) => { if (newVal === 'map') { tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 + setTimeout(() => { + watchMapHeight() + }) } else if (newVal === 'normal') { tableHeight.value = window.innerHeight - 60 - 50 - 10 - 98 - 10 - 52 - 52 - 10 } }) +onMounted(() => { + fetchDict() + fetchData() + watchMapHeight() +}) const { proxy } = getCurrentInstance() as any @@ -200,7 +222,7 @@ -
+
diff --git a/src/views/home/well/index.vue b/src/views/home/well/index.vue index 3d0f05c..2c14e7a 100644 --- a/src/views/home/well/index.vue +++ b/src/views/home/well/index.vue @@ -154,11 +154,6 @@ monitorStateList.value = res.data }) } -onMounted(() => { - fetchDict() - fetchData() -}) - // 切换地图标识 const switchMode = (type: string) => { // if (!mapList.value.length) { @@ -217,14 +212,41 @@ window.addEventListener('resize', () => { tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 }) +// 监听地图高度 +const watchMapHeight = () => { + // 创建一个ResizeObserver实例 + const observer = new ResizeObserver((entries: any) => { + for (const entry of entries) { + // 获取div元素的新高度 + const newHeight = entry.contentRect.height + // 执行相应的操作,比如更新UI或调用其他函数 + console.log(`元素新高度为:${newHeight}`) + if (newHeight < 350) { + tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 + (350 - newHeight) + } + } + }) + // 监听目标div元素的宽度变化 + const targetDiv = document.getElementById('map-container-height') as Element + observer.observe(targetDiv) +} + watch(() => tableFlag.value, (newVal) => { if (newVal === 'map') { tableHeight.value = window.innerHeight - 60 - 50 - 10 - 350 - 98 - 10 - 52 - 52 - 10 + setTimeout(() => { + watchMapHeight() + }) } else if (newVal === 'normal') { tableHeight.value = window.innerHeight - 60 - 50 - 10 - 98 - 10 - 52 - 52 - 10 } }) +onMounted(() => { + fetchDict() + fetchData() + watchMapHeight() +}) const { proxy } = getCurrentInstance() as any @@ -232,7 +254,7 @@ -
+