2025-11-18 14:46:51 +08:00
|
|
|
|
import { useState, useEffect, useMemo } from 'react';
|
2025-10-15 20:10:52 +08:00
|
|
|
|
import { EditorPluginManager, IEditorPluginMetadata, EditorPluginCategory } from '@esengine/editor-core';
|
2025-10-27 09:29:11 +08:00
|
|
|
|
import * as LucideIcons from 'lucide-react';
|
2025-11-18 14:46:51 +08:00
|
|
|
|
import {
|
|
|
|
|
|
Package,
|
|
|
|
|
|
CheckCircle,
|
|
|
|
|
|
XCircle,
|
|
|
|
|
|
Search,
|
|
|
|
|
|
Grid,
|
|
|
|
|
|
List,
|
|
|
|
|
|
ChevronDown,
|
|
|
|
|
|
ChevronRight,
|
|
|
|
|
|
X,
|
|
|
|
|
|
RefreshCw,
|
|
|
|
|
|
ShoppingCart
|
|
|
|
|
|
} from 'lucide-react';
|
|
|
|
|
|
import { PluginMarketPanel } from './PluginMarketPanel';
|
|
|
|
|
|
import { PluginMarketService } from '../services/PluginMarketService';
|
|
|
|
|
|
import { GitHubService } from '../services/GitHubService';
|
2025-10-15 20:10:52 +08:00
|
|
|
|
import '../styles/PluginManagerWindow.css';
|
|
|
|
|
|
|
|
|
|
|
|
interface PluginManagerWindowProps {
|
|
|
|
|
|
pluginManager: EditorPluginManager;
|
2025-11-18 14:46:51 +08:00
|
|
|
|
githubService: GitHubService;
|
2025-10-15 20:10:52 +08:00
|
|
|
|
onClose: () => void;
|
2025-10-28 17:19:28 +08:00
|
|
|
|
onRefresh?: () => Promise<void>;
|
|
|
|
|
|
onOpen?: () => void;
|
|
|
|
|
|
locale: string;
|
2025-11-18 14:46:51 +08:00
|
|
|
|
projectPath: string | null;
|
2025-10-15 20:10:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const categoryIcons: Record<EditorPluginCategory, string> = {
|
2025-10-27 09:29:11 +08:00
|
|
|
|
[EditorPluginCategory.Tool]: 'Wrench',
|
|
|
|
|
|
[EditorPluginCategory.Window]: 'LayoutGrid',
|
|
|
|
|
|
[EditorPluginCategory.Inspector]: 'Search',
|
|
|
|
|
|
[EditorPluginCategory.System]: 'Settings',
|
|
|
|
|
|
[EditorPluginCategory.ImportExport]: 'Package'
|
2025-10-15 20:10:52 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-11-18 14:46:51 +08:00
|
|
|
|
export function PluginManagerWindow({ pluginManager, githubService, onClose, onRefresh, onOpen, locale, projectPath }: PluginManagerWindowProps) {
|
2025-10-28 17:19:28 +08:00
|
|
|
|
const t = (key: string) => {
|
|
|
|
|
|
const translations: Record<string, Record<string, string>> = {
|
|
|
|
|
|
zh: {
|
|
|
|
|
|
title: '插件管理器',
|
|
|
|
|
|
searchPlaceholder: '搜索插件...',
|
|
|
|
|
|
enabled: '已启用',
|
|
|
|
|
|
disabled: '已禁用',
|
|
|
|
|
|
enable: '启用',
|
|
|
|
|
|
disable: '禁用',
|
|
|
|
|
|
enablePlugin: '启用插件',
|
|
|
|
|
|
disablePlugin: '禁用插件',
|
|
|
|
|
|
refresh: '刷新',
|
|
|
|
|
|
refreshPluginList: '刷新插件列表',
|
|
|
|
|
|
close: '关闭',
|
|
|
|
|
|
listView: '列表视图',
|
|
|
|
|
|
gridView: '网格视图',
|
|
|
|
|
|
noPlugins: '未安装插件',
|
|
|
|
|
|
installed: '安装于',
|
|
|
|
|
|
categoryTools: '工具',
|
|
|
|
|
|
categoryWindows: '窗口',
|
|
|
|
|
|
categoryInspectors: '检查器',
|
|
|
|
|
|
categorySystem: '系统',
|
2025-11-18 14:46:51 +08:00
|
|
|
|
categoryImportExport: '导入/导出',
|
|
|
|
|
|
tabInstalled: '已安装',
|
|
|
|
|
|
tabMarketplace: '插件市场'
|
2025-10-28 17:19:28 +08:00
|
|
|
|
},
|
|
|
|
|
|
en: {
|
|
|
|
|
|
title: 'Plugin Manager',
|
|
|
|
|
|
searchPlaceholder: 'Search plugins...',
|
|
|
|
|
|
enabled: 'Enabled',
|
|
|
|
|
|
disabled: 'Disabled',
|
|
|
|
|
|
enable: 'Enable',
|
|
|
|
|
|
disable: 'Disable',
|
|
|
|
|
|
enablePlugin: 'Enable plugin',
|
|
|
|
|
|
disablePlugin: 'Disable plugin',
|
|
|
|
|
|
refresh: 'Refresh',
|
|
|
|
|
|
refreshPluginList: 'Refresh plugin list',
|
|
|
|
|
|
close: 'Close',
|
|
|
|
|
|
listView: 'List view',
|
|
|
|
|
|
gridView: 'Grid view',
|
|
|
|
|
|
noPlugins: 'No plugins installed',
|
|
|
|
|
|
installed: 'Installed',
|
|
|
|
|
|
categoryTools: 'Tools',
|
|
|
|
|
|
categoryWindows: 'Windows',
|
|
|
|
|
|
categoryInspectors: 'Inspectors',
|
|
|
|
|
|
categorySystem: 'System',
|
2025-11-18 14:46:51 +08:00
|
|
|
|
categoryImportExport: 'Import/Export',
|
|
|
|
|
|
tabInstalled: 'Installed',
|
|
|
|
|
|
tabMarketplace: 'Marketplace'
|
2025-10-28 17:19:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
return translations[locale]?.[key] || translations.en?.[key] || key;
|
|
|
|
|
|
};
|
2025-10-15 20:10:52 +08:00
|
|
|
|
|
2025-10-28 17:19:28 +08:00
|
|
|
|
const getCategoryName = (category: EditorPluginCategory): string => {
|
|
|
|
|
|
const categoryKeys: Record<EditorPluginCategory, string> = {
|
|
|
|
|
|
[EditorPluginCategory.Tool]: 'categoryTools',
|
|
|
|
|
|
[EditorPluginCategory.Window]: 'categoryWindows',
|
|
|
|
|
|
[EditorPluginCategory.Inspector]: 'categoryInspectors',
|
|
|
|
|
|
[EditorPluginCategory.System]: 'categorySystem',
|
|
|
|
|
|
[EditorPluginCategory.ImportExport]: 'categoryImportExport'
|
|
|
|
|
|
};
|
|
|
|
|
|
return t(categoryKeys[category]);
|
|
|
|
|
|
};
|
2025-11-18 14:46:51 +08:00
|
|
|
|
const [activeTab, setActiveTab] = useState<'installed' | 'marketplace'>('installed');
|
2025-10-15 20:10:52 +08:00
|
|
|
|
const [plugins, setPlugins] = useState<IEditorPluginMetadata[]>([]);
|
|
|
|
|
|
const [filter, setFilter] = useState('');
|
|
|
|
|
|
const [viewMode, setViewMode] = useState<'grid' | 'list'>('list');
|
|
|
|
|
|
const [expandedCategories, setExpandedCategories] = useState<Set<EditorPluginCategory>>(
|
|
|
|
|
|
new Set(Object.values(EditorPluginCategory))
|
|
|
|
|
|
);
|
2025-10-28 17:19:28 +08:00
|
|
|
|
const [isRefreshing, setIsRefreshing] = useState(false);
|
2025-10-15 20:10:52 +08:00
|
|
|
|
|
2025-11-18 14:46:51 +08:00
|
|
|
|
const marketService = useMemo(() => new PluginMarketService(pluginManager), [pluginManager]);
|
|
|
|
|
|
|
|
|
|
|
|
// 设置项目路径到 marketService
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
marketService.setProjectPath(projectPath);
|
|
|
|
|
|
}, [projectPath, marketService]);
|
|
|
|
|
|
|
2025-10-28 17:19:28 +08:00
|
|
|
|
const updatePluginList = () => {
|
|
|
|
|
|
const allPlugins = pluginManager.getAllPluginMetadata();
|
|
|
|
|
|
setPlugins(allPlugins);
|
|
|
|
|
|
};
|
2025-10-15 20:10:52 +08:00
|
|
|
|
|
2025-10-28 17:19:28 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (onOpen) {
|
|
|
|
|
|
onOpen();
|
|
|
|
|
|
}
|
|
|
|
|
|
updatePluginList();
|
2025-10-15 20:10:52 +08:00
|
|
|
|
}, [pluginManager]);
|
|
|
|
|
|
|
2025-10-28 17:19:28 +08:00
|
|
|
|
// 监听 locale 变化,重新获取插件列表(以刷新插件的 displayName 和 description)
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
updatePluginList();
|
|
|
|
|
|
}, [locale]);
|
|
|
|
|
|
|
|
|
|
|
|
const handleRefresh = async () => {
|
|
|
|
|
|
if (!onRefresh || isRefreshing) return;
|
|
|
|
|
|
|
|
|
|
|
|
setIsRefreshing(true);
|
|
|
|
|
|
try {
|
|
|
|
|
|
await onRefresh();
|
|
|
|
|
|
updatePluginList();
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('Failed to refresh plugins:', error);
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setIsRefreshing(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-10-15 20:10:52 +08:00
|
|
|
|
const togglePlugin = async (name: string, enabled: boolean) => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (enabled) {
|
|
|
|
|
|
await pluginManager.disablePlugin(name);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
await pluginManager.enablePlugin(name);
|
|
|
|
|
|
}
|
|
|
|
|
|
const allPlugins = pluginManager.getAllPluginMetadata();
|
|
|
|
|
|
setPlugins(allPlugins);
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error(`Failed to toggle plugin ${name}:`, error);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const toggleCategory = (category: EditorPluginCategory) => {
|
|
|
|
|
|
const newExpanded = new Set(expandedCategories);
|
|
|
|
|
|
if (newExpanded.has(category)) {
|
|
|
|
|
|
newExpanded.delete(category);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
newExpanded.add(category);
|
|
|
|
|
|
}
|
|
|
|
|
|
setExpandedCategories(newExpanded);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
const filteredPlugins = plugins.filter((plugin) => {
|
2025-10-15 20:10:52 +08:00
|
|
|
|
if (!filter) return true;
|
|
|
|
|
|
const searchLower = filter.toLowerCase();
|
|
|
|
|
|
return (
|
|
|
|
|
|
plugin.name.toLowerCase().includes(searchLower) ||
|
|
|
|
|
|
plugin.displayName.toLowerCase().includes(searchLower) ||
|
|
|
|
|
|
plugin.description?.toLowerCase().includes(searchLower)
|
|
|
|
|
|
);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-11-18 14:46:51 +08:00
|
|
|
|
const pluginsByCategory = filteredPlugins.reduce(
|
|
|
|
|
|
(acc, plugin) => {
|
|
|
|
|
|
if (!acc[plugin.category]) {
|
|
|
|
|
|
acc[plugin.category] = [];
|
|
|
|
|
|
}
|
|
|
|
|
|
acc[plugin.category].push(plugin);
|
|
|
|
|
|
return acc;
|
|
|
|
|
|
},
|
|
|
|
|
|
{} as Record<EditorPluginCategory, IEditorPluginMetadata[]>
|
|
|
|
|
|
);
|
2025-10-15 20:10:52 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
const enabledCount = plugins.filter((p) => p.enabled).length;
|
|
|
|
|
|
const disabledCount = plugins.filter((p) => !p.enabled).length;
|
2025-10-15 20:10:52 +08:00
|
|
|
|
|
2025-10-27 09:29:11 +08:00
|
|
|
|
const renderPluginCard = (plugin: IEditorPluginMetadata) => {
|
|
|
|
|
|
const IconComponent = plugin.icon ? (LucideIcons as any)[plugin.icon] : null;
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div key={plugin.name} className={`plugin-card ${plugin.enabled ? 'enabled' : 'disabled'}`}>
|
|
|
|
|
|
<div className="plugin-card-header">
|
|
|
|
|
|
<div className="plugin-card-icon">
|
|
|
|
|
|
{IconComponent ? <IconComponent size={24} /> : <Package size={24} />}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="plugin-card-info">
|
|
|
|
|
|
<div className="plugin-card-title">{plugin.displayName}</div>
|
|
|
|
|
|
<div className="plugin-card-version">v{plugin.version}</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<button
|
|
|
|
|
|
className={`plugin-toggle ${plugin.enabled ? 'enabled' : 'disabled'}`}
|
|
|
|
|
|
onClick={() => togglePlugin(plugin.name, plugin.enabled)}
|
2025-10-28 17:19:28 +08:00
|
|
|
|
title={plugin.enabled ? t('disablePlugin') : t('enablePlugin')}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
>
|
|
|
|
|
|
{plugin.enabled ? <CheckCircle size={18} /> : <XCircle size={18} />}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
2025-11-18 14:46:51 +08:00
|
|
|
|
{plugin.description && <div className="plugin-card-description">{plugin.description}</div>}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
<div className="plugin-card-footer">
|
|
|
|
|
|
<span className="plugin-card-category">
|
|
|
|
|
|
{(() => {
|
|
|
|
|
|
const CategoryIcon = (LucideIcons as any)[categoryIcons[plugin.category]];
|
|
|
|
|
|
return CategoryIcon ? <CategoryIcon size={14} style={{ marginRight: '4px' }} /> : null;
|
|
|
|
|
|
})()}
|
2025-10-28 17:19:28 +08:00
|
|
|
|
{getCategoryName(plugin.category)}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
{plugin.installedAt && (
|
|
|
|
|
|
<span className="plugin-card-installed">
|
2025-10-28 17:19:28 +08:00
|
|
|
|
{t('installed')}: {new Date(plugin.installedAt).toLocaleDateString()}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const renderPluginList = (plugin: IEditorPluginMetadata) => {
|
|
|
|
|
|
const IconComponent = plugin.icon ? (LucideIcons as any)[plugin.icon] : null;
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div key={plugin.name} className={`plugin-list-item ${plugin.enabled ? 'enabled' : 'disabled'}`}>
|
|
|
|
|
|
<div className="plugin-list-icon">
|
|
|
|
|
|
{IconComponent ? <IconComponent size={20} /> : <Package size={20} />}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="plugin-list-info">
|
|
|
|
|
|
<div className="plugin-list-name">
|
|
|
|
|
|
{plugin.displayName}
|
|
|
|
|
|
<span className="plugin-list-version">v{plugin.version}</span>
|
|
|
|
|
|
</div>
|
2025-11-18 14:46:51 +08:00
|
|
|
|
{plugin.description && <div className="plugin-list-description">{plugin.description}</div>}
|
2025-10-15 20:10:52 +08:00
|
|
|
|
</div>
|
2025-10-27 09:29:11 +08:00
|
|
|
|
<div className="plugin-list-status">
|
|
|
|
|
|
{plugin.enabled ? (
|
2025-10-28 17:19:28 +08:00
|
|
|
|
<span className="status-badge enabled">{t('enabled')}</span>
|
2025-10-27 09:29:11 +08:00
|
|
|
|
) : (
|
2025-10-28 17:19:28 +08:00
|
|
|
|
<span className="status-badge disabled">{t('disabled')}</span>
|
2025-10-27 09:29:11 +08:00
|
|
|
|
)}
|
2025-10-15 20:10:52 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<button
|
2025-10-27 09:29:11 +08:00
|
|
|
|
className="plugin-list-toggle"
|
2025-10-15 20:10:52 +08:00
|
|
|
|
onClick={() => togglePlugin(plugin.name, plugin.enabled)}
|
2025-10-28 17:19:28 +08:00
|
|
|
|
title={plugin.enabled ? t('disablePlugin') : t('enablePlugin')}
|
2025-10-15 20:10:52 +08:00
|
|
|
|
>
|
2025-10-28 17:19:28 +08:00
|
|
|
|
{plugin.enabled ? t('disable') : t('enable')}
|
2025-10-15 20:10:52 +08:00
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
2025-10-27 09:29:11 +08:00
|
|
|
|
);
|
|
|
|
|
|
};
|
2025-10-15 20:10:52 +08:00
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className="plugin-manager-overlay" onClick={onClose}>
|
|
|
|
|
|
<div className="plugin-manager-window" onClick={(e) => e.stopPropagation()}>
|
|
|
|
|
|
<div className="plugin-manager-header">
|
|
|
|
|
|
<div className="plugin-manager-title">
|
|
|
|
|
|
<Package size={20} />
|
2025-10-28 17:19:28 +08:00
|
|
|
|
<h2>{t('title')}</h2>
|
2025-10-15 20:10:52 +08:00
|
|
|
|
</div>
|
2025-10-28 17:19:28 +08:00
|
|
|
|
<button className="plugin-manager-close" onClick={onClose} title={t('close')}>
|
2025-10-15 20:10:52 +08:00
|
|
|
|
<X size={20} />
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-11-18 14:46:51 +08:00
|
|
|
|
<div className="plugin-manager-tabs">
|
|
|
|
|
|
<button
|
|
|
|
|
|
className={`plugin-manager-tab ${activeTab === 'installed' ? 'active' : ''}`}
|
|
|
|
|
|
onClick={() => setActiveTab('installed')}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Package size={16} />
|
|
|
|
|
|
{t('tabInstalled')}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<button
|
|
|
|
|
|
className={`plugin-manager-tab ${activeTab === 'marketplace' ? 'active' : ''}`}
|
|
|
|
|
|
onClick={() => setActiveTab('marketplace')}
|
|
|
|
|
|
>
|
|
|
|
|
|
<ShoppingCart size={16} />
|
|
|
|
|
|
{t('tabMarketplace')}
|
|
|
|
|
|
</button>
|
2025-10-15 20:10:52 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-11-18 14:46:51 +08:00
|
|
|
|
{activeTab === 'installed' && (
|
|
|
|
|
|
<>
|
|
|
|
|
|
<div className="plugin-toolbar">
|
|
|
|
|
|
<div className="plugin-toolbar-left">
|
|
|
|
|
|
<div className="plugin-search">
|
|
|
|
|
|
<Search size={14} />
|
|
|
|
|
|
<input
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
placeholder={t('searchPlaceholder')}
|
|
|
|
|
|
value={filter}
|
|
|
|
|
|
onChange={(e) => setFilter(e.target.value)}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="plugin-toolbar-right">
|
|
|
|
|
|
<div className="plugin-stats">
|
|
|
|
|
|
<span className="stat-item enabled">
|
|
|
|
|
|
<CheckCircle size={14} />
|
|
|
|
|
|
{enabledCount} {t('enabled')}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span className="stat-item disabled">
|
|
|
|
|
|
<XCircle size={14} />
|
|
|
|
|
|
{disabledCount} {t('disabled')}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{onRefresh && (
|
|
|
|
|
|
<button
|
|
|
|
|
|
className="plugin-refresh-btn"
|
|
|
|
|
|
onClick={handleRefresh}
|
|
|
|
|
|
disabled={isRefreshing}
|
|
|
|
|
|
title={t('refreshPluginList')}
|
|
|
|
|
|
style={{
|
|
|
|
|
|
padding: '6px 12px',
|
|
|
|
|
|
display: 'flex',
|
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
|
gap: '6px',
|
|
|
|
|
|
backgroundColor: '#0e639c',
|
|
|
|
|
|
border: 'none',
|
|
|
|
|
|
borderRadius: '4px',
|
|
|
|
|
|
color: '#fff',
|
|
|
|
|
|
cursor: isRefreshing ? 'not-allowed' : 'pointer',
|
|
|
|
|
|
fontSize: '12px',
|
|
|
|
|
|
opacity: isRefreshing ? 0.6 : 1
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<RefreshCw size={14} className={isRefreshing ? 'spinning' : ''} />
|
|
|
|
|
|
{t('refresh')}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
)}
|
|
|
|
|
|
<div className="plugin-view-mode">
|
|
|
|
|
|
<button
|
|
|
|
|
|
className={viewMode === 'list' ? 'active' : ''}
|
|
|
|
|
|
onClick={() => setViewMode('list')}
|
|
|
|
|
|
title={t('listView')}
|
|
|
|
|
|
>
|
|
|
|
|
|
<List size={14} />
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<button
|
|
|
|
|
|
className={viewMode === 'grid' ? 'active' : ''}
|
|
|
|
|
|
onClick={() => setViewMode('grid')}
|
|
|
|
|
|
title={t('gridView')}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Grid size={14} />
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-10-15 20:10:52 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-11-18 14:46:51 +08:00
|
|
|
|
<div
|
|
|
|
|
|
className="plugin-content"
|
|
|
|
|
|
style={{ display: activeTab === 'installed' ? 'block' : 'none' }}
|
|
|
|
|
|
>
|
|
|
|
|
|
{plugins.length === 0 ? (
|
|
|
|
|
|
<div className="plugin-empty">
|
|
|
|
|
|
<Package size={48} />
|
|
|
|
|
|
<p>{t('noPlugins')}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<div className="plugin-categories">
|
|
|
|
|
|
{Object.entries(pluginsByCategory).map(([category, categoryPlugins]) => {
|
|
|
|
|
|
const cat = category as EditorPluginCategory;
|
|
|
|
|
|
const isExpanded = expandedCategories.has(cat);
|
2025-10-15 20:10:52 +08:00
|
|
|
|
|
2025-11-18 14:46:51 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<div key={category} className="plugin-category">
|
|
|
|
|
|
<div
|
|
|
|
|
|
className="plugin-category-header"
|
|
|
|
|
|
onClick={() => toggleCategory(cat)}
|
|
|
|
|
|
>
|
|
|
|
|
|
<button className="plugin-category-toggle">
|
|
|
|
|
|
{isExpanded ? (
|
|
|
|
|
|
<ChevronDown size={16} />
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<ChevronRight size={16} />
|
|
|
|
|
|
)}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<span className="plugin-category-icon">
|
|
|
|
|
|
{(() => {
|
|
|
|
|
|
const CategoryIcon = (LucideIcons as any)[
|
|
|
|
|
|
categoryIcons[cat]
|
|
|
|
|
|
];
|
|
|
|
|
|
return CategoryIcon ? <CategoryIcon size={16} /> : null;
|
|
|
|
|
|
})()}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span className="plugin-category-name">{getCategoryName(cat)}</span>
|
|
|
|
|
|
<span className="plugin-category-count">
|
|
|
|
|
|
{categoryPlugins.length}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{isExpanded && (
|
|
|
|
|
|
<div className={`plugin-category-content ${viewMode}`}>
|
|
|
|
|
|
{viewMode === 'grid'
|
|
|
|
|
|
? categoryPlugins.map(renderPluginCard)
|
|
|
|
|
|
: categoryPlugins.map(renderPluginList)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
2025-10-15 20:10:52 +08:00
|
|
|
|
</div>
|
2025-11-18 14:46:51 +08:00
|
|
|
|
);
|
|
|
|
|
|
})}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
2025-10-15 20:10:52 +08:00
|
|
|
|
</div>
|
2025-11-18 14:46:51 +08:00
|
|
|
|
</>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{activeTab === 'marketplace' && (
|
|
|
|
|
|
<PluginMarketPanel
|
|
|
|
|
|
marketService={marketService}
|
|
|
|
|
|
locale={locale}
|
|
|
|
|
|
projectPath={projectPath}
|
|
|
|
|
|
onReloadPlugins={onRefresh}
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
2025-10-15 20:10:52 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|