feat(editor): 添加插件多语言支持
This commit is contained in:
@@ -179,9 +179,29 @@ export class EditorPluginManager extends PluginManager {
|
||||
|
||||
/**
|
||||
* 获取所有插件元数据
|
||||
*
|
||||
* 实时从插件实例获取 displayName 和 description,以支持多语言切换
|
||||
*/
|
||||
public getAllPluginMetadata(): IEditorPluginMetadata[] {
|
||||
return Array.from(this.pluginMetadata.values());
|
||||
const metadataList: IEditorPluginMetadata[] = [];
|
||||
|
||||
for (const [name, metadata] of this.pluginMetadata.entries()) {
|
||||
const plugin = this.editorPlugins.get(name);
|
||||
|
||||
// 如果插件实例存在,使用实时的 displayName 和 description
|
||||
if (plugin) {
|
||||
metadataList.push({
|
||||
...metadata,
|
||||
displayName: plugin.displayName,
|
||||
description: plugin.description
|
||||
});
|
||||
} else {
|
||||
// 回退到缓存的元数据
|
||||
metadataList.push(metadata);
|
||||
}
|
||||
}
|
||||
|
||||
return metadataList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -121,6 +121,16 @@ export interface IEditorPlugin extends IPlugin {
|
||||
* 文件保存后回调
|
||||
*/
|
||||
onAfterSave?(filePath: string): void | Promise<void>;
|
||||
|
||||
/**
|
||||
* 设置插件语言
|
||||
*/
|
||||
setLocale?(locale: string): void;
|
||||
|
||||
/**
|
||||
* 获取行为树节点模板
|
||||
*/
|
||||
getNodeTemplates?(): any[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user