11import { Angry , MousePointerClick , RefreshCcw , Smile , Tags , Telescope } from "lucide-react" ;
22import React from "react" ;
3+ import { Dialog } from "../components/dialog" ;
34import IconButton from "../components/IconButton" ;
45import { StageManager } from "../core/stage/stageManager/StageManager" ;
56import { cn } from "../utils/cn" ;
@@ -26,22 +27,28 @@ export default function TagPanel({ open = false, className = "" }: { open: boole
2627 const handleMoveCameraToTag = ( tagUUID : string ) => {
2728 return ( ) => {
2829 // 跳转到对应位置
29- StageManager . moveToTag ( tagUUID ) ;
30+ StageManager . moveCameraToTag ( tagUUID ) ;
3031 } ;
3132 } ;
3233
3334 const handleMouseEnterTag = ( tagUUID : string ) => {
3435 return ( ) => {
3536 if ( isMouseEnterMoveCameraAble ) {
36- StageManager . moveToTag ( tagUUID ) ;
37+ StageManager . moveCameraToTag ( tagUUID ) ;
3738 } else {
3839 console . log ( "禁止滑动" ) ;
3940 }
4041 } ;
4142 } ;
4243
4344 const handleClickAddTag = ( ) => {
44- // TODO: 这里可能缺少一个是否有选中的实体的检测
45+ // 检查是否有选中的entity或连线
46+ if ( StageManager . getSelectedEntities ( ) . length === 0 && StageManager . getSelectedAssociations ( ) . length === 0 ) {
47+ Dialog . show ( {
48+ title : "请先选中舞台上的物体" ,
49+ content : "选中后再点此按钮,即可添标签" ,
50+ } ) ;
51+ }
4552 StageManager . addTagBySelected ( ) ;
4653 refreshTagNameList ( ) ;
4754 } ;
@@ -67,22 +74,26 @@ export default function TagPanel({ open = false, className = "" }: { open: boole
6774 < IconButton onClick = { refreshTagNameList } tooltip = "如果舞台上的标签发生变更但此处未更新,可以手动刷新" >
6875 < RefreshCcw />
6976 </ IconButton >
70- < IconButton
71- onClick = { ( ) => {
72- setIsMouseEnterMoveCameraAble ( ! isMouseEnterMoveCameraAble ) ;
73- } }
74- tooltip = { isMouseEnterMoveCameraAble ? "快速瞭望模式" : "点击跳转模式" }
75- >
76- { isMouseEnterMoveCameraAble ? < Telescope /> : < MousePointerClick /> }
77- </ IconButton >
78- < IconButton
79- onClick = { ( ) => {
80- setIsPerspective ( ! isPerspective ) ;
81- } }
82- tooltip = { isPerspective ? "透视已开启" : "开启透视眼" }
83- >
84- { isPerspective ? < Angry /> : < Smile /> }
85- </ IconButton >
77+ { tagNameList . length >= 3 && (
78+ < IconButton
79+ onClick = { ( ) => {
80+ setIsMouseEnterMoveCameraAble ( ! isMouseEnterMoveCameraAble ) ;
81+ } }
82+ tooltip = { isMouseEnterMoveCameraAble ? "快速瞭望模式" : "点击跳转模式" }
83+ >
84+ { isMouseEnterMoveCameraAble ? < Telescope /> : < MousePointerClick /> }
85+ </ IconButton >
86+ ) }
87+ { tagNameList . length > 0 && (
88+ < IconButton
89+ onClick = { ( ) => {
90+ setIsPerspective ( ! isPerspective ) ;
91+ } }
92+ tooltip = { isPerspective ? "透视已开启" : "开启透视眼" }
93+ >
94+ { isPerspective ? < Angry /> : < Smile /> }
95+ </ IconButton >
96+ ) }
8697 </ div >
8798
8899 { /* 标签列表 */ }
0 commit comments