路径规划界面增加视频 封装拖拽组件 和 全景视频组件 设备状态界面增加完成点 机器人任务界面的topcard值的优化
This commit is contained in:
60
src/components/Draggable.tsx
Normal file
60
src/components/Draggable.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
import { PlayCircleOutlined, CloseOutlined } from '@ant-design/icons';
|
||||
import React, { useRef } from 'react';
|
||||
import Draggable from 'react-draggable';
|
||||
import clsx from 'clsx';
|
||||
|
||||
interface Props {
|
||||
children: React.ReactNode;
|
||||
defaultPosition?: { x: number; y: number };
|
||||
// 新增
|
||||
title: string;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
const DraggableBox: React.FC<Props> = ({
|
||||
children,
|
||||
defaultPosition = { x: 0, y: 0 },
|
||||
title,
|
||||
onClose,
|
||||
}) => {
|
||||
const nodeRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
return (
|
||||
<Draggable
|
||||
nodeRef={nodeRef}
|
||||
defaultPosition={defaultPosition}
|
||||
handle=".drag-header" // 仅标题栏可拖拽,内容区不触发拖拽
|
||||
>
|
||||
<div
|
||||
ref={nodeRef}
|
||||
className={clsx(
|
||||
'fixed select-none z-[9999] bg-white shadow-xl rounded-lg overflow-hidden',
|
||||
'border-[8px] border-slate-200 top-[8px] left-[8px] w-[600px] h-[300px]' // 整体8px外边框
|
||||
)}
|
||||
>
|
||||
{/* 拖拽标题栏 + 关闭按钮 */}
|
||||
<div className="drag-header flex items-center justify-between px-4 py-3 bg-slate-100 cursor-move border-b border-slate-200">
|
||||
<div className="flex items-center gap-2">
|
||||
<PlayCircleOutlined className="text-slate-600" />
|
||||
<span className="font-semibold text-slate-800">{title}</span>
|
||||
</div>
|
||||
{/* 关闭按钮,阻止拖拽冒泡 */}
|
||||
<div
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onClose();
|
||||
}}
|
||||
className="w-6 h-6 flex items-center justify-center rounded hover:bg-red-100 cursor-pointer transition-colors"
|
||||
>
|
||||
<CloseOutlined className="text-slate-500 hover:text-red-500" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 传入的视频内容 */}
|
||||
<div>{children}</div>
|
||||
</div>
|
||||
</Draggable>
|
||||
);
|
||||
};
|
||||
|
||||
export default DraggableBox;
|
||||
Reference in New Issue
Block a user