fix: getMenuTree 默认用 module.label,而非凭空假定 i18n key
Shrimp.getMenuTree() 之前默认输出 { t: '<moduleKey>.menuManage' },
强加一个用户未必写过的 i18n key,不写翻译就显示 raw key。退化为直接
用 module.label —— 模块注册时已声明,不另起 key。
UserModule / RoleModule 同步补 label: 之前 super(parent, "user", ...)
没传 label,会落到 ShrimpTableModule 默认的 { t: moduleKey };现在显
式传 { t: "user.menuManage" } / { t: "role.menuManage" },沿用 hand-
admin 已有的翻译键,迁移零成本。
demo 里临时塞的 DemoShrimp 子类清掉,直接 new Shrimp()。
This commit is contained in:
+4
-4
@@ -90,13 +90,13 @@ export class Shrimp {
|
||||
return Array.from(map.entries()).map(([key, label]) => ({ key, label }))
|
||||
}
|
||||
|
||||
/** 菜单树,默认平铺所有模块,子类可覆盖为分组结构 */
|
||||
/** 菜单树,默认平铺所有模块(label 用模块注册时声明的 label),子类可覆盖为分组结构 */
|
||||
getMenuTree(): IMenuItem[] {
|
||||
const items: IMenuItem[] = []
|
||||
this.modules.forEach(module => {
|
||||
items.push({
|
||||
name: module.moduleKey,
|
||||
label: { t: module.moduleKey + '.menuManage' },
|
||||
label: module.label,
|
||||
moduleKey: module.moduleKey
|
||||
})
|
||||
})
|
||||
@@ -705,7 +705,7 @@ const userFields: IFieldConfig[] = [
|
||||
|
||||
export class UserModule extends ShrimpTableModule<WithId<IUser>> {
|
||||
constructor(public parent: Shrimp | ShrimpModule, dataSource: ShrimpCrud<WithId<IUser>>, fields?: IFieldConfig[]) {
|
||||
super(parent, "user", dataSource, fields || userFields)
|
||||
super(parent, "user", dataSource, fields || userFields, { t: "user.menuManage" })
|
||||
this.initCrud()
|
||||
}
|
||||
|
||||
@@ -794,7 +794,7 @@ const roleFields: IFieldConfig[] = [
|
||||
|
||||
export class RoleModule extends ShrimpTableModule<WithId<IRole>, IRoleProto> {
|
||||
constructor(public parent: Shrimp | ShrimpModule, dataSource: ShrimpCrud<WithId<IRole>>, fields?: IFieldConfig[]) {
|
||||
super(parent, "role", dataSource, fields || roleFields)
|
||||
super(parent, "role", dataSource, fields || roleFields, { t: "role.menuManage" })
|
||||
this.initCrud()
|
||||
this.addEvent("clear", { t: "power.clear" })
|
||||
this.addEvent("export", { t: "power.export" })
|
||||
|
||||
Reference in New Issue
Block a user