名称添加中文

This commit is contained in:
pqcqaq 2024-10-20 19:23:12 +08:00
parent 993a7f6b26
commit 6773b16420
2 changed files with 9 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import * as vscode from 'vscode';
import {
entityConfig,
getEntityName,
getProjectEntityList,
subscribe,
} from '../utils/entities';
@ -140,7 +141,10 @@ export class EntityItem extends TreeItem {
public readonly label: string,
public readonly collapsibleState: vscode.TreeItemCollapsibleState
) {
super(label, collapsibleState, label);
const name = getEntityName(label);
const labelWithZhCN = name ? label + ` (${name})` : label;
super(labelWithZhCN, collapsibleState, label);
this.label = labelWithZhCN; // 不知道为什么上面的super方法不生效所以这里再设置一次
this.contextValue = 'entityItem'; // 添加这行,用于识别右键菜单项
}
}

View File

@ -522,6 +522,10 @@ export const syncProjectEntityList = () => {
updateProjectEntityList(entities);
};
export const getEntityName = (en: string) => {
return entityConfig.getEntityDesc(en)?.locales.zh_CN?.name || "";
};
export function findEntityDefFile(entityName: string): string[] {
const fileName = toUpperFirst(`${entityName}.ts`);
const possiblePaths: string[] = [];