Feature/editor optimization (#251)
* refactor: 编辑器/运行时架构拆分与构建系统升级 * feat(core): 层级系统重构与UI变换矩阵修复 * refactor: 移除 ecs-components 聚合包并修复跨包组件查找问题 * fix(physics): 修复跨包组件类引用问题 * feat: 统一运行时架构与浏览器运行支持 * feat(asset): 实现浏览器运行时资产加载系统 * fix: 修复文档、CodeQL安全问题和CI类型检查错误 * fix: 修复文档、CodeQL安全问题和CI类型检查错误 * fix: 修复文档、CodeQL安全问题、CI类型检查和测试错误 * test: 补齐核心模块测试用例,修复CI构建配置 * fix: 修复测试用例中的类型错误和断言问题 * fix: 修复 turbo build:npm 任务的依赖顺序问题 * fix: 修复 CI 构建错误并优化构建性能
This commit is contained in:
@@ -26,6 +26,15 @@ export interface UIDesignResolution {
|
||||
height: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件配置
|
||||
* Plugin Configuration
|
||||
*/
|
||||
export interface PluginSettings {
|
||||
/** 启用的插件 ID 列表 / Enabled plugin IDs */
|
||||
enabledPlugins: string[];
|
||||
}
|
||||
|
||||
export interface ProjectConfig {
|
||||
projectType?: ProjectType;
|
||||
componentsPath?: string;
|
||||
@@ -35,6 +44,8 @@ export interface ProjectConfig {
|
||||
defaultScene?: string;
|
||||
/** UI 设计分辨率 / UI design resolution */
|
||||
uiDesignResolution?: UIDesignResolution;
|
||||
/** 插件配置 / Plugin settings */
|
||||
plugins?: PluginSettings;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
@@ -200,16 +211,21 @@ export class ProjectService implements IService {
|
||||
private async loadConfig(configPath: string): Promise<ProjectConfig> {
|
||||
try {
|
||||
const content = await this.fileAPI.readFileContent(configPath);
|
||||
logger.debug('Raw config content:', content);
|
||||
const config = JSON.parse(content) as ProjectConfig;
|
||||
return {
|
||||
logger.debug('Parsed config plugins:', config.plugins);
|
||||
const result = {
|
||||
projectType: config.projectType || 'esengine',
|
||||
componentsPath: config.componentsPath || '',
|
||||
componentPattern: config.componentPattern || '**/*.ts',
|
||||
buildOutput: config.buildOutput || 'temp/editor-components',
|
||||
scenesPath: config.scenesPath || 'scenes',
|
||||
defaultScene: config.defaultScene || 'main.ecs',
|
||||
uiDesignResolution: config.uiDesignResolution
|
||||
uiDesignResolution: config.uiDesignResolution,
|
||||
plugins: config.plugins
|
||||
};
|
||||
logger.debug('Loaded config result:', result);
|
||||
return result;
|
||||
} catch (error) {
|
||||
logger.warn('Failed to load config, using defaults', error);
|
||||
return {
|
||||
@@ -280,6 +296,60 @@ export class ProjectService implements IService {
|
||||
await this.updateConfig({ uiDesignResolution: resolution });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取启用的插件列表
|
||||
* Get enabled plugins list
|
||||
*/
|
||||
public getEnabledPlugins(): string[] {
|
||||
return this.projectConfig?.plugins?.enabledPlugins || [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取插件配置
|
||||
* Get plugin settings
|
||||
*/
|
||||
public getPluginSettings(): PluginSettings | null {
|
||||
logger.debug('getPluginSettings called, projectConfig:', this.projectConfig);
|
||||
logger.debug('getPluginSettings plugins:', this.projectConfig?.plugins);
|
||||
return this.projectConfig?.plugins || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置启用的插件列表
|
||||
* Set enabled plugins list
|
||||
*
|
||||
* @param enabledPlugins - Array of enabled plugin IDs
|
||||
*/
|
||||
public async setEnabledPlugins(enabledPlugins: string[]): Promise<void> {
|
||||
await this.updateConfig({
|
||||
plugins: {
|
||||
enabledPlugins
|
||||
}
|
||||
});
|
||||
await this.messageHub.publish('project:pluginsChanged', { enabledPlugins });
|
||||
logger.info('Plugin settings saved', { count: enabledPlugins.length });
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用插件
|
||||
* Enable a plugin
|
||||
*/
|
||||
public async enablePlugin(pluginId: string): Promise<void> {
|
||||
const current = this.getEnabledPlugins();
|
||||
if (!current.includes(pluginId)) {
|
||||
await this.setEnabledPlugins([...current, pluginId]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用插件
|
||||
* Disable a plugin
|
||||
*/
|
||||
public async disablePlugin(pluginId: string): Promise<void> {
|
||||
const current = this.getEnabledPlugins();
|
||||
await this.setEnabledPlugins(current.filter(id => id !== pluginId));
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this.currentProject = null;
|
||||
this.projectConfig = null;
|
||||
|
||||
Reference in New Issue
Block a user