fix(menu): v0.11 is*Authorize 条件化 + --category App 支持

P1 修复(与 web Form.vue 一致):
- is*Authorize 4 字段: 仅 type ∈ [2, 3, 4, 9, 11] (表单类菜单) = 1
  其他 type (1=目录/5=报表/6=大屏/7=外链/8=代码生成/10=门户) = 0
  来源: web/views/permission/menu/Form.vue:281-291 onTypeChange()

P2 新增:
- --category <Web|App> flag (默认 Web)
- category 字段硬编码 'Web' → opts.category || 'Web'
  支持 App 端菜单 (web Form.vue 下拉 Web/App 二选一)

回归验证: TS 编译通过 (仅 tests/e2e/ 旧错误与本次无关)

Co-Authored-By: Claude <[email protected]>
This commit is contained in:
sswandClaude committed 2026-06-22 20:51:03 +08:00
1 parent 588ed084dd
commit 284b38694d
1 file changed
+16 -6
+16 -6
View File
@@ -40,6 +40,8 @@ interface Opts {
type?: string
urlAddress?: string
icon?: string
/** v0.11 新增: 支持 App 菜单 (web Form.vue 下拉 Web/App 二选一) */
category?: string
json?: boolean
}
@@ -57,6 +59,8 @@ export function buildMenuCreateCommand(): Command {
.option('--type <t>', '低级模式 type: 1=目录 2=Vue扩展 3=VisualDev 7=外链', '1')
.option('--urlAddress <u>', '低级模式: URL')
.option('--icon <i>', '低级模式: 图标')
// v0.11 新增: 支持 App 菜单 (默认 Web)
.option('--category <c>', '菜单分类 (Web | App, 默认 Web)', 'Web')
.option('--json', '原始 JSON 输出', false)
.action(async (opts: Opts) => {
const c = await JnpfClient.fromToken()
@@ -93,8 +97,10 @@ export function buildMenuCreateCommand(): Command {
type: 3, // VisualDev
enabledMark: 1,
sortCode: 0,
category: 'Web',
// v0.11 修复: 用 opts.category (默认 Web), 支持 --category=App
category: opts.category || 'Web',
linkTarget: '_self',
// v0.11 修复: web Form.vue:281-291 — type=3 属表单类 → is*Authorize=1
isButtonAuthorize: 1,
isColumnAuthorize: 1,
isDataAuthorize: 1,
@@ -232,6 +238,9 @@ export function buildMenuCreateCommand(): Command {
}
}
// v0.11 修复: web Form.vue:281-291 条件化 is*Authorize
// 仅 type ∈ [2, 3, 4, 9, 11] (表单类菜单) = 1, 其余 (目录/报表/外链/代码生成) = 0
const isFormType = [2, 3, 4, 9, 11].includes(type)
const body: Record<string, unknown> = {
fullName: opts.fullName,
enCode,
@@ -239,12 +248,13 @@ export function buildMenuCreateCommand(): Command {
type,
enabledMark: 1,
sortCode: 0,
category: 'Web',
// v0.11 修复: 用 opts.category (默认 Web), 支持 --category=App
category: opts.category || 'Web',
linkTarget: '_self',
isButtonAuthorize: 1,
isColumnAuthorize: 1,
isDataAuthorize: 1,
isFormAuthorize: 1,
isButtonAuthorize: isFormType ? 1 : 0,
isColumnAuthorize: isFormType ? 1 : 0,
isDataAuthorize: isFormType ? 1 : 0,
isFormAuthorize: isFormType ? 1 : 0,
icon,
propertyJson,
}