com-angel-authorization 1.0.8 → 1.0.10
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/README.md +5 -1
- package/dist/index.cjs +45 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +41 -4
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +187 -36
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +28 -1
- package/dist/react/index.d.ts +28 -1
- package/dist/react/index.js +182 -36
- package/dist/react/index.js.map +1 -1
- package/dist/vue/index.cjs +173 -11
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.cts +28 -1
- package/dist/vue/index.d.ts +28 -1
- package/dist/vue/index.js +168 -11
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.cjs
CHANGED
|
@@ -22,6 +22,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
var react_exports = {};
|
|
23
23
|
__export(react_exports, {
|
|
24
24
|
Can: () => Can,
|
|
25
|
+
MENU_LEAF_NO: () => MENU_LEAF_NO,
|
|
26
|
+
MENU_LEAF_YES: () => MENU_LEAF_YES,
|
|
25
27
|
MENU_LIST_TYPE_PARAM: () => MENU_LIST_TYPE_PARAM,
|
|
26
28
|
MENU_TYPE_BUTTON: () => MENU_TYPE_BUTTON,
|
|
27
29
|
MENU_TYPE_LABEL: () => MENU_TYPE_LABEL,
|
|
@@ -37,6 +39,7 @@ __export(react_exports, {
|
|
|
37
39
|
RESOURCE_STATUS_ENABLED: () => RESOURCE_STATUS_ENABLED,
|
|
38
40
|
RESOURCE_STATUS_OPTIONS: () => RESOURCE_STATUS_OPTIONS,
|
|
39
41
|
RESOURCE_TYPE_API: () => RESOURCE_TYPE_API,
|
|
42
|
+
ROOT_MENU_DEPTH: () => ROOT_MENU_DEPTH,
|
|
40
43
|
ROOT_PARENT_ID: () => ROOT_PARENT_ID,
|
|
41
44
|
ResourceManager: () => ResourceManager,
|
|
42
45
|
SYSTEM_ADMIN_DEFAULT_KEY: () => SYSTEM_ADMIN_DEFAULT_KEY,
|
|
@@ -55,8 +58,10 @@ __export(react_exports, {
|
|
|
55
58
|
extractRecords: () => extractRecords,
|
|
56
59
|
getAppClientId: () => getAppClientId,
|
|
57
60
|
getDeviceWorkerId: () => getDeviceWorkerId,
|
|
61
|
+
isMenuLeaf: () => isMenuLeaf,
|
|
58
62
|
mapAuthorizationResource: () => mapAuthorizationResource,
|
|
59
63
|
mapMenuResource: () => mapMenuResource,
|
|
64
|
+
resolveMenuDepth: () => resolveMenuDepth,
|
|
60
65
|
snowyflake: () => snowyflake,
|
|
61
66
|
useHasPermission: () => useHasPermission,
|
|
62
67
|
useHasRole: () => useHasRole,
|
|
@@ -283,12 +288,15 @@ function Can({
|
|
|
283
288
|
var import_react2 = require("react");
|
|
284
289
|
|
|
285
290
|
// src/resources/types.ts
|
|
291
|
+
var MENU_LEAF_YES = 1;
|
|
292
|
+
var MENU_LEAF_NO = 0;
|
|
286
293
|
var RESOURCE_TYPE_API = "api";
|
|
287
294
|
var MENU_TYPE_PAGE = "page";
|
|
288
295
|
var MENU_TYPE_MENU = "menu";
|
|
289
296
|
var MENU_TYPE_BUTTON = "button";
|
|
290
297
|
var MENU_LIST_TYPE_PARAM = "page,menu,button";
|
|
291
298
|
var ROOT_PARENT_ID = "";
|
|
299
|
+
var ROOT_MENU_DEPTH = 1;
|
|
292
300
|
var RESOURCE_STATUS_ENABLED = 1;
|
|
293
301
|
var RESOURCE_STATUS_DISABLED = 0;
|
|
294
302
|
var RESOURCE_STATUS_OPTIONS = [
|
|
@@ -507,9 +515,16 @@ function mapMenuResource(item) {
|
|
|
507
515
|
const permissionPointNames = Array.isArray(permissionNamesRaw) ? permissionNamesRaw.map((n) => String(n ?? "")).filter(Boolean) : void 0;
|
|
508
516
|
const rawParentId = row.parentId ?? row.parent_id;
|
|
509
517
|
const parentId = rawParentId === void 0 || rawParentId === null || rawParentId === "" || String(rawParentId) === "0" ? null : String(rawParentId);
|
|
518
|
+
const rawDepth = row.depth;
|
|
519
|
+
const parsedDepth = Number(rawDepth);
|
|
520
|
+
const depth = Number.isFinite(parsedDepth) && parsedDepth > 0 ? Math.floor(parsedDepth) : parentId ? ROOT_MENU_DEPTH + 1 : ROOT_MENU_DEPTH;
|
|
521
|
+
const rawLeaf = row.leaf;
|
|
522
|
+
const leaf = rawLeaf === true || rawLeaf === 1 || rawLeaf === "1" || String(rawLeaf).toLowerCase() === "true" ? MENU_LEAF_YES : Number(rawLeaf) === MENU_LEAF_YES ? MENU_LEAF_YES : 0;
|
|
510
523
|
return {
|
|
511
524
|
resourceId: String(resourceId),
|
|
512
525
|
parentId,
|
|
526
|
+
depth,
|
|
527
|
+
leaf,
|
|
513
528
|
type: toMenuType(row.type),
|
|
514
529
|
name: String(row.name ?? ""),
|
|
515
530
|
identification: String(row.identification ?? row.identity ?? row.path ?? ""),
|
|
@@ -518,9 +533,21 @@ function mapMenuResource(item) {
|
|
|
518
533
|
status: toResourceStatus(row.status)
|
|
519
534
|
};
|
|
520
535
|
}
|
|
536
|
+
function isMenuLeaf(row) {
|
|
537
|
+
return Number(row.leaf) === MENU_LEAF_YES;
|
|
538
|
+
}
|
|
539
|
+
function resolveMenuDepth(parentId, menus) {
|
|
540
|
+
if (!parentId) return ROOT_MENU_DEPTH;
|
|
541
|
+
const parent = menus.find((item) => item.resourceId === parentId);
|
|
542
|
+
const parentDepth = parent && Number.isFinite(parent.depth) && parent.depth > 0 ? Math.floor(parent.depth) : ROOT_MENU_DEPTH;
|
|
543
|
+
return parentDepth + 1;
|
|
544
|
+
}
|
|
521
545
|
function buildListUrl(type, params) {
|
|
522
546
|
const parts = [];
|
|
523
547
|
appendQueryParam(parts, "type", type);
|
|
548
|
+
if (params?.depth !== void 0 && params?.depth !== null && String(params.depth) !== "") {
|
|
549
|
+
appendQueryParam(parts, "depth", String(params.depth));
|
|
550
|
+
}
|
|
524
551
|
appendQueryParam(parts, "page-token", params?.pagination?.pageToken ?? "");
|
|
525
552
|
appendQueryParam(parts, "page-size", params?.pagination?.pageSize ?? "20");
|
|
526
553
|
appendQueryParam(parts, "page-direction", params?.pagination?.pageDirection ?? "current");
|
|
@@ -548,9 +575,11 @@ function buildUpdateBody(values) {
|
|
|
548
575
|
};
|
|
549
576
|
}
|
|
550
577
|
function buildCreateMenuBody(values, resourceId = getAppClientId()) {
|
|
578
|
+
const parentId = values.parentId ? values.parentId : null;
|
|
551
579
|
return {
|
|
552
580
|
resourceId,
|
|
553
|
-
parentId
|
|
581
|
+
parentId,
|
|
582
|
+
depth: values.depth > 0 ? Math.floor(values.depth) : parentId ? ROOT_MENU_DEPTH + 1 : ROOT_MENU_DEPTH,
|
|
554
583
|
type: values.type,
|
|
555
584
|
name: values.name.trim(),
|
|
556
585
|
identification: values.identification.trim(),
|
|
@@ -559,8 +588,10 @@ function buildCreateMenuBody(values, resourceId = getAppClientId()) {
|
|
|
559
588
|
};
|
|
560
589
|
}
|
|
561
590
|
function buildUpdateMenuBody(values) {
|
|
591
|
+
const parentId = values.parentId ? values.parentId : null;
|
|
562
592
|
return {
|
|
563
|
-
parentId
|
|
593
|
+
parentId,
|
|
594
|
+
depth: values.depth > 0 ? Math.floor(values.depth) : parentId ? ROOT_MENU_DEPTH + 1 : ROOT_MENU_DEPTH,
|
|
564
595
|
type: values.type,
|
|
565
596
|
name: values.name.trim(),
|
|
566
597
|
identification: values.identification.trim(),
|
|
@@ -614,7 +645,10 @@ function createMenuResourceApi(request) {
|
|
|
614
645
|
async list(params, signal) {
|
|
615
646
|
const json = await request({
|
|
616
647
|
method: "GET",
|
|
617
|
-
url: buildListUrl(MENU_LIST_TYPE_PARAM,
|
|
648
|
+
url: buildListUrl(MENU_LIST_TYPE_PARAM, {
|
|
649
|
+
pagination: params?.pagination,
|
|
650
|
+
depth: params?.depth ?? ROOT_MENU_DEPTH
|
|
651
|
+
}),
|
|
618
652
|
signal
|
|
619
653
|
});
|
|
620
654
|
const records = extractRecords(json).map(mapMenuResource).filter((item) => item !== null);
|
|
@@ -624,6 +658,14 @@ function createMenuResourceApi(request) {
|
|
|
624
658
|
...pagination
|
|
625
659
|
};
|
|
626
660
|
},
|
|
661
|
+
async listSubResources(resourceId, signal) {
|
|
662
|
+
const json = await request({
|
|
663
|
+
method: "GET",
|
|
664
|
+
url: `/authorization-resources/${encodeURIComponent(resourceId)}/sub-resources`,
|
|
665
|
+
signal
|
|
666
|
+
});
|
|
667
|
+
return extractRecords(json).map(mapMenuResource).filter((item) => item !== null);
|
|
668
|
+
},
|
|
627
669
|
listPermissionPoints(params, signal) {
|
|
628
670
|
return permissionApi.list(params, signal);
|
|
629
671
|
},
|
|
@@ -1225,6 +1267,7 @@ var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
|
1225
1267
|
var PAGE_SIZE_OPTIONS2 = ["10", "20", "50", "100"];
|
|
1226
1268
|
var emptyForm2 = () => ({
|
|
1227
1269
|
parentId: null,
|
|
1270
|
+
depth: ROOT_MENU_DEPTH,
|
|
1228
1271
|
type: MENU_TYPE_MENU,
|
|
1229
1272
|
name: "",
|
|
1230
1273
|
identification: "",
|
|
@@ -1238,6 +1281,9 @@ function MenuManager({
|
|
|
1238
1281
|
toolbarExtra
|
|
1239
1282
|
}) {
|
|
1240
1283
|
const [records, setRecords] = (0, import_react3.useState)([]);
|
|
1284
|
+
const [childrenMap, setChildrenMap] = (0, import_react3.useState)({});
|
|
1285
|
+
const [expandedIds, setExpandedIds] = (0, import_react3.useState)({});
|
|
1286
|
+
const [expandingIds, setExpandingIds] = (0, import_react3.useState)({});
|
|
1241
1287
|
const [permissionPoints, setPermissionPoints] = (0, import_react3.useState)([]);
|
|
1242
1288
|
const [loading, setLoading] = (0, import_react3.useState)(false);
|
|
1243
1289
|
const [error, setError] = (0, import_react3.useState)("");
|
|
@@ -1256,18 +1302,40 @@ function MenuManager({
|
|
|
1256
1302
|
permissionPoints.forEach((p) => map.set(p.resourceId, p.name || p.identification));
|
|
1257
1303
|
return map;
|
|
1258
1304
|
}, [permissionPoints]);
|
|
1305
|
+
const allKnownMenus = (0, import_react3.useMemo)(() => {
|
|
1306
|
+
const map = /* @__PURE__ */ new Map();
|
|
1307
|
+
records.forEach((row) => map.set(row.resourceId, row));
|
|
1308
|
+
Object.values(childrenMap).forEach((list) => {
|
|
1309
|
+
list.forEach((row) => map.set(row.resourceId, row));
|
|
1310
|
+
});
|
|
1311
|
+
return Array.from(map.values());
|
|
1312
|
+
}, [records, childrenMap]);
|
|
1259
1313
|
const parentOptions = (0, import_react3.useMemo)(() => {
|
|
1260
|
-
return
|
|
1314
|
+
return allKnownMenus.filter((row) => !editing || row.resourceId !== editing.resourceId).map((row) => ({
|
|
1261
1315
|
value: row.resourceId,
|
|
1262
1316
|
label: `${row.name}\uFF08${MENU_TYPE_LABEL[row.type]}\uFF09`
|
|
1263
1317
|
}));
|
|
1264
|
-
}, [
|
|
1318
|
+
}, [allKnownMenus, editing]);
|
|
1319
|
+
const flatRows = (0, import_react3.useMemo)(() => {
|
|
1320
|
+
const rows = [];
|
|
1321
|
+
const walk = (list) => {
|
|
1322
|
+
list.forEach((row) => {
|
|
1323
|
+
rows.push(row);
|
|
1324
|
+
if (expandedIds[row.resourceId] && childrenMap[row.resourceId]?.length) {
|
|
1325
|
+
walk(childrenMap[row.resourceId]);
|
|
1326
|
+
}
|
|
1327
|
+
});
|
|
1328
|
+
};
|
|
1329
|
+
walk(records);
|
|
1330
|
+
return rows;
|
|
1331
|
+
}, [records, childrenMap, expandedIds]);
|
|
1265
1332
|
const loadList = (0, import_react3.useCallback)(
|
|
1266
1333
|
async (direction = "current", token = pageToken) => {
|
|
1267
1334
|
setLoading(true);
|
|
1268
1335
|
setError("");
|
|
1269
1336
|
try {
|
|
1270
1337
|
const result = await api.list({
|
|
1338
|
+
depth: ROOT_MENU_DEPTH,
|
|
1271
1339
|
pagination: {
|
|
1272
1340
|
pageToken: token,
|
|
1273
1341
|
pageSize,
|
|
@@ -1275,6 +1343,9 @@ function MenuManager({
|
|
|
1275
1343
|
}
|
|
1276
1344
|
});
|
|
1277
1345
|
setRecords(result.records);
|
|
1346
|
+
setChildrenMap({});
|
|
1347
|
+
setExpandedIds({});
|
|
1348
|
+
setExpandingIds({});
|
|
1278
1349
|
setPageToken(result.pageToken);
|
|
1279
1350
|
setHasPreviousPage(result.hasPreviousPage);
|
|
1280
1351
|
setHasNextPage(result.hasNextPage);
|
|
@@ -1295,6 +1366,29 @@ function MenuManager({
|
|
|
1295
1366
|
} catch {
|
|
1296
1367
|
}
|
|
1297
1368
|
}, [api]);
|
|
1369
|
+
const toggleExpand = async (row) => {
|
|
1370
|
+
if (isMenuLeaf(row)) return;
|
|
1371
|
+
const id = row.resourceId;
|
|
1372
|
+
if (expandedIds[id]) {
|
|
1373
|
+
setExpandedIds((prev) => ({ ...prev, [id]: false }));
|
|
1374
|
+
return;
|
|
1375
|
+
}
|
|
1376
|
+
if (!childrenMap[id]) {
|
|
1377
|
+
setExpandingIds((prev) => ({ ...prev, [id]: true }));
|
|
1378
|
+
setError("");
|
|
1379
|
+
try {
|
|
1380
|
+
const children = await api.listSubResources(id);
|
|
1381
|
+
setChildrenMap((prev) => ({ ...prev, [id]: children }));
|
|
1382
|
+
setExpandedIds((prev) => ({ ...prev, [id]: true }));
|
|
1383
|
+
} catch (err) {
|
|
1384
|
+
setError(err instanceof Error ? err.message : "\u52A0\u8F7D\u4E0B\u7EA7\u83DC\u5355\u5931\u8D25");
|
|
1385
|
+
} finally {
|
|
1386
|
+
setExpandingIds((prev) => ({ ...prev, [id]: false }));
|
|
1387
|
+
}
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
setExpandedIds((prev) => ({ ...prev, [id]: true }));
|
|
1391
|
+
};
|
|
1298
1392
|
(0, import_react3.useEffect)(() => {
|
|
1299
1393
|
void loadList("current", "");
|
|
1300
1394
|
void loadPermissionPoints();
|
|
@@ -1309,6 +1403,7 @@ function MenuManager({
|
|
|
1309
1403
|
setEditing(row);
|
|
1310
1404
|
setForm({
|
|
1311
1405
|
parentId: row.parentId ?? null,
|
|
1406
|
+
depth: resolveMenuDepth(row.parentId ?? null, allKnownMenus),
|
|
1312
1407
|
type: row.type,
|
|
1313
1408
|
name: row.name,
|
|
1314
1409
|
identification: row.identification,
|
|
@@ -1396,35 +1491,54 @@ function MenuManager({
|
|
|
1396
1491
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { style: styles2.th, children: "\u6743\u9650\u6807\u8BC6" }),
|
|
1397
1492
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { style: { ...styles2.th, width: 140 }, children: "\u64CD\u4F5C" })
|
|
1398
1493
|
] }) }),
|
|
1399
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tbody", { children: loading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { colSpan: 6, style: styles2.empty, children: "\u52A0\u8F7D\u4E2D\u2026" }) }) :
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
{
|
|
1406
|
-
style:
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1494
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tbody", { children: loading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { colSpan: 6, style: styles2.empty, children: "\u52A0\u8F7D\u4E2D\u2026" }) }) : flatRows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { colSpan: 6, style: styles2.empty, children: "\u6682\u65E0\u6570\u636E" }) }) : flatRows.map((row) => {
|
|
1495
|
+
const leaf = isMenuLeaf(row);
|
|
1496
|
+
const expanded = Boolean(expandedIds[row.resourceId]);
|
|
1497
|
+
const expanding = Boolean(expandingIds[row.resourceId]);
|
|
1498
|
+
const indent = Math.max(0, (row.depth || 1) - 1) * 18;
|
|
1499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("tr", { children: [
|
|
1500
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { style: styles2.td, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { ...styles2.treeCell, paddingLeft: indent }, children: [
|
|
1501
|
+
leaf ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: styles2.treeSpacer }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1502
|
+
"button",
|
|
1503
|
+
{
|
|
1504
|
+
type: "button",
|
|
1505
|
+
style: styles2.treeToggle,
|
|
1506
|
+
onClick: () => void toggleExpand(row),
|
|
1507
|
+
disabled: expanding,
|
|
1508
|
+
"aria-label": expanded ? "\u6536\u8D77" : "\u5C55\u5F00",
|
|
1509
|
+
children: expanding ? "\u2026" : expanded ? "\u25BC" : "\u25B6"
|
|
1510
|
+
}
|
|
1511
|
+
),
|
|
1512
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: row.name })
|
|
1513
|
+
] }) }),
|
|
1514
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { style: styles2.td, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("code", { style: styles2.code, children: row.identification || "\u2014" }) }),
|
|
1515
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { style: styles2.td, children: MENU_TYPE_LABEL[row.type] }),
|
|
1516
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { style: styles2.td, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1517
|
+
"span",
|
|
1419
1518
|
{
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1519
|
+
style: {
|
|
1520
|
+
...styles2.badge,
|
|
1521
|
+
background: row.status === RESOURCE_STATUS_ENABLED ? "#e8f7ef" : "#f4f4f5",
|
|
1522
|
+
color: row.status === RESOURCE_STATUS_ENABLED ? "#067647" : "#667085"
|
|
1523
|
+
},
|
|
1524
|
+
children: row.status === RESOURCE_STATUS_ENABLED ? "\u663E\u793A" : "\u9690\u85CF"
|
|
1424
1525
|
}
|
|
1425
|
-
)
|
|
1426
|
-
|
|
1427
|
-
|
|
1526
|
+
) }),
|
|
1527
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { style: styles2.td, children: renderPermissionLabels(row) }),
|
|
1528
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("td", { style: styles2.td, children: [
|
|
1529
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", style: styles2.linkBtn, onClick: () => openEdit(row), children: "\u7F16\u8F91" }),
|
|
1530
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1531
|
+
"button",
|
|
1532
|
+
{
|
|
1533
|
+
type: "button",
|
|
1534
|
+
style: { ...styles2.linkBtn, color: "#d92d20" },
|
|
1535
|
+
onClick: () => askDelete(row),
|
|
1536
|
+
children: "\u5220\u9664"
|
|
1537
|
+
}
|
|
1538
|
+
)
|
|
1539
|
+
] })
|
|
1540
|
+
] }, row.resourceId);
|
|
1541
|
+
}) })
|
|
1428
1542
|
] }) }),
|
|
1429
1543
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: styles2.pagination, children: [
|
|
1430
1544
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { style: styles2.pageSize, children: [
|
|
@@ -1485,10 +1599,14 @@ function MenuManager({
|
|
|
1485
1599
|
{
|
|
1486
1600
|
style: styles2.input,
|
|
1487
1601
|
value: form.parentId ?? ROOT_PARENT_ID,
|
|
1488
|
-
onChange: (e) =>
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1602
|
+
onChange: (e) => {
|
|
1603
|
+
const parentId = e.target.value ? e.target.value : null;
|
|
1604
|
+
setForm((prev) => ({
|
|
1605
|
+
...prev,
|
|
1606
|
+
parentId,
|
|
1607
|
+
depth: resolveMenuDepth(parentId, allKnownMenus)
|
|
1608
|
+
}));
|
|
1609
|
+
},
|
|
1492
1610
|
children: [
|
|
1493
1611
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: ROOT_PARENT_ID, children: "\u65E0" }),
|
|
1494
1612
|
parentOptions.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: opt.value, children: opt.label }, opt.value))
|
|
@@ -1496,6 +1614,10 @@ function MenuManager({
|
|
|
1496
1614
|
}
|
|
1497
1615
|
)
|
|
1498
1616
|
] }),
|
|
1617
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: styles2.field, children: [
|
|
1618
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: styles2.label, children: "\u83DC\u5355\u5C42\u7EA7\uFF08depth\uFF09" }),
|
|
1619
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("input", { style: styles2.input, value: form.depth, readOnly: true })
|
|
1620
|
+
] }),
|
|
1499
1621
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("fieldset", { style: styles2.fieldset, children: [
|
|
1500
1622
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("legend", { style: styles2.label, children: "\u83DC\u5355\u7C7B\u578B" }),
|
|
1501
1623
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: styles2.radioGroup, children: MENU_TYPE_OPTIONS.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { style: styles2.radioItem, children: [
|
|
@@ -1680,6 +1802,30 @@ var styles2 = {
|
|
|
1680
1802
|
borderBottom: "1px solid #f2f4f7",
|
|
1681
1803
|
verticalAlign: "middle"
|
|
1682
1804
|
},
|
|
1805
|
+
treeCell: {
|
|
1806
|
+
display: "flex",
|
|
1807
|
+
alignItems: "center",
|
|
1808
|
+
gap: 6
|
|
1809
|
+
},
|
|
1810
|
+
treeToggle: {
|
|
1811
|
+
width: 22,
|
|
1812
|
+
height: 22,
|
|
1813
|
+
border: "1px solid #d0d5dd",
|
|
1814
|
+
borderRadius: 4,
|
|
1815
|
+
background: "#fff",
|
|
1816
|
+
color: "#475467",
|
|
1817
|
+
cursor: "pointer",
|
|
1818
|
+
fontSize: 10,
|
|
1819
|
+
lineHeight: "20px",
|
|
1820
|
+
padding: 0,
|
|
1821
|
+
flexShrink: 0
|
|
1822
|
+
},
|
|
1823
|
+
treeSpacer: {
|
|
1824
|
+
width: 22,
|
|
1825
|
+
height: 22,
|
|
1826
|
+
flexShrink: 0,
|
|
1827
|
+
display: "inline-block"
|
|
1828
|
+
},
|
|
1683
1829
|
empty: { padding: 28, textAlign: "center", color: "#98a2b3", fontSize: 14 },
|
|
1684
1830
|
code: {
|
|
1685
1831
|
fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
@@ -1989,6 +2135,8 @@ var styles3 = {
|
|
|
1989
2135
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1990
2136
|
0 && (module.exports = {
|
|
1991
2137
|
Can,
|
|
2138
|
+
MENU_LEAF_NO,
|
|
2139
|
+
MENU_LEAF_YES,
|
|
1992
2140
|
MENU_LIST_TYPE_PARAM,
|
|
1993
2141
|
MENU_TYPE_BUTTON,
|
|
1994
2142
|
MENU_TYPE_LABEL,
|
|
@@ -2004,6 +2152,7 @@ var styles3 = {
|
|
|
2004
2152
|
RESOURCE_STATUS_ENABLED,
|
|
2005
2153
|
RESOURCE_STATUS_OPTIONS,
|
|
2006
2154
|
RESOURCE_TYPE_API,
|
|
2155
|
+
ROOT_MENU_DEPTH,
|
|
2007
2156
|
ROOT_PARENT_ID,
|
|
2008
2157
|
ResourceManager,
|
|
2009
2158
|
SYSTEM_ADMIN_DEFAULT_KEY,
|
|
@@ -2022,8 +2171,10 @@ var styles3 = {
|
|
|
2022
2171
|
extractRecords,
|
|
2023
2172
|
getAppClientId,
|
|
2024
2173
|
getDeviceWorkerId,
|
|
2174
|
+
isMenuLeaf,
|
|
2025
2175
|
mapAuthorizationResource,
|
|
2026
2176
|
mapMenuResource,
|
|
2177
|
+
resolveMenuDepth,
|
|
2027
2178
|
snowyflake,
|
|
2028
2179
|
useHasPermission,
|
|
2029
2180
|
useHasRole,
|