Ver Fonte

feat: 解决ts报错问题;

liujia há 3 semanas atrás
pai
commit
0490f71

+ 1 - 0
src/api/room/types.ts

@@ -1,3 +1,4 @@
+import type { FurnitureItem } from '@/types/radar'
 /**
  * 房间信息请求参数
  * @param devId 设备ID

+ 0 - 1
src/components/EditableFurniture/index.vue

@@ -5,7 +5,6 @@
       position: 'absolute',
       left: `${centerCss.left}px`,
       top: `${centerCss.top}px`,
-      zIndex: 10,
       pointerEvents: 'auto',
     }"
   >

+ 3 - 2
src/types/radar.ts

@@ -1,10 +1,11 @@
-import type { FurnitureIconType } from '@/types/furniture'
+import type { FurnitureType } from '@/api/room/types'
+// import type { FurnitureIconType } from '@/types/furniture'
 /**
  * 家具元素,用于在雷达区域中展示和编辑
  */
 export interface FurnitureItem {
   name: string // 家具名称(如:床、桌子)
-  type: FurnitureIconType // 家具类型标识(如:'bed'、'table')
+  type: FurnitureType // 家具类型标识(如:'bed'、'table')
   width: number // 家具宽度(单位:px)
   length: number // 家具长度(单位:px)
   left: number // CSS 坐标系下的 left 值(用于定位)

+ 3 - 5
src/views/device/detail/components/deviceAreaConfig/index.vue

@@ -395,7 +395,7 @@ interface CanvaseItem {
   name: string // 名称
   type: string // 类型,图标icon
   width: number // 家具宽度
-  height: number // 家具长度
+  height?: number // 家具长度
   length?: number // 家具长度
   top: number // 距离检测范围上方位置 cm
   left: number // 	距离检测范围左边位置 cm
@@ -429,7 +429,7 @@ const addHandler = (icon: FurnitureIconType) => {
 
   const newItem: FurnitureItem = {
     name: furnitureIconNameMap[icon],
-    type: icon,
+    type: icon as FurnitureType,
     width: originWidth,
     length: originHeight,
     top: 0,
@@ -437,8 +437,6 @@ const addHandler = (icon: FurnitureIconType) => {
     rotate: 0,
     x: 0,
     y: 0,
-    // x: originOffsetX,
-    // y: originOffsetY,
     nanoid: nanoid(),
   }
 
@@ -488,7 +486,7 @@ useDropZone(contentEl, {
       const x = event.clientX - rect.left
       const y = event.clientY - rect.top
       // 中心点对齐计算
-      currentDragItem.value.top = y - currentDragItem.value.height / 2
+      currentDragItem.value.top = y - currentDragItem.value.height! / 2
       currentDragItem.value.left = x - currentDragItem.value.width / 2
       // 添加边界检查
       // const maxX = contentEl.value.offsetWidth - currentDragItem.value.width