fix: 修复项目切换时运行时和系统重复初始化问题 (#267)
* feat(editor): 添加 GitHub Discussions 社区论坛功能 * chore: 更新 pnpm-lock.yaml * chore: 删除测试图片 * refactor: 改用 Imgur 图床上传图片 * fix: 修复项目切换时运行时和系统重复初始化问题 * fix: 修复多个编辑器问题 * feat: 添加脚本编辑器配置和类型定义支持 * feat: 实现资产 .meta 文件自动生成功能
This commit is contained in:
67
packages/editor-app/src/plugins/builtin/AssetMetaPlugin.ts
Normal file
67
packages/editor-app/src/plugins/builtin/AssetMetaPlugin.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Asset Meta Plugin
|
||||
* 资产元数据插件
|
||||
*
|
||||
* Handles .meta file generation for project assets.
|
||||
* 处理项目资产的 .meta 文件生成。
|
||||
*/
|
||||
|
||||
import type { ServiceContainer } from '@esengine/ecs-framework';
|
||||
import { createLogger } from '@esengine/ecs-framework';
|
||||
import type { IPlugin, IEditorModuleLoader, ModuleManifest } from '@esengine/editor-core';
|
||||
import { AssetRegistryService } from '@esengine/editor-core';
|
||||
|
||||
const logger = createLogger('AssetMetaPlugin');
|
||||
|
||||
/**
|
||||
* Asset Meta Editor Module
|
||||
* 资产元数据编辑器模块
|
||||
*/
|
||||
class AssetMetaEditorModule implements IEditorModuleLoader {
|
||||
private _assetRegistry: AssetRegistryService | null = null;
|
||||
|
||||
async install(_services: ServiceContainer): Promise<void> {
|
||||
// 创建 AssetRegistryService 并初始化
|
||||
// Create AssetRegistryService and initialize
|
||||
this._assetRegistry = new AssetRegistryService();
|
||||
|
||||
// 初始化服务(订阅 project:opened 事件)
|
||||
// Initialize service (subscribes to project:opened event)
|
||||
await this._assetRegistry.initialize();
|
||||
|
||||
logger.info('AssetRegistryService initialized');
|
||||
}
|
||||
|
||||
async uninstall(): Promise<void> {
|
||||
if (this._assetRegistry) {
|
||||
this._assetRegistry.unloadProject();
|
||||
this._assetRegistry = null;
|
||||
}
|
||||
logger.info('Uninstalled');
|
||||
}
|
||||
|
||||
async onEditorReady(): Promise<void> {
|
||||
logger.info('Editor is ready');
|
||||
}
|
||||
}
|
||||
|
||||
const manifest: ModuleManifest = {
|
||||
id: '@esengine/asset-meta',
|
||||
name: '@esengine/asset-meta',
|
||||
displayName: 'Asset Meta',
|
||||
version: '1.0.0',
|
||||
description: 'Generates .meta files for project assets | 为项目资产生成 .meta 文件',
|
||||
category: 'Other',
|
||||
icon: 'FileJson',
|
||||
isCore: true,
|
||||
defaultEnabled: true,
|
||||
isEngineModule: false, // 不是引擎模块,不会被打包到 runtime
|
||||
canContainContent: false,
|
||||
dependencies: [],
|
||||
exports: {}
|
||||
};
|
||||
|
||||
export const AssetMetaPlugin: IPlugin = {
|
||||
manifest,
|
||||
editorModule: new AssetMetaEditorModule()
|
||||
};
|
||||
@@ -56,6 +56,32 @@ class EditorAppearanceEditorModule implements IEditorModuleLoader {
|
||||
step: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'scriptEditor',
|
||||
title: '脚本编辑器',
|
||||
description: '配置用于打开脚本文件的外部编辑器',
|
||||
settings: [
|
||||
{
|
||||
key: 'editor.scriptEditor',
|
||||
label: '脚本编辑器',
|
||||
type: 'select',
|
||||
defaultValue: 'system',
|
||||
description: '双击脚本文件时使用的编辑器',
|
||||
options: SettingsService.SCRIPT_EDITORS.map(editor => ({
|
||||
value: editor.id,
|
||||
label: editor.name
|
||||
}))
|
||||
},
|
||||
{
|
||||
key: 'editor.customScriptEditorCommand',
|
||||
label: '自定义编辑器命令',
|
||||
type: 'string',
|
||||
defaultValue: '',
|
||||
description: '当选择"自定义"时,填写编辑器的命令行命令(如 notepad++)',
|
||||
placeholder: '例如:notepad++'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ export { SceneInspectorPlugin } from './SceneInspectorPlugin';
|
||||
export { ProfilerPlugin } from './ProfilerPlugin';
|
||||
export { EditorAppearancePlugin } from './EditorAppearancePlugin';
|
||||
export { ProjectSettingsPlugin } from './ProjectSettingsPlugin';
|
||||
export { AssetMetaPlugin } from './AssetMetaPlugin';
|
||||
// Note: PluginConfigPlugin removed - module management is now unified in ProjectSettingsPlugin
|
||||
// TODO: Re-enable when blueprint-editor package is fixed
|
||||
// export { BlueprintPlugin } from '@esengine/blueprint-editor';
|
||||
|
||||
Reference in New Issue
Block a user