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:
@@ -33,17 +33,6 @@ import type {
|
||||
IMeResult,
|
||||
} from "shrimp-server"
|
||||
|
||||
class DemoShrimp extends Shrimp {
|
||||
/** 默认 getMenuTree 用 i18n key,demo 没翻译这些键,直接用模块自带的 label */
|
||||
getMenuTree(): IMenuItem[] {
|
||||
const items: IMenuItem[] = []
|
||||
this.modules.forEach(m => {
|
||||
items.push({ name: m.moduleKey, label: m.label, moduleKey: m.moduleKey })
|
||||
})
|
||||
return items
|
||||
}
|
||||
}
|
||||
|
||||
interface ITag { _id: string; name: string }
|
||||
interface IProduct { _id: string; code: string; name: string; price: number; tagIds: string[] }
|
||||
|
||||
@@ -70,7 +59,7 @@ const superAdmin: IShrimpOperator = {
|
||||
}
|
||||
|
||||
async function bootstrap() {
|
||||
const shrimp = new DemoShrimp()
|
||||
const shrimp = new Shrimp()
|
||||
|
||||
// TODO(70→90): ShrimpTableModule 当前只在 dataSource.model 存在时自动登记 crudRegistry,
|
||||
// 这里需要手动 wire 让 MemoryShrimpCrud 的 populate 也能查到关联表
|
||||
|
||||
Reference in New Issue
Block a user