openxiangda 1.0.125 → 1.0.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cli.js
CHANGED
|
@@ -5500,6 +5500,7 @@ function inferNotificationResourceCode(item) {
|
|
|
5500
5500
|
|
|
5501
5501
|
function extractResourceValues(value, spec) {
|
|
5502
5502
|
if (spec.key === 'notifications') return extractNotificationResourceValues(value);
|
|
5503
|
+
if (spec.key === 'menus') return extractMenuResourceValues(value);
|
|
5503
5504
|
if (Array.isArray(value)) return value;
|
|
5504
5505
|
if (!value || typeof value !== 'object') return [value];
|
|
5505
5506
|
for (const key of spec.pluralKeys || []) {
|
|
@@ -5509,6 +5510,32 @@ function extractResourceValues(value, spec) {
|
|
|
5509
5510
|
return [value];
|
|
5510
5511
|
}
|
|
5511
5512
|
|
|
5513
|
+
function extractMenuResourceValues(value) {
|
|
5514
|
+
const baseValues = (() => {
|
|
5515
|
+
if (Array.isArray(value)) return value;
|
|
5516
|
+
if (!value || typeof value !== 'object') return [value];
|
|
5517
|
+
if (Array.isArray(value.menus)) return value.menus;
|
|
5518
|
+
if (value.resource && typeof value.resource === 'object') return [value.resource];
|
|
5519
|
+
return [value];
|
|
5520
|
+
})();
|
|
5521
|
+
const result = [];
|
|
5522
|
+
const visit = (item, parentCode) => {
|
|
5523
|
+
if (!item || typeof item !== 'object' || Array.isArray(item)) {
|
|
5524
|
+
result.push(item);
|
|
5525
|
+
return;
|
|
5526
|
+
}
|
|
5527
|
+
const { children, ...rest } = item;
|
|
5528
|
+
const code = rest.code || rest.resourceCode;
|
|
5529
|
+
result.push(parentCode && !rest.parentCode && !rest.parentId ? { ...rest, parentCode } : rest);
|
|
5530
|
+
if (!Array.isArray(children)) return;
|
|
5531
|
+
for (const child of children) {
|
|
5532
|
+
visit(child, code || parentCode);
|
|
5533
|
+
}
|
|
5534
|
+
};
|
|
5535
|
+
for (const item of baseValues) visit(item, null);
|
|
5536
|
+
return result;
|
|
5537
|
+
}
|
|
5538
|
+
|
|
5512
5539
|
function extractNotificationResourceValues(value) {
|
|
5513
5540
|
if (Array.isArray(value)) return value;
|
|
5514
5541
|
if (!value || typeof value !== 'object') return [value];
|
|
@@ -708,6 +708,8 @@ export default async function (ctx) {
|
|
|
708
708
|
|
|
709
709
|
## 12. Menu — `src/resources/menus/<code>.json`
|
|
710
710
|
|
|
711
|
+
菜单可以写成单个资源文件,也可以在 `menus.json` 中用 `children` 声明树形结构;`resource validate|plan|publish` 会把 children 展开成独立菜单资源,并自动给子菜单补 `parentCode`。
|
|
712
|
+
|
|
711
713
|
```json
|
|
712
714
|
{
|
|
713
715
|
"code": "main",
|
package/package.json
CHANGED
|
@@ -58,7 +58,7 @@ openxiangda runtime deploy --profile <name>
|
|
|
58
58
|
|
|
59
59
|
## 权限资源
|
|
60
60
|
|
|
61
|
-
React SPA 页面需要声明菜单 code、route code 和 path pattern。默认菜单资源在 `src/resources/menus/menus.json
|
|
61
|
+
React SPA 页面需要声明菜单 code、route code 和 path pattern。默认菜单资源在 `src/resources/menus/menus.json`;可以用 `children` 声明树形菜单,`resource validate|plan|publish` 会展开成独立菜单资源:
|
|
62
62
|
|
|
63
63
|
```json
|
|
64
64
|
{
|