2025-11-26 11:08:10 +08:00
|
|
|
import { useState, useEffect, useRef } from 'react';
|
2025-10-17 18:13:31 +08:00
|
|
|
import { Entity, Core } from '@esengine/ecs-framework';
|
2025-11-25 22:23:19 +08:00
|
|
|
import { EntityStoreService, MessageHub, SceneManagerService, CommandManager, EntityCreationRegistry, EntityCreationTemplate } from '@esengine/editor-core';
|
2025-10-14 23:56:54 +08:00
|
|
|
import { useLocale } from '../hooks/useLocale';
|
2025-11-27 20:42:46 +08:00
|
|
|
import * as LucideIcons from 'lucide-react';
|
2025-11-29 23:00:48 +08:00
|
|
|
import {
|
|
|
|
|
Box, Wifi, Search, Plus, Trash2, Monitor, Globe, ChevronRight, ChevronDown,
|
|
|
|
|
Eye, Star, Lock, Settings, Filter, Folder, Sun, Cloud, Mountain, Flag,
|
|
|
|
|
SquareStack
|
|
|
|
|
} from 'lucide-react';
|
2025-10-15 23:24:13 +08:00
|
|
|
import { ProfilerService, RemoteEntity } from '../services/ProfilerService';
|
2025-10-17 18:13:31 +08:00
|
|
|
import { confirm } from '@tauri-apps/plugin-dialog';
|
2025-11-27 20:42:46 +08:00
|
|
|
import { CreateEntityCommand, DeleteEntityCommand } from '../application/commands/entity';
|
2025-10-14 23:31:09 +08:00
|
|
|
import '../styles/SceneHierarchy.css';
|
|
|
|
|
|
2025-11-29 23:00:48 +08:00
|
|
|
function getIconComponent(iconName: string | undefined, size: number = 14): React.ReactNode {
|
|
|
|
|
if (!iconName) return <Box size={size} />;
|
2025-11-27 20:42:46 +08:00
|
|
|
|
|
|
|
|
const icons = LucideIcons as unknown as Record<string, React.ComponentType<{ size?: number }>>;
|
|
|
|
|
const IconComponent = icons[iconName];
|
|
|
|
|
if (IconComponent) {
|
|
|
|
|
return <IconComponent size={size} />;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-29 23:00:48 +08:00
|
|
|
return <Box size={size} />;
|
2025-11-27 20:42:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const categoryIconMap: Record<string, string> = {
|
|
|
|
|
'rendering': 'Image',
|
|
|
|
|
'ui': 'LayoutGrid',
|
|
|
|
|
'physics': 'Box',
|
|
|
|
|
'audio': 'Volume2',
|
|
|
|
|
'basic': 'Plus',
|
|
|
|
|
'other': 'MoreHorizontal',
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-29 23:00:48 +08:00
|
|
|
// 实体类型到图标的映射
|
|
|
|
|
const entityTypeIcons: Record<string, React.ReactNode> = {
|
|
|
|
|
'World': <Mountain size={14} className="entity-type-icon world" />,
|
|
|
|
|
'Folder': <Folder size={14} className="entity-type-icon folder" />,
|
|
|
|
|
'DirectionalLight': <Sun size={14} className="entity-type-icon light" />,
|
|
|
|
|
'SkyLight': <Sun size={14} className="entity-type-icon light" />,
|
|
|
|
|
'SkyAtmosphere': <Cloud size={14} className="entity-type-icon atmosphere" />,
|
|
|
|
|
'VolumetricCloud': <Cloud size={14} className="entity-type-icon cloud" />,
|
|
|
|
|
'StaticMeshActor': <SquareStack size={14} className="entity-type-icon mesh" />,
|
|
|
|
|
'PlayerStart': <Flag size={14} className="entity-type-icon player" />,
|
|
|
|
|
'ExponentialHeightFog': <Cloud size={14} className="entity-type-icon fog" />,
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-21 10:03:18 +08:00
|
|
|
type ViewMode = 'local' | 'remote';
|
2025-11-29 23:00:48 +08:00
|
|
|
type SortColumn = 'name' | 'type';
|
|
|
|
|
type SortDirection = 'asc' | 'desc';
|
2025-11-21 10:03:18 +08:00
|
|
|
|
2025-10-14 23:31:09 +08:00
|
|
|
interface SceneHierarchyProps {
|
2025-11-29 23:00:48 +08:00
|
|
|
entityStore: EntityStoreService;
|
|
|
|
|
messageHub: MessageHub;
|
|
|
|
|
commandManager: CommandManager;
|
|
|
|
|
isProfilerMode?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface EntityNode {
|
|
|
|
|
entity: Entity;
|
|
|
|
|
children: EntityNode[];
|
|
|
|
|
isExpanded: boolean;
|
|
|
|
|
depth: number;
|
2025-10-14 23:31:09 +08:00
|
|
|
}
|
|
|
|
|
|
2025-11-23 21:45:10 +08:00
|
|
|
export function SceneHierarchy({ entityStore, messageHub, commandManager, isProfilerMode = false }: SceneHierarchyProps) {
|
2025-11-02 23:50:41 +08:00
|
|
|
const [entities, setEntities] = useState<Entity[]>([]);
|
|
|
|
|
const [remoteEntities, setRemoteEntities] = useState<RemoteEntity[]>([]);
|
|
|
|
|
const [isRemoteConnected, setIsRemoteConnected] = useState(false);
|
2025-11-23 21:45:10 +08:00
|
|
|
const [viewMode, setViewMode] = useState<ViewMode>(isProfilerMode ? 'remote' : 'local');
|
2025-11-29 23:00:48 +08:00
|
|
|
const [selectedIds, setSelectedIds] = useState<Set<number>>(new Set());
|
2025-11-02 23:50:41 +08:00
|
|
|
const [searchQuery, setSearchQuery] = useState('');
|
|
|
|
|
const [sceneName, setSceneName] = useState<string>('Untitled');
|
|
|
|
|
const [remoteSceneName, setRemoteSceneName] = useState<string | null>(null);
|
|
|
|
|
const [sceneFilePath, setSceneFilePath] = useState<string | null>(null);
|
|
|
|
|
const [isSceneModified, setIsSceneModified] = useState<boolean>(false);
|
2025-11-21 10:03:18 +08:00
|
|
|
const [contextMenu, setContextMenu] = useState<{ x: number; y: number; entityId: number | null } | null>(null);
|
2025-11-23 21:45:10 +08:00
|
|
|
const [draggedEntityId, setDraggedEntityId] = useState<number | null>(null);
|
|
|
|
|
const [dropTargetIndex, setDropTargetIndex] = useState<number | null>(null);
|
2025-11-25 22:23:19 +08:00
|
|
|
const [pluginTemplates, setPluginTemplates] = useState<EntityCreationTemplate[]>([]);
|
2025-11-29 23:00:48 +08:00
|
|
|
const [expandedFolders, setExpandedFolders] = useState<Set<number>>(new Set());
|
|
|
|
|
const [sortColumn, setSortColumn] = useState<SortColumn>('name');
|
|
|
|
|
const [sortDirection, setSortDirection] = useState<SortDirection>('asc');
|
|
|
|
|
const [showFilterMenu, setShowFilterMenu] = useState(false);
|
2025-11-02 23:50:41 +08:00
|
|
|
const { t, locale } = useLocale();
|
|
|
|
|
|
2025-11-21 10:03:18 +08:00
|
|
|
const isShowingRemote = viewMode === 'remote' && isRemoteConnected;
|
2025-11-29 23:00:48 +08:00
|
|
|
const selectedId = selectedIds.size > 0 ? Array.from(selectedIds)[0] : null;
|
2025-11-21 10:03:18 +08:00
|
|
|
|
2025-11-25 22:23:19 +08:00
|
|
|
// Get entity creation templates from plugins
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const updateTemplates = () => {
|
|
|
|
|
const registry = Core.services.resolve(EntityCreationRegistry);
|
|
|
|
|
if (registry) {
|
|
|
|
|
setPluginTemplates(registry.getAll());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
updateTemplates();
|
|
|
|
|
|
|
|
|
|
const unsubInstalled = messageHub.subscribe('plugin:installed', updateTemplates);
|
|
|
|
|
const unsubUninstalled = messageHub.subscribe('plugin:uninstalled', updateTemplates);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
unsubInstalled();
|
|
|
|
|
unsubUninstalled();
|
|
|
|
|
};
|
|
|
|
|
}, [messageHub]);
|
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
// Subscribe to scene changes
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const sceneManager = Core.services.resolve(SceneManagerService);
|
|
|
|
|
|
|
|
|
|
const updateSceneInfo = () => {
|
|
|
|
|
if (sceneManager) {
|
|
|
|
|
const state = sceneManager.getSceneState();
|
|
|
|
|
setSceneName(state.sceneName);
|
|
|
|
|
setIsSceneModified(state.isModified);
|
2025-11-23 21:45:10 +08:00
|
|
|
setSceneFilePath(state.currentScenePath || null);
|
2025-11-02 23:50:41 +08:00
|
|
|
}
|
|
|
|
|
};
|
2025-10-17 18:13:31 +08:00
|
|
|
|
|
|
|
|
updateSceneInfo();
|
2025-10-14 23:31:09 +08:00
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
const unsubLoaded = messageHub.subscribe('scene:loaded', (data: any) => {
|
|
|
|
|
if (data.sceneName) {
|
|
|
|
|
setSceneName(data.sceneName);
|
|
|
|
|
setSceneFilePath(data.path || null);
|
|
|
|
|
setIsSceneModified(data.isModified || false);
|
|
|
|
|
} else {
|
|
|
|
|
updateSceneInfo();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
const unsubNew = messageHub.subscribe('scene:new', () => {
|
|
|
|
|
updateSceneInfo();
|
|
|
|
|
});
|
|
|
|
|
const unsubSaved = messageHub.subscribe('scene:saved', () => {
|
|
|
|
|
updateSceneInfo();
|
|
|
|
|
});
|
2025-11-23 21:45:10 +08:00
|
|
|
const unsubModified = messageHub.subscribe('scene:modified', updateSceneInfo);
|
2025-10-14 23:31:09 +08:00
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
return () => {
|
|
|
|
|
unsubLoaded();
|
|
|
|
|
unsubNew();
|
|
|
|
|
unsubSaved();
|
|
|
|
|
unsubModified();
|
|
|
|
|
};
|
|
|
|
|
}, [messageHub]);
|
|
|
|
|
|
|
|
|
|
// Subscribe to local entity changes
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const updateEntities = () => {
|
2025-11-23 21:45:10 +08:00
|
|
|
setEntities([...entityStore.getRootEntities()]);
|
2025-11-02 23:50:41 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleSelection = (data: { entity: Entity | null }) => {
|
2025-11-29 23:00:48 +08:00
|
|
|
if (data.entity) {
|
|
|
|
|
setSelectedIds(new Set([data.entity.id]));
|
|
|
|
|
} else {
|
|
|
|
|
setSelectedIds(new Set());
|
|
|
|
|
}
|
2025-11-02 23:50:41 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
updateEntities();
|
|
|
|
|
|
|
|
|
|
const unsubAdd = messageHub.subscribe('entity:added', updateEntities);
|
|
|
|
|
const unsubRemove = messageHub.subscribe('entity:removed', updateEntities);
|
|
|
|
|
const unsubClear = messageHub.subscribe('entities:cleared', updateEntities);
|
|
|
|
|
const unsubSelect = messageHub.subscribe('entity:selected', handleSelection);
|
2025-11-23 21:45:10 +08:00
|
|
|
const unsubSceneLoaded = messageHub.subscribe('scene:loaded', updateEntities);
|
|
|
|
|
const unsubSceneNew = messageHub.subscribe('scene:new', updateEntities);
|
|
|
|
|
const unsubReordered = messageHub.subscribe('entity:reordered', updateEntities);
|
2025-11-02 23:50:41 +08:00
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
unsubAdd();
|
|
|
|
|
unsubRemove();
|
|
|
|
|
unsubClear();
|
|
|
|
|
unsubSelect();
|
2025-11-23 21:45:10 +08:00
|
|
|
unsubSceneLoaded();
|
|
|
|
|
unsubSceneNew();
|
|
|
|
|
unsubReordered();
|
2025-11-02 23:50:41 +08:00
|
|
|
};
|
|
|
|
|
}, [entityStore, messageHub]);
|
|
|
|
|
|
|
|
|
|
// Subscribe to remote entity data from ProfilerService
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const profilerService = (window as any).__PROFILER_SERVICE__ as ProfilerService | undefined;
|
|
|
|
|
|
|
|
|
|
if (!profilerService) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-10-14 23:31:09 +08:00
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
const initiallyConnected = profilerService.isConnected();
|
|
|
|
|
setIsRemoteConnected(initiallyConnected);
|
2025-10-14 23:31:09 +08:00
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
const unsubscribe = profilerService.subscribe((data) => {
|
|
|
|
|
const connected = profilerService.isConnected();
|
|
|
|
|
setIsRemoteConnected(connected);
|
2025-10-14 23:31:09 +08:00
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
if (connected && data.entities && data.entities.length > 0) {
|
|
|
|
|
setRemoteEntities((prev) => {
|
|
|
|
|
if (prev.length !== data.entities!.length) {
|
|
|
|
|
return data.entities!;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const hasChanged = data.entities!.some((entity, index) => {
|
|
|
|
|
const prevEntity = prev[index];
|
|
|
|
|
return !prevEntity ||
|
2025-11-29 23:00:48 +08:00
|
|
|
prevEntity.id !== entity.id ||
|
|
|
|
|
prevEntity.name !== entity.name ||
|
|
|
|
|
prevEntity.componentCount !== entity.componentCount;
|
2025-11-02 23:50:41 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return hasChanged ? data.entities! : prev;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!remoteSceneName && data.entities.length > 0 && data.entities[0]) {
|
|
|
|
|
profilerService.requestEntityDetails(data.entities[0].id);
|
|
|
|
|
}
|
|
|
|
|
} else if (!connected) {
|
|
|
|
|
setRemoteEntities([]);
|
|
|
|
|
setRemoteSceneName(null);
|
|
|
|
|
}
|
2025-10-16 17:10:22 +08:00
|
|
|
});
|
2025-10-18 20:21:43 +08:00
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
return () => unsubscribe();
|
|
|
|
|
}, [remoteSceneName]);
|
|
|
|
|
|
|
|
|
|
// Listen for entity details to get remote scene name
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const handleEntityDetails = ((event: CustomEvent) => {
|
|
|
|
|
const details = event.detail;
|
|
|
|
|
if (details && details.sceneName) {
|
|
|
|
|
setRemoteSceneName(details.sceneName);
|
|
|
|
|
}
|
|
|
|
|
}) as EventListener;
|
|
|
|
|
|
|
|
|
|
window.addEventListener('profiler:entity-details', handleEntityDetails);
|
|
|
|
|
return () => window.removeEventListener('profiler:entity-details', handleEntityDetails);
|
|
|
|
|
}, []);
|
|
|
|
|
|
2025-11-29 23:00:48 +08:00
|
|
|
const handleEntityClick = (entity: Entity, e: React.MouseEvent) => {
|
|
|
|
|
if (e.ctrlKey || e.metaKey) {
|
|
|
|
|
setSelectedIds(prev => {
|
|
|
|
|
const next = new Set(prev);
|
|
|
|
|
if (next.has(entity.id)) {
|
|
|
|
|
next.delete(entity.id);
|
|
|
|
|
} else {
|
|
|
|
|
next.add(entity.id);
|
|
|
|
|
}
|
|
|
|
|
return next;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
setSelectedIds(new Set([entity.id]));
|
|
|
|
|
entityStore.selectEntity(entity);
|
|
|
|
|
}
|
2025-11-02 23:50:41 +08:00
|
|
|
};
|
|
|
|
|
|
2025-11-23 21:45:10 +08:00
|
|
|
const handleDragStart = (e: React.DragEvent, entityId: number) => {
|
|
|
|
|
setDraggedEntityId(entityId);
|
|
|
|
|
e.dataTransfer.effectAllowed = 'move';
|
|
|
|
|
e.dataTransfer.setData('text/plain', entityId.toString());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleDragOver = (e: React.DragEvent, index: number) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
e.dataTransfer.dropEffect = 'move';
|
|
|
|
|
setDropTargetIndex(index);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleDragLeave = () => {
|
|
|
|
|
setDropTargetIndex(null);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleDrop = (e: React.DragEvent, targetIndex: number) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (draggedEntityId !== null) {
|
|
|
|
|
entityStore.reorderEntity(draggedEntityId, targetIndex);
|
|
|
|
|
}
|
|
|
|
|
setDraggedEntityId(null);
|
|
|
|
|
setDropTargetIndex(null);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleDragEnd = () => {
|
|
|
|
|
setDraggedEntityId(null);
|
|
|
|
|
setDropTargetIndex(null);
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
const handleRemoteEntityClick = (entity: RemoteEntity) => {
|
2025-11-29 23:00:48 +08:00
|
|
|
setSelectedIds(new Set([entity.id]));
|
2025-11-02 23:50:41 +08:00
|
|
|
|
|
|
|
|
const profilerService = (window as any).__PROFILER_SERVICE__ as ProfilerService | undefined;
|
|
|
|
|
if (profilerService) {
|
|
|
|
|
profilerService.requestEntityDetails(entity.id);
|
2025-10-18 20:21:43 +08:00
|
|
|
}
|
2025-10-17 18:13:31 +08:00
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
messageHub.publish('remote-entity:selected', {
|
|
|
|
|
entity: {
|
|
|
|
|
id: entity.id,
|
|
|
|
|
name: entity.name,
|
|
|
|
|
enabled: entity.enabled,
|
|
|
|
|
componentCount: entity.componentCount,
|
|
|
|
|
componentTypes: entity.componentTypes
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleCreateEntity = () => {
|
|
|
|
|
const entityCount = entityStore.getAllEntities().length;
|
|
|
|
|
const entityName = `Entity ${entityCount + 1}`;
|
2025-11-21 10:03:18 +08:00
|
|
|
|
|
|
|
|
const command = new CreateEntityCommand(
|
|
|
|
|
entityStore,
|
|
|
|
|
messageHub,
|
|
|
|
|
entityName
|
|
|
|
|
);
|
|
|
|
|
commandManager.execute(command);
|
2025-11-02 23:50:41 +08:00
|
|
|
};
|
2025-10-16 17:33:43 +08:00
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
const handleDeleteEntity = async () => {
|
|
|
|
|
if (!selectedId) return;
|
2025-10-16 17:33:43 +08:00
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
const entity = entityStore.getEntity(selectedId);
|
|
|
|
|
if (!entity) return;
|
2025-10-16 17:33:43 +08:00
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
const confirmed = await confirm(
|
|
|
|
|
locale === 'zh'
|
2025-11-21 10:03:18 +08:00
|
|
|
? `确定要删除实体 "${entity.name}" 吗?`
|
|
|
|
|
: `Are you sure you want to delete entity "${entity.name}"?`,
|
2025-11-02 23:50:41 +08:00
|
|
|
{
|
|
|
|
|
title: locale === 'zh' ? '删除实体' : 'Delete Entity',
|
|
|
|
|
kind: 'warning'
|
|
|
|
|
}
|
2025-10-16 17:33:43 +08:00
|
|
|
);
|
2025-11-02 23:50:41 +08:00
|
|
|
|
|
|
|
|
if (confirmed) {
|
2025-11-21 10:03:18 +08:00
|
|
|
const command = new DeleteEntityCommand(
|
|
|
|
|
entityStore,
|
|
|
|
|
messageHub,
|
|
|
|
|
entity
|
|
|
|
|
);
|
|
|
|
|
commandManager.execute(command);
|
2025-11-02 23:50:41 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-21 10:03:18 +08:00
|
|
|
const handleContextMenu = (e: React.MouseEvent, entityId: number | null) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
setContextMenu({ x: e.clientX, y: e.clientY, entityId });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const closeContextMenu = () => {
|
|
|
|
|
setContextMenu(null);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const handleClick = () => closeContextMenu();
|
|
|
|
|
if (contextMenu) {
|
|
|
|
|
window.addEventListener('click', handleClick);
|
|
|
|
|
return () => window.removeEventListener('click', handleClick);
|
|
|
|
|
}
|
|
|
|
|
}, [contextMenu]);
|
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
useEffect(() => {
|
|
|
|
|
const handleKeyDown = (e: KeyboardEvent) => {
|
2025-11-21 10:03:18 +08:00
|
|
|
if (e.key === 'Delete' && selectedId && !isShowingRemote) {
|
2025-11-02 23:50:41 +08:00
|
|
|
handleDeleteEntity();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
window.addEventListener('keydown', handleKeyDown);
|
|
|
|
|
return () => window.removeEventListener('keydown', handleKeyDown);
|
2025-11-21 10:03:18 +08:00
|
|
|
}, [selectedId, isShowingRemote]);
|
2025-11-02 23:50:41 +08:00
|
|
|
|
2025-11-29 23:00:48 +08:00
|
|
|
const toggleFolderExpand = (entityId: number) => {
|
|
|
|
|
setExpandedFolders(prev => {
|
|
|
|
|
const next = new Set(prev);
|
|
|
|
|
if (next.has(entityId)) {
|
|
|
|
|
next.delete(entityId);
|
|
|
|
|
} else {
|
|
|
|
|
next.add(entityId);
|
|
|
|
|
}
|
|
|
|
|
return next;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleSortClick = (column: SortColumn) => {
|
|
|
|
|
if (sortColumn === column) {
|
|
|
|
|
setSortDirection(prev => prev === 'asc' ? 'desc' : 'asc');
|
|
|
|
|
} else {
|
|
|
|
|
setSortColumn(column);
|
|
|
|
|
setSortDirection('asc');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Get entity type for display
|
|
|
|
|
const getEntityType = (entity: Entity): string => {
|
|
|
|
|
const components = entity.components || [];
|
|
|
|
|
if (components.length > 0) {
|
|
|
|
|
const firstComponent = components[0];
|
|
|
|
|
return firstComponent?.constructor?.name || 'Entity';
|
|
|
|
|
}
|
|
|
|
|
return 'Entity';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Get icon for entity type
|
|
|
|
|
const getEntityIcon = (entityType: string): React.ReactNode => {
|
|
|
|
|
return entityTypeIcons[entityType] || <Box size={14} className="entity-type-icon default" />;
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
// Filter entities based on search query
|
|
|
|
|
const filterRemoteEntities = (entityList: RemoteEntity[]): RemoteEntity[] => {
|
|
|
|
|
if (!searchQuery.trim()) return entityList;
|
|
|
|
|
|
|
|
|
|
const query = searchQuery.toLowerCase();
|
|
|
|
|
return entityList.filter((entity) => {
|
|
|
|
|
const name = entity.name;
|
|
|
|
|
const id = entity.id.toString();
|
|
|
|
|
|
|
|
|
|
if (name.toLowerCase().includes(query) || id.includes(query)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Array.isArray(entity.componentTypes)) {
|
|
|
|
|
return entity.componentTypes.some((type) =>
|
|
|
|
|
type.toLowerCase().includes(query)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const filterLocalEntities = (entityList: Entity[]): Entity[] => {
|
|
|
|
|
if (!searchQuery.trim()) return entityList;
|
|
|
|
|
|
|
|
|
|
const query = searchQuery.toLowerCase();
|
|
|
|
|
return entityList.filter((entity) => {
|
2025-11-29 23:00:48 +08:00
|
|
|
const name = entity.name || '';
|
2025-11-02 23:50:41 +08:00
|
|
|
const id = entity.id.toString();
|
2025-11-29 23:00:48 +08:00
|
|
|
return name.toLowerCase().includes(query) || id.includes(query);
|
2025-11-02 23:50:41 +08:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-21 10:03:18 +08:00
|
|
|
const displayEntities = isShowingRemote
|
2025-11-02 23:50:41 +08:00
|
|
|
? filterRemoteEntities(remoteEntities)
|
|
|
|
|
: filterLocalEntities(entities);
|
2025-11-21 10:03:18 +08:00
|
|
|
const showRemoteIndicator = isShowingRemote && remoteEntities.length > 0;
|
|
|
|
|
const displaySceneName = isShowingRemote && remoteSceneName ? remoteSceneName : sceneName;
|
2025-11-02 23:50:41 +08:00
|
|
|
|
2025-11-29 23:00:48 +08:00
|
|
|
const totalCount = displayEntities.length;
|
|
|
|
|
const selectedCount = selectedIds.size;
|
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
return (
|
2025-11-29 23:00:48 +08:00
|
|
|
<div className="scene-hierarchy outliner">
|
|
|
|
|
{/* Toolbar */}
|
|
|
|
|
<div className="outliner-toolbar">
|
|
|
|
|
<div className="outliner-toolbar-left">
|
|
|
|
|
<button
|
|
|
|
|
className="outliner-filter-btn"
|
|
|
|
|
onClick={() => setShowFilterMenu(!showFilterMenu)}
|
|
|
|
|
>
|
|
|
|
|
<Filter size={14} />
|
|
|
|
|
<ChevronDown size={10} />
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="outliner-search">
|
|
|
|
|
<Search size={14} />
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder={locale === 'zh' ? '搜索...' : 'Search...'}
|
|
|
|
|
value={searchQuery}
|
|
|
|
|
onChange={(e) => setSearchQuery(e.target.value)}
|
|
|
|
|
/>
|
|
|
|
|
<ChevronDown size={12} className="search-dropdown" />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="outliner-toolbar-right">
|
|
|
|
|
{!isShowingRemote && (
|
|
|
|
|
<button
|
|
|
|
|
className="outliner-action-btn"
|
|
|
|
|
onClick={handleCreateEntity}
|
|
|
|
|
title={locale === 'zh' ? '添加' : 'Add'}
|
|
|
|
|
>
|
|
|
|
|
<Plus size={14} />
|
|
|
|
|
</button>
|
2025-11-23 21:45:10 +08:00
|
|
|
)}
|
2025-11-29 23:00:48 +08:00
|
|
|
<button
|
|
|
|
|
className="outliner-action-btn"
|
|
|
|
|
title={locale === 'zh' ? '设置' : 'Settings'}
|
|
|
|
|
>
|
|
|
|
|
<Settings size={14} />
|
|
|
|
|
</button>
|
2025-11-02 23:50:41 +08:00
|
|
|
</div>
|
2025-11-29 23:00:48 +08:00
|
|
|
|
2025-11-23 21:45:10 +08:00
|
|
|
{isRemoteConnected && !isProfilerMode && (
|
2025-11-21 10:03:18 +08:00
|
|
|
<div className="view-mode-toggle">
|
|
|
|
|
<button
|
|
|
|
|
className={`mode-btn ${viewMode === 'local' ? 'active' : ''}`}
|
|
|
|
|
onClick={() => setViewMode('local')}
|
|
|
|
|
title={locale === 'zh' ? '本地场景' : 'Local Scene'}
|
|
|
|
|
>
|
|
|
|
|
<Monitor size={14} />
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
className={`mode-btn ${viewMode === 'remote' ? 'active' : ''}`}
|
|
|
|
|
onClick={() => setViewMode('remote')}
|
|
|
|
|
title={locale === 'zh' ? '远程实体' : 'Remote Entities'}
|
|
|
|
|
>
|
|
|
|
|
<Globe size={14} />
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-11-29 23:00:48 +08:00
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
{showRemoteIndicator && (
|
|
|
|
|
<div className="remote-indicator" title="Showing remote entities">
|
|
|
|
|
<Wifi size={12} />
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-10-15 23:24:13 +08:00
|
|
|
</div>
|
2025-11-29 23:00:48 +08:00
|
|
|
|
|
|
|
|
{/* Column Headers */}
|
|
|
|
|
<div className="outliner-header">
|
|
|
|
|
<div className="outliner-header-icons">
|
|
|
|
|
<span title={locale === 'zh' ? '可见性' : 'Visibility'}><Eye size={12} className="header-icon" /></span>
|
|
|
|
|
<span title={locale === 'zh' ? '收藏' : 'Favorite'}><Star size={12} className="header-icon" /></span>
|
|
|
|
|
<span title={locale === 'zh' ? '锁定' : 'Lock'}><Lock size={12} className="header-icon" /></span>
|
2025-11-02 23:50:41 +08:00
|
|
|
</div>
|
2025-11-29 23:00:48 +08:00
|
|
|
<div
|
|
|
|
|
className={`outliner-header-label ${sortColumn === 'name' ? 'sorted' : ''}`}
|
|
|
|
|
onClick={() => handleSortClick('name')}
|
|
|
|
|
>
|
|
|
|
|
<span>Item Label</span>
|
|
|
|
|
{sortColumn === 'name' && (
|
|
|
|
|
<span className="sort-indicator">{sortDirection === 'asc' ? '▲' : '▼'}</span>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
className={`outliner-header-type ${sortColumn === 'type' ? 'sorted' : ''}`}
|
|
|
|
|
onClick={() => handleSortClick('type')}
|
|
|
|
|
>
|
|
|
|
|
<span>Type</span>
|
|
|
|
|
{sortColumn === 'type' && (
|
|
|
|
|
<span className="sort-indicator">{sortDirection === 'asc' ? '▲' : '▼'}</span>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Entity List */}
|
|
|
|
|
<div className="outliner-content" onContextMenu={(e) => !isShowingRemote && handleContextMenu(e, null)}>
|
2025-11-02 23:50:41 +08:00
|
|
|
{displayEntities.length === 0 ? (
|
|
|
|
|
<div className="empty-state">
|
2025-11-29 23:00:48 +08:00
|
|
|
<Box size={32} strokeWidth={1.5} className="empty-icon" />
|
2025-11-02 23:50:41 +08:00
|
|
|
<div className="empty-hint">
|
2025-11-21 10:03:18 +08:00
|
|
|
{isShowingRemote
|
2025-11-29 23:00:48 +08:00
|
|
|
? (locale === 'zh' ? '远程游戏中没有实体' : 'No entities in remote game')
|
|
|
|
|
: (locale === 'zh' ? '创建实体开始使用' : 'Create an entity to get started')}
|
2025-11-02 23:50:41 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-11-21 10:03:18 +08:00
|
|
|
) : isShowingRemote ? (
|
2025-11-29 23:00:48 +08:00
|
|
|
<div className="outliner-list">
|
2025-11-02 23:50:41 +08:00
|
|
|
{(displayEntities as RemoteEntity[]).map((entity) => (
|
2025-11-29 23:00:48 +08:00
|
|
|
<div
|
2025-11-02 23:50:41 +08:00
|
|
|
key={entity.id}
|
2025-11-29 23:00:48 +08:00
|
|
|
className={`outliner-item ${selectedIds.has(entity.id) ? 'selected' : ''} ${!entity.enabled ? 'disabled' : ''}`}
|
2025-11-02 23:50:41 +08:00
|
|
|
onClick={() => handleRemoteEntityClick(entity)}
|
|
|
|
|
>
|
2025-11-29 23:00:48 +08:00
|
|
|
<div className="outliner-item-icons">
|
|
|
|
|
<Eye size={12} className="item-icon visibility" />
|
|
|
|
|
</div>
|
|
|
|
|
<div className="outliner-item-content">
|
|
|
|
|
<span className="outliner-item-expand" />
|
|
|
|
|
{getEntityIcon(entity.componentTypes?.[0] || 'Entity')}
|
|
|
|
|
<span className="outliner-item-name">{entity.name}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="outliner-item-type">
|
|
|
|
|
{entity.componentTypes?.[0] || 'Entity'}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-11-02 23:50:41 +08:00
|
|
|
))}
|
2025-11-29 23:00:48 +08:00
|
|
|
</div>
|
2025-11-02 23:50:41 +08:00
|
|
|
) : (
|
2025-11-29 23:00:48 +08:00
|
|
|
<div className="outliner-list">
|
|
|
|
|
{/* World/Scene Root */}
|
|
|
|
|
<div
|
|
|
|
|
className={`outliner-item world-item ${expandedFolders.has(-1) ? 'expanded' : ''}`}
|
|
|
|
|
onClick={() => toggleFolderExpand(-1)}
|
|
|
|
|
>
|
|
|
|
|
<div className="outliner-item-icons">
|
|
|
|
|
<Eye size={12} className="item-icon visibility" />
|
|
|
|
|
</div>
|
|
|
|
|
<div className="outliner-item-content">
|
|
|
|
|
<span
|
|
|
|
|
className="outliner-item-expand"
|
|
|
|
|
onClick={(e) => { e.stopPropagation(); toggleFolderExpand(-1); }}
|
|
|
|
|
>
|
|
|
|
|
{expandedFolders.has(-1) ? <ChevronDown size={12} /> : <ChevronRight size={12} />}
|
|
|
|
|
</span>
|
|
|
|
|
<Mountain size={14} className="entity-type-icon world" />
|
|
|
|
|
<span className="outliner-item-name">{displaySceneName} (Editor)</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="outliner-item-type">World</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Entity Items */}
|
|
|
|
|
{expandedFolders.has(-1) && entities.map((entity, index) => {
|
|
|
|
|
const entityType = getEntityType(entity);
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
key={entity.id}
|
|
|
|
|
className={`outliner-item ${selectedIds.has(entity.id) ? 'selected' : ''} ${draggedEntityId === entity.id ? 'dragging' : ''} ${dropTargetIndex === index ? 'drop-target' : ''}`}
|
|
|
|
|
style={{ paddingLeft: '32px' }}
|
|
|
|
|
draggable
|
|
|
|
|
onClick={(e) => handleEntityClick(entity, e)}
|
|
|
|
|
onDragStart={(e) => handleDragStart(e, entity.id)}
|
|
|
|
|
onDragOver={(e) => handleDragOver(e, index)}
|
|
|
|
|
onDragLeave={handleDragLeave}
|
|
|
|
|
onDrop={(e) => handleDrop(e, index)}
|
|
|
|
|
onDragEnd={handleDragEnd}
|
|
|
|
|
onContextMenu={(e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
handleEntityClick(entity, e);
|
|
|
|
|
handleContextMenu(e, entity.id);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div className="outliner-item-icons">
|
|
|
|
|
<Eye size={12} className="item-icon visibility" />
|
|
|
|
|
</div>
|
|
|
|
|
<div className="outliner-item-content">
|
|
|
|
|
<span className="outliner-item-expand" />
|
|
|
|
|
{getEntityIcon(entityType)}
|
|
|
|
|
<span className="outliner-item-name">{entity.name || `Entity ${entity.id}`}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="outliner-item-type">{entityType}</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Status Bar */}
|
|
|
|
|
<div className="outliner-status">
|
|
|
|
|
<span>{totalCount} {locale === 'zh' ? '个对象' : 'actors'}</span>
|
|
|
|
|
{selectedCount > 0 && (
|
|
|
|
|
<span> ({selectedCount} {locale === 'zh' ? '个已选中' : 'selected'})</span>
|
2025-10-15 23:24:13 +08:00
|
|
|
)}
|
2025-11-02 23:50:41 +08:00
|
|
|
</div>
|
2025-11-21 10:03:18 +08:00
|
|
|
|
|
|
|
|
{contextMenu && !isShowingRemote && (
|
2025-11-26 11:08:10 +08:00
|
|
|
<ContextMenuWithSubmenu
|
|
|
|
|
x={contextMenu.x}
|
|
|
|
|
y={contextMenu.y}
|
|
|
|
|
locale={locale}
|
|
|
|
|
entityId={contextMenu.entityId}
|
|
|
|
|
pluginTemplates={pluginTemplates}
|
|
|
|
|
onCreateEmpty={() => { handleCreateEntity(); closeContextMenu(); }}
|
|
|
|
|
onCreateFromTemplate={async (template) => {
|
|
|
|
|
await template.create(contextMenu.entityId ?? undefined);
|
|
|
|
|
closeContextMenu();
|
2025-11-21 10:03:18 +08:00
|
|
|
}}
|
2025-11-26 11:08:10 +08:00
|
|
|
onDelete={() => { handleDeleteEntity(); closeContextMenu(); }}
|
|
|
|
|
onClose={closeContextMenu}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ContextMenuWithSubmenuProps {
|
|
|
|
|
x: number;
|
|
|
|
|
y: number;
|
|
|
|
|
locale: string;
|
|
|
|
|
entityId: number | null;
|
|
|
|
|
pluginTemplates: EntityCreationTemplate[];
|
|
|
|
|
onCreateEmpty: () => void;
|
|
|
|
|
onCreateFromTemplate: (template: EntityCreationTemplate) => void;
|
|
|
|
|
onDelete: () => void;
|
|
|
|
|
onClose: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ContextMenuWithSubmenu({
|
|
|
|
|
x, y, locale, entityId, pluginTemplates,
|
2025-11-27 20:42:46 +08:00
|
|
|
onCreateEmpty, onCreateFromTemplate, onDelete
|
2025-11-26 11:08:10 +08:00
|
|
|
}: ContextMenuWithSubmenuProps) {
|
|
|
|
|
const [activeSubmenu, setActiveSubmenu] = useState<string | null>(null);
|
|
|
|
|
const [submenuPosition, setSubmenuPosition] = useState<{ x: number; y: number }>({ x: 0, y: 0 });
|
|
|
|
|
const menuRef = useRef<HTMLDivElement>(null);
|
|
|
|
|
|
|
|
|
|
const categoryLabels: Record<string, { zh: string; en: string }> = {
|
|
|
|
|
'basic': { zh: '基础', en: 'Basic' },
|
2025-11-27 20:42:46 +08:00
|
|
|
'rendering': { zh: '2D 对象', en: '2D Objects' },
|
2025-11-26 11:08:10 +08:00
|
|
|
'ui': { zh: 'UI', en: 'UI' },
|
|
|
|
|
'physics': { zh: '物理', en: 'Physics' },
|
|
|
|
|
'audio': { zh: '音频', en: 'Audio' },
|
|
|
|
|
'other': { zh: '其他', en: 'Other' },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getCategoryLabel = (category: string) => {
|
|
|
|
|
const labels = categoryLabels[category];
|
|
|
|
|
return labels ? (locale === 'zh' ? labels.zh : labels.en) : category;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const templatesByCategory = pluginTemplates.reduce((acc, template) => {
|
|
|
|
|
const cat = template.category || 'other';
|
|
|
|
|
if (!acc[cat]) acc[cat] = [];
|
|
|
|
|
acc[cat].push(template);
|
|
|
|
|
return acc;
|
|
|
|
|
}, {} as Record<string, EntityCreationTemplate[]>);
|
|
|
|
|
|
2025-11-27 20:42:46 +08:00
|
|
|
Object.values(templatesByCategory).forEach(templates => {
|
|
|
|
|
templates.sort((a, b) => (a.order ?? 100) - (b.order ?? 100));
|
|
|
|
|
});
|
2025-11-26 11:08:10 +08:00
|
|
|
|
|
|
|
|
const handleSubmenuEnter = (category: string, e: React.MouseEvent) => {
|
|
|
|
|
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
|
|
|
|
|
setSubmenuPosition({ x: rect.right - 4, y: rect.top });
|
|
|
|
|
setActiveSubmenu(category);
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-27 20:42:46 +08:00
|
|
|
const categoryOrder = ['rendering', 'ui', 'physics', 'audio', 'basic', 'other'];
|
|
|
|
|
const sortedCategories = Object.entries(templatesByCategory).sort(([a], [b]) => {
|
|
|
|
|
const orderA = categoryOrder.indexOf(a);
|
|
|
|
|
const orderB = categoryOrder.indexOf(b);
|
|
|
|
|
return (orderA === -1 ? 999 : orderA) - (orderB === -1 ? 999 : orderB);
|
|
|
|
|
});
|
|
|
|
|
|
2025-11-26 11:08:10 +08:00
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
ref={menuRef}
|
|
|
|
|
className="context-menu"
|
|
|
|
|
style={{ position: 'fixed', left: x, top: y, zIndex: 1000 }}
|
|
|
|
|
>
|
|
|
|
|
<button onClick={onCreateEmpty}>
|
|
|
|
|
<Plus size={12} />
|
|
|
|
|
<span>{locale === 'zh' ? '创建空实体' : 'Create Empty Entity'}</span>
|
|
|
|
|
</button>
|
|
|
|
|
|
2025-11-27 20:42:46 +08:00
|
|
|
{sortedCategories.length > 0 && <div className="context-menu-divider" />}
|
2025-11-26 11:08:10 +08:00
|
|
|
|
2025-11-27 20:42:46 +08:00
|
|
|
{sortedCategories.map(([category, templates]) => (
|
2025-11-26 11:08:10 +08:00
|
|
|
<div
|
|
|
|
|
key={category}
|
|
|
|
|
className="context-menu-item-with-submenu"
|
|
|
|
|
onMouseEnter={(e) => handleSubmenuEnter(category, e)}
|
|
|
|
|
onMouseLeave={() => setActiveSubmenu(null)}
|
2025-11-21 10:03:18 +08:00
|
|
|
>
|
2025-11-26 11:08:10 +08:00
|
|
|
<button>
|
2025-11-27 20:42:46 +08:00
|
|
|
{getIconComponent(categoryIconMap[category], 12)}
|
2025-11-26 11:08:10 +08:00
|
|
|
<span>{getCategoryLabel(category)}</span>
|
|
|
|
|
<ChevronRight size={12} className="submenu-arrow" />
|
2025-11-21 10:03:18 +08:00
|
|
|
</button>
|
2025-11-26 11:08:10 +08:00
|
|
|
{activeSubmenu === category && (
|
|
|
|
|
<div
|
|
|
|
|
className="context-submenu"
|
|
|
|
|
style={{ left: submenuPosition.x, top: submenuPosition.y }}
|
|
|
|
|
onMouseEnter={() => setActiveSubmenu(category)}
|
|
|
|
|
>
|
|
|
|
|
{templates.map((template) => (
|
|
|
|
|
<button key={template.id} onClick={() => onCreateFromTemplate(template)}>
|
2025-11-27 20:42:46 +08:00
|
|
|
{getIconComponent(template.icon as string, 12)}
|
2025-11-25 22:23:19 +08:00
|
|
|
<span>{template.label}</span>
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
2025-11-26 11:08:10 +08:00
|
|
|
</div>
|
2025-11-21 10:03:18 +08:00
|
|
|
)}
|
|
|
|
|
</div>
|
2025-11-26 11:08:10 +08:00
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
{entityId && (
|
|
|
|
|
<>
|
|
|
|
|
<div className="context-menu-divider" />
|
|
|
|
|
<button onClick={onDelete} className="context-menu-danger">
|
|
|
|
|
<Trash2 size={12} />
|
|
|
|
|
<span>{locale === 'zh' ? '删除实体' : 'Delete Entity'}</span>
|
|
|
|
|
</button>
|
|
|
|
|
</>
|
2025-11-21 10:03:18 +08:00
|
|
|
)}
|
2025-11-02 23:50:41 +08:00
|
|
|
</div>
|
|
|
|
|
);
|
2025-10-14 23:31:09 +08:00
|
|
|
}
|