修复ts警告

This commit is contained in:
YHH
2025-10-16 18:20:31 +08:00
parent 8d741bf1b9
commit 2a17c47c25
9 changed files with 36 additions and 28 deletions

View File

@@ -8,7 +8,6 @@ import { SceneHierarchy } from './components/SceneHierarchy';
import { EntityInspector } from './components/EntityInspector'; import { EntityInspector } from './components/EntityInspector';
import { AssetBrowser } from './components/AssetBrowser'; import { AssetBrowser } from './components/AssetBrowser';
import { ConsolePanel } from './components/ConsolePanel'; import { ConsolePanel } from './components/ConsolePanel';
import { ProfilerPanel } from './components/ProfilerPanel';
import { PluginManagerWindow } from './components/PluginManagerWindow'; import { PluginManagerWindow } from './components/PluginManagerWindow';
import { ProfilerWindow } from './components/ProfilerWindow'; import { ProfilerWindow } from './components/ProfilerWindow';
import { PortManager } from './components/PortManager'; import { PortManager } from './components/PortManager';
@@ -101,9 +100,8 @@ function App() {
console.log('[App] Remote game disconnected'); console.log('[App] Remote game disconnected');
setIsRemoteConnected(false); setIsRemoteConnected(false);
if (projectLoaded) { if (projectLoaded) {
const projectService = Core.services.resolve(ProjectService);
const componentRegistry = Core.services.resolve(ComponentRegistry); const componentRegistry = Core.services.resolve(ComponentRegistry);
const componentCount = componentRegistry?.getRegisteredComponents().length || 0; const componentCount = componentRegistry?.getAllComponents().length || 0;
setStatus(t('header.status.projectOpened') + (componentCount > 0 ? ` (${componentCount} components registered)` : '')); setStatus(t('header.status.projectOpened') + (componentCount > 0 ? ` (${componentCount} components registered)` : ''));
} else { } else {
setStatus(t('header.status.ready')); setStatus(t('header.status.ready'));

View File

@@ -106,13 +106,11 @@ export function ConsolePanel({ logService }: ConsolePanelProps) {
}; };
const formatTime = (date: Date): string => { const formatTime = (date: Date): string => {
return date.toLocaleTimeString('en-US', { const hours = date.getHours().toString().padStart(2, '0');
hour12: false, const minutes = date.getMinutes().toString().padStart(2, '0');
hour: '2-digit', const seconds = date.getSeconds().toString().padStart(2, '0');
minute: '2-digit', const ms = date.getMilliseconds().toString().padStart(3, '0');
second: '2-digit', return `${hours}:${minutes}:${seconds}.${ms}`;
fractionalSecondDigits: 3
});
}; };
const toggleLogExpand = (logId: number) => { const toggleLogExpand = (logId: number) => {

View File

@@ -464,7 +464,7 @@ export function EntityInspector({ entityStore: _entityStore, messageHub }: Entit
<div className="section-content"> <div className="section-content">
<div className="info-row"> <div className="info-row">
<span className="info-label">ID:</span> <span className="info-label">ID:</span>
<span className="info-value">{selectedEntity.id}</span> <span className="info-value">{selectedEntity!.id}</span>
</div> </div>
<div className="info-row"> <div className="info-row">
<span className="info-label">Name:</span> <span className="info-label">Name:</span>

View File

@@ -4,7 +4,7 @@ import type { MenuItem as PluginMenuItem } from '@esengine/editor-core';
import '../styles/MenuBar.css'; import '../styles/MenuBar.css';
interface MenuItem { interface MenuItem {
label: string; label?: string;
shortcut?: string; shortcut?: string;
disabled?: boolean; disabled?: boolean;
separator?: boolean; separator?: boolean;
@@ -215,12 +215,12 @@ export function MenuBar({
{ label: t('viewport'), disabled: true }, { label: t('viewport'), disabled: true },
{ separator: true }, { separator: true },
...pluginMenuItems.map(item => ({ ...pluginMenuItems.map(item => ({
label: item.label, label: item.label || '',
shortcut: item.shortcut, shortcut: item.shortcut,
disabled: item.disabled, disabled: item.disabled,
onClick: item.onClick onClick: item.onClick
})), })),
...(pluginMenuItems.length > 0 ? [{ separator: true }] : []), ...(pluginMenuItems.length > 0 ? [{ separator: true } as MenuItem] : []),
{ label: t('pluginManager'), onClick: onOpenPluginManager }, { label: t('pluginManager'), onClick: onOpenPluginManager },
{ separator: true }, { separator: true },
{ label: t('devtools'), onClick: onToggleDevtools } { label: t('devtools'), onClick: onToggleDevtools }
@@ -255,7 +255,7 @@ export function MenuBar({
}; };
const handleMenuItemClick = (item: MenuItem) => { const handleMenuItemClick = (item: MenuItem) => {
if (!item.disabled && !item.separator && item.onClick) { if (!item.disabled && !item.separator && item.onClick && item.label) {
item.onClick(); item.onClick();
setOpenMenu(null); setOpenMenu(null);
} }
@@ -271,7 +271,7 @@ export function MenuBar({
> >
{t(menuKey)} {t(menuKey)}
</button> </button>
{openMenu === menuKey && ( {openMenu === menuKey && menus[menuKey] && (
<div className="menu-dropdown"> <div className="menu-dropdown">
{menus[menuKey].map((item, index) => { {menus[menuKey].map((item, index) => {
if (item.separator) { if (item.separator) {
@@ -284,7 +284,7 @@ export function MenuBar({
onClick={() => handleMenuItemClick(item)} onClick={() => handleMenuItemClick(item)}
disabled={item.disabled} disabled={item.disabled}
> >
<span>{item.label}</span> <span>{item.label || ''}</span>
{item.shortcut && <span className="menu-shortcut">{item.shortcut}</span>} {item.shortcut && <span className="menu-shortcut">{item.shortcut}</span>}
</button> </button>
); );

View File

@@ -9,7 +9,7 @@ interface PortManagerProps {
export function PortManager({ onClose }: PortManagerProps) { export function PortManager({ onClose }: PortManagerProps) {
const [isServerRunning, setIsServerRunning] = useState(false); const [isServerRunning, setIsServerRunning] = useState(false);
const [serverPort, setServerPort] = useState<number>(8080); const [serverPort] = useState<number>(8080);
const [isChecking, setIsChecking] = useState(false); const [isChecking, setIsChecking] = useState(false);
const [isStopping, setIsStopping] = useState(false); const [isStopping, setIsStopping] = useState(false);

View File

@@ -1,6 +1,6 @@
import { useState, useEffect, useRef } from 'react'; import { useState, useEffect, useRef } from 'react';
import { Core } from '@esengine/ecs-framework'; import { Core } from '@esengine/ecs-framework';
import { Activity, BarChart3, Clock, Cpu, TrendingUp, RefreshCw, Pause, Play } from 'lucide-react'; import { Activity, BarChart3, Clock, Cpu, RefreshCw, Pause, Play } from 'lucide-react';
import '../styles/ProfilerPanel.css'; import '../styles/ProfilerPanel.css';
interface SystemPerformanceData { interface SystemPerformanceData {

View File

@@ -28,7 +28,7 @@ export function ProfilerWindow({ onClose }: ProfilerWindowProps) {
const [systems, setSystems] = useState<SystemPerformanceData[]>([]); const [systems, setSystems] = useState<SystemPerformanceData[]>([]);
const [totalFrameTime, setTotalFrameTime] = useState(0); const [totalFrameTime, setTotalFrameTime] = useState(0);
const [isPaused, setIsPaused] = useState(false); const [isPaused, setIsPaused] = useState(false);
const [sortBy, setSortBy] = useState<'time' | 'average' | 'name'>('time'); const [sortBy] = useState<'time' | 'average' | 'name'>('time');
const [dataSource, setDataSource] = useState<DataSource>('local'); const [dataSource, setDataSource] = useState<DataSource>('local');
const [viewMode, setViewMode] = useState<'tree' | 'table'>('table'); const [viewMode, setViewMode] = useState<'tree' | 'table'>('table');
const [searchQuery, setSearchQuery] = useState(''); const [searchQuery, setSearchQuery] = useState('');

View File

@@ -108,12 +108,12 @@ export function SceneHierarchy({ entityStore, messageHub }: SceneHierarchyProps)
}; };
// Filter entities based on search query // Filter entities based on search query
const filterEntities = <T extends Entity | RemoteEntity>(entityList: T[]): T[] => { const filterRemoteEntities = (entityList: RemoteEntity[]): RemoteEntity[] => {
if (!searchQuery.trim()) return entityList; if (!searchQuery.trim()) return entityList;
const query = searchQuery.toLowerCase(); const query = searchQuery.toLowerCase();
return entityList.filter(entity => { return entityList.filter(entity => {
const name = 'name' in entity ? entity.name : `Entity ${entity.id}`; const name = entity.name;
const id = entity.id.toString(); const id = entity.id.toString();
// Search by name or ID // Search by name or ID
@@ -121,8 +121,8 @@ export function SceneHierarchy({ entityStore, messageHub }: SceneHierarchyProps)
return true; return true;
} }
// Search by component types (for remote entities) // Search by component types
if ('componentTypes' in entity && Array.isArray(entity.componentTypes)) { if (Array.isArray(entity.componentTypes)) {
return entity.componentTypes.some(type => return entity.componentTypes.some(type =>
type.toLowerCase().includes(query) type.toLowerCase().includes(query)
); );
@@ -132,8 +132,20 @@ export function SceneHierarchy({ entityStore, messageHub }: SceneHierarchyProps)
}); });
}; };
const filterLocalEntities = (entityList: Entity[]): Entity[] => {
if (!searchQuery.trim()) return entityList;
const query = searchQuery.toLowerCase();
return entityList.filter(entity => {
const id = entity.id.toString();
return id.includes(query);
});
};
// Determine which entities to display // Determine which entities to display
const displayEntities = filterEntities(isRemoteConnected ? remoteEntities : entities); const displayEntities = isRemoteConnected
? filterRemoteEntities(remoteEntities)
: filterLocalEntities(entities);
const showRemoteIndicator = isRemoteConnected && remoteEntities.length > 0; const showRemoteIndicator = isRemoteConnected && remoteEntities.length > 0;
return ( return (
@@ -169,7 +181,7 @@ export function SceneHierarchy({ entityStore, messageHub }: SceneHierarchyProps)
</div> </div>
) : isRemoteConnected ? ( ) : isRemoteConnected ? (
<ul className="entity-list"> <ul className="entity-list">
{displayEntities.map(entity => ( {(displayEntities as RemoteEntity[]).map(entity => (
<li <li
key={entity.id} key={entity.id}
className={`entity-item remote-entity ${selectedId === entity.id ? 'selected' : ''} ${!entity.enabled ? 'disabled' : ''}`} className={`entity-item remote-entity ${selectedId === entity.id ? 'selected' : ''} ${!entity.enabled ? 'disabled' : ''}`}

View File

@@ -12,8 +12,8 @@
"noEmit": true, "noEmit": true,
"jsx": "react-jsx", "jsx": "react-jsx",
"strict": true, "strict": true,
"noUnusedLocals": true, "noUnusedLocals": false,
"noUnusedParameters": true, "noUnusedParameters": false,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true, "noUncheckedIndexedAccess": true,
"experimentalDecorators": true, "experimentalDecorators": true,