浏览代码

fix🐛: 修复测试问题

gitboyzcf 5 天之前
父节点
当前提交
74b529f22b

+ 8 - 0
src/api/modules/mr.js

@@ -3,6 +3,14 @@ import { request } from '@/api/request.js'
 
 const noMr = import.meta.env.VITE_APP_API_BASEURL.split('api')[0]
 export default {
+  // 模拟IV获取权限
+  API_RO_GET(params = {}) {
+    return request({
+      baseURL: noMr,
+      url: `/api/users/${params.userId}/resource_operations`,
+      method: 'get'
+    })
+  },
   // 根据设备ID获取流
   API_MR_STREAMS_GET(data = {}) {
     return request({

+ 4 - 3
src/api/utils.js

@@ -21,9 +21,10 @@ export const requestError = (response) => {
 export const toLogin = () => {
   storage.session.clear()
   storage.local.clear()
-  router.push({
-    name: 'Login'
-  })
+  // router.push({
+  //   name: 'Login'
+  // })
+  window.top.location.href = '/login'
 }
 
 export const throttleToLogin = useThrottleFn(toLogin, 2000, {

+ 3 - 2
src/components/UniversalWindow/components/uwMenu.vue

@@ -14,6 +14,7 @@
       <li
         class="h-40px flex flex-items-center text-#fff text-14px pl-10px hover-bg-#2058C7"
         v-for="item in menuOptions"
+        v-auth="item.auth"
         :key="item.uuid"
         @click.stop="menuClick(item)"
         :style="{ backgroundColor: menuCache.key === item.key ? '#2058C7' : '' }"
@@ -67,7 +68,7 @@
       icon: 'fluent:cursor-click-24-regular',
       w: '40',
       h: '22',
-      auth: ['DomeCamera'],
+      auth: [],
       uuid: uuidv4().substring(0, 8)
     },
     {
@@ -76,7 +77,7 @@
       icon: 'lucide:rotate-3d',
       w: '40',
       h: '18',
-      auth: ['Linkage'],
+      auth: [],
       uuid: uuidv4().substring(0, 8)
     },
     // {

+ 8 - 7
src/layout/HomeMap/HomeMap.vue

@@ -255,14 +255,15 @@
               1
             )
           }
-        } else if (i.type === 'xs') {
-          if (i.selected) {
-            toolsIndex(mapType)
-            toolsIndex({ type: 'rlt' })
-          } else {
-            fullOptions.value.options.series = [series[0]]
-          }
         }
+        //  else if (i.type === 'xs') {
+        //   if (i.selected) {
+        //     toolsIndex(mapType)
+        //     toolsIndex({ type: 'rlt' })
+        //   } else {
+        //     fullOptions.value.options.series = [series[0]]
+        //   }
+        // }
       }
     }
     $mitt.on('onToolsIndex', toolsIndex)

+ 9 - 2
src/layout/Three3D/components/addDevice.vue

@@ -1,10 +1,12 @@
 <template>
-  <n-data-table :columns="columns" :data="data" bordered />
+  <n-data-table :columns="columns" :data="data" bordered max-height="500px" />
   <div class="flex justify-end mt-2">
     <n-pagination
       v-model:page="pagination.page"
       :page-sizes="pagination.pageSizes"
       :page-count="pagination.pageSize"
+      :on-update:page="pagination.onChange"
+      :on-update:page-size="pagination.onUpdatePageSize"
       show-quick-jumper
       show-size-picker
     />
@@ -97,15 +99,20 @@
     pageSizes: [10, 50, 100],
     onChange: (page) => {
       pagination.page = page
+      init()
     },
     onUpdatePageSize: (pageSize) => {
       pagination.pageSize = pageSize
       pagination.page = 1
+      init()
     }
   })
 
   const init = async () => {
-    const res = await API_DEVICES_GET()
+    const res = await API_DEVICES_GET({
+      page: pagination.page,
+      limit: pagination.pageSize
+    })
     data.value = res?.items || []
     pagination.total = res?.total_items
     pagination.page = res?.current

+ 57 - 37
src/layout/Three3D/index.vue

@@ -341,12 +341,18 @@
       const z = positionAttribute.getZ(i)
 
       // 1. 获取热力值 (0 到 1 之间)
-      const heatValue = generateHeatmapValue(x, z)
-      heatmapValues.push(heatValue)
+      const originalHeatValue = generateHeatmapValue(x, z)
 
-      // 2. 根据热力值和坐标生成地形高度
-      // 热力值越高,地形越高,从而将颜色和高度绑定
-      const y = heatValue * maxTerrainHeight + 15 // 整体抬高到建筑上方
+      // 为了让“红色区域不要太红”,我们对用于着色的热力值做轻微压缩/偏移处理:
+      // - 将热力值整体缩小到原来的 75%(降低最高端的红色强度)
+      // - 加上一个小的偏移以避免完全变暗
+      // - 最终上限设置为 0.95,避免出现完全饱和的红色
+      const colorHeatValue = Math.min(0.95, Math.max(0.0, originalHeatValue * 0.75 + 0.08))
+
+      heatmapValues.push(colorHeatValue)
+
+      // 2. 根据原始热力值和坐标生成地形高度(高度仍使用 originalHeatValue,使视觉的高低与热力对应)
+      const y = originalHeatValue * maxTerrainHeight + 15 // 整体抬高到建筑上方
 
       positionAttribute.setY(i, y)
     }
@@ -357,47 +363,61 @@
     // 自定义着色器材质(与上次相同,但确保颜色映射和您图片一致)
     const heatmapMaterial = new THREE.ShaderMaterial({
       uniforms: {
-        uTime: { value: 0.0 }
+        uTime: { value: 0.0 },
+        uOpacity: { value: 1.0 } // 全局不透明度控制,可在运行时调整
       },
+      transparent: true, // 允许透明
+      depthWrite: false, // 关闭深度写入以便正确混合
+      blending: THREE.NormalBlending,
       vertexShader: `
-            attribute float heatValue;
-            varying float vHeatValue;
-
-            void main() {
-                vHeatValue = heatValue;
-                gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
-            }
-        `,
+        attribute float heatValue;
+        varying float vHeatValue;
+
+        void main() {
+          vHeatValue = heatValue;
+          gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
+        }
+      `,
       fragmentShader: `
-            varying float vHeatValue;
-
-            void main() {
-                vec3 color = vec3(0.0);
-
-                // 颜色映射逻辑: 确保渐变从深蓝 (最低值) 到红色 (最高值)
-                if (vHeatValue < 0.25) {
-                    // 深蓝/黑蓝 到 蓝/青 (对应图中最低部分)
-                    color = mix(vec3(0.0, 0.1, 0.4), vec3(0.0, 0.5, 1.0), vHeatValue * 4.0);
-                } else if (vHeatValue < 0.5) {
-                    // 蓝/青 到 绿色 (对应图中中间部分)
-                    color = mix(vec3(0.0, 0.5, 1.0), vec3(0.0, 1.0, 0.2), (vHeatValue - 0.25) * 4.0);
-                } else if (vHeatValue < 0.75) {
-                    // 绿色 到 黄色 (对应图中高一些的部分)
-                    color = mix(vec3(0.0, 1.0, 0.2), vec3(1.0, 1.0, 0.0), (vHeatValue - 0.5) * 4.0);
-                } else {
-                    // 黄色 到 红色/橙色 (对应图中最高峰部分)
-                    color = mix(vec3(1.0, 1.0, 0.0), vec3(1.0, 0.2, 0.0), (vHeatValue - 0.75) * 4.0);
-                }
-
-                gl_FragColor = vec4(color, 1.0);
-            }
-        `,
+        varying float vHeatValue;
+        uniform float uOpacity;
+
+        void main() {
+          vec3 color = vec3(0.0);
+
+          // 颜色映射逻辑: 确保渐变从深蓝 (最低值) 到红色 (最高值)
+          if (vHeatValue < 0.25) {
+            // 深蓝/黑蓝 到 蓝/青 (对应图中最低部分)
+            color = mix(vec3(0.0, 0.1, 0.4), vec3(0.0, 0.5, 1.0), vHeatValue * 4.0);
+          } else if (vHeatValue < 0.5) {
+            // 蓝/青 到 绿色 (对应图中中间部分)
+            color = mix(vec3(0.0, 0.5, 1.0), vec3(0.0, 1.0, 0.2), (vHeatValue - 0.25) * 4.0);
+          } else if (vHeatValue < 0.75) {
+            // 绿色 到 黄色 (对应图中高一些的部分)
+            color = mix(vec3(0.0, 1.0, 0.2), vec3(1.0, 1.0, 0.0), (vHeatValue - 0.5) * 4.0);
+          } else {
+            // 黄色 到 红色/橙色 (对应图中最高峰部分)
+            color = mix(vec3(1.0, 1.0, 0.0), vec3(1.0, 0.2, 0.0), (vHeatValue - 0.75) * 4.0);
+          }
+
+          // 基于热力值计算每片面的不透明度:低热力值更透明,热值高则更不透明
+          float minA = 0.08;
+          float maxA = 0.95;
+          float localOpacity = mix(minA, maxA, vHeatValue);
+
+          // 将局部不透明度与全局控制相乘,方便外部动态调整整体透明度
+          float finalA = clamp(localOpacity * uOpacity, 0.0, 1.0);
+
+          gl_FragColor = vec4(color, finalA);
+        }
+      `,
       side: THREE.DoubleSide
     })
 
     heatmapMesh = new THREE.Mesh(geometry, heatmapMaterial)
     heatmapMesh.visible = false
     heatmapMesh.scale.set(0.2, 0.2, 0.2)
+    heatmapMesh
     scene.add(heatmapMesh)
   }
 

+ 1 - 0
src/views/home/home.vue

@@ -86,6 +86,7 @@
   }
 
   useSystem.connectAlarmWS()
+  useSystem.getPermissions()
 </script>
 
 <style>

+ 33 - 4
src/views/home/leftbox/historyAlarm.vue

@@ -14,12 +14,14 @@
     }"
     :bordered="false"
   >
-    <n-data-table :columns="columns" :data="data" bordered />
+    <n-data-table :columns="columns" :data="data" max-height="500px" bordered />
     <div class="flex justify-end mt-2">
       <n-pagination
         v-model:page="pagination.page"
         :page-sizes="pagination.pageSizes"
         :page-count="pagination.pageSize"
+        :on-update:page="pagination.onChange"
+        :on-update:page-size="pagination.onUpdatePageSize"
         show-quick-jumper
         show-size-picker
       />
@@ -28,10 +30,12 @@
 </template>
 
 <script setup>
-  import { NButton, NModal, NDataTable, NPagination } from 'naive-ui'
+  import { NButton, NModal, NDataTable, NPagination, useModal } from 'naive-ui'
   import { Events } from '@/utils/enum'
   import dayjs from 'dayjs'
+  import { h } from 'vue'
 
+  const modal = useModal()
   const { API_ALARM_HISTORY_GET } = useRequest()
   const showModal = ref(false)
 
@@ -88,7 +92,25 @@
 
   const data = ref([])
   const columns = createColumns({
-    handleSubmit(row) {}
+    handleSubmit(row) {
+      modal.create({
+        title: '事件详情',
+        preset: 'card',
+        style: {
+          marginTop: '10%'
+        },
+        content: () =>
+          h('div', { style: { display: 'flex', flexDirection: 'column', gap: '8px' } }, [
+            h('span', {}, `事件名称:${Events[row.eventTypeId] ? Events[row.eventTypeId] : ''}`),
+            h(
+              'span',
+              {},
+              `事件时间:${dayjs(parseInt(`${row.haveTime}`.padEnd(13, '0'))).format('YYYY-MM-DD HH:mm:ss')}`
+            ),
+            h('span', { style: { 'white-space': 'pre-wrap' } }, `事件描述:${row.handledDetail}`)
+          ])
+      })
+    }
   })
 
   const pagination = reactive({
@@ -98,15 +120,22 @@
     pageSizes: [10, 50, 100],
     onChange: (page) => {
       pagination.page = page
+      init()
     },
     onUpdatePageSize: (pageSize) => {
       pagination.pageSize = pageSize
       pagination.page = 1
+      console.log(123)
+
+      init()
     }
   })
 
   const init = async () => {
-    const res = await API_ALARM_HISTORY_GET()
+    const res = await API_ALARM_HISTORY_GET({
+      page: pagination.page,
+      page_size: pagination.pageSize
+    })
     data.value = res?.items || []
     pagination.total = res?.total
     pagination.page = res?.page

+ 1 - 1
vite.config.js

@@ -68,7 +68,7 @@ export default ({ mode, command }) => {
         compiler: 'vue3'
       }),
       deletePlugin({
-        targets: ['dist/del'],
+        targets: ['foreground/del'],
         hook: 'writeBundle'
       })
     ],