com-angel-authorization 1.0.8 → 1.0.9

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.
@@ -36,6 +36,7 @@ __export(vue_exports, {
36
36
  RESOURCE_STATUS_ENABLED: () => RESOURCE_STATUS_ENABLED,
37
37
  RESOURCE_STATUS_OPTIONS: () => RESOURCE_STATUS_OPTIONS,
38
38
  RESOURCE_TYPE_API: () => RESOURCE_TYPE_API,
39
+ ROOT_MENU_DEPTH: () => ROOT_MENU_DEPTH,
39
40
  ROOT_PARENT_ID: () => ROOT_PARENT_ID,
40
41
  ResourceManager: () => ResourceManager,
41
42
  SYSTEM_ADMIN_DEFAULT_KEY: () => SYSTEM_ADMIN_DEFAULT_KEY,
@@ -58,6 +59,7 @@ __export(vue_exports, {
58
59
  getDeviceWorkerId: () => getDeviceWorkerId,
59
60
  mapAuthorizationResource: () => mapAuthorizationResource,
60
61
  mapMenuResource: () => mapMenuResource,
62
+ resolveMenuDepth: () => resolveMenuDepth,
61
63
  snowyflake: () => snowyflake,
62
64
  useHasPermission: () => useHasPermission,
63
65
  useHasRole: () => useHasRole,
@@ -370,6 +372,7 @@ var MENU_TYPE_MENU = "menu";
370
372
  var MENU_TYPE_BUTTON = "button";
371
373
  var MENU_LIST_TYPE_PARAM = "page,menu,button";
372
374
  var ROOT_PARENT_ID = "";
375
+ var ROOT_MENU_DEPTH = 1;
373
376
  var RESOURCE_STATUS_ENABLED = 1;
374
377
  var RESOURCE_STATUS_DISABLED = 0;
375
378
  var RESOURCE_STATUS_OPTIONS = [
@@ -588,9 +591,13 @@ function mapMenuResource(item) {
588
591
  const permissionPointNames = Array.isArray(permissionNamesRaw) ? permissionNamesRaw.map((n) => String(n ?? "")).filter(Boolean) : void 0;
589
592
  const rawParentId = row.parentId ?? row.parent_id;
590
593
  const parentId = rawParentId === void 0 || rawParentId === null || rawParentId === "" || String(rawParentId) === "0" ? null : String(rawParentId);
594
+ const rawDepth = row.depth;
595
+ const parsedDepth = Number(rawDepth);
596
+ const depth = Number.isFinite(parsedDepth) && parsedDepth > 0 ? Math.floor(parsedDepth) : parentId ? ROOT_MENU_DEPTH + 1 : ROOT_MENU_DEPTH;
591
597
  return {
592
598
  resourceId: String(resourceId),
593
599
  parentId,
600
+ depth,
594
601
  type: toMenuType(row.type),
595
602
  name: String(row.name ?? ""),
596
603
  identification: String(row.identification ?? row.identity ?? row.path ?? ""),
@@ -599,6 +606,12 @@ function mapMenuResource(item) {
599
606
  status: toResourceStatus(row.status)
600
607
  };
601
608
  }
609
+ function resolveMenuDepth(parentId, menus) {
610
+ if (!parentId) return ROOT_MENU_DEPTH;
611
+ const parent = menus.find((item) => item.resourceId === parentId);
612
+ const parentDepth = parent && Number.isFinite(parent.depth) && parent.depth > 0 ? Math.floor(parent.depth) : ROOT_MENU_DEPTH;
613
+ return parentDepth + 1;
614
+ }
602
615
  function buildListUrl(type, params) {
603
616
  const parts = [];
604
617
  appendQueryParam(parts, "type", type);
@@ -629,9 +642,11 @@ function buildUpdateBody(values) {
629
642
  };
630
643
  }
631
644
  function buildCreateMenuBody(values, resourceId = getAppClientId()) {
645
+ const parentId = values.parentId ? values.parentId : null;
632
646
  return {
633
647
  resourceId,
634
- parentId: values.parentId ? values.parentId : null,
648
+ parentId,
649
+ depth: values.depth > 0 ? Math.floor(values.depth) : parentId ? ROOT_MENU_DEPTH + 1 : ROOT_MENU_DEPTH,
635
650
  type: values.type,
636
651
  name: values.name.trim(),
637
652
  identification: values.identification.trim(),
@@ -640,8 +655,10 @@ function buildCreateMenuBody(values, resourceId = getAppClientId()) {
640
655
  };
641
656
  }
642
657
  function buildUpdateMenuBody(values) {
658
+ const parentId = values.parentId ? values.parentId : null;
643
659
  return {
644
- parentId: values.parentId ? values.parentId : null,
660
+ parentId,
661
+ depth: values.depth > 0 ? Math.floor(values.depth) : parentId ? ROOT_MENU_DEPTH + 1 : ROOT_MENU_DEPTH,
645
662
  type: values.type,
646
663
  name: values.name.trim(),
647
664
  identification: values.identification.trim(),
@@ -1440,6 +1457,7 @@ var PAGE_SIZE_OPTIONS2 = ["10", "20", "50", "100"];
1440
1457
  function emptyForm2() {
1441
1458
  return {
1442
1459
  parentId: null,
1460
+ depth: ROOT_MENU_DEPTH,
1443
1461
  type: MENU_TYPE_MENU,
1444
1462
  name: "",
1445
1463
  identification: "",
@@ -1761,6 +1779,7 @@ var MenuManager = (0, import_vue4.defineComponent)({
1761
1779
  editing.value = row;
1762
1780
  Object.assign(form, {
1763
1781
  parentId: row.parentId ?? null,
1782
+ depth: resolveMenuDepth(row.parentId ?? null, records.value),
1764
1783
  type: row.type,
1765
1784
  name: row.name,
1766
1785
  identification: row.identification,
@@ -2008,7 +2027,9 @@ var MenuManager = (0, import_vue4.defineComponent)({
2008
2027
  value: form.parentId ?? ROOT_PARENT_ID,
2009
2028
  onChange: (e) => {
2010
2029
  const value = e.target.value;
2011
- form.parentId = value ? value : null;
2030
+ const parentId = value ? value : null;
2031
+ form.parentId = parentId;
2032
+ form.depth = resolveMenuDepth(parentId, records.value);
2012
2033
  }
2013
2034
  },
2014
2035
  [
@@ -2023,6 +2044,14 @@ var MenuManager = (0, import_vue4.defineComponent)({
2023
2044
  ]
2024
2045
  )
2025
2046
  ]),
2047
+ (0, import_vue4.h)("div", { style: s2.field }, [
2048
+ (0, import_vue4.h)("span", { style: s2.label }, "\u83DC\u5355\u5C42\u7EA7\uFF08depth\uFF09"),
2049
+ (0, import_vue4.h)("input", {
2050
+ style: s2.input,
2051
+ value: form.depth,
2052
+ readOnly: true
2053
+ })
2054
+ ]),
2026
2055
  (0, import_vue4.h)("fieldset", { style: s2.fieldset }, [
2027
2056
  (0, import_vue4.h)("legend", { style: s2.label }, "\u83DC\u5355\u7C7B\u578B"),
2028
2057
  (0, import_vue4.h)(
@@ -2421,6 +2450,7 @@ var SystemAdmin = (0, import_vue5.defineComponent)({
2421
2450
  RESOURCE_STATUS_ENABLED,
2422
2451
  RESOURCE_STATUS_OPTIONS,
2423
2452
  RESOURCE_TYPE_API,
2453
+ ROOT_MENU_DEPTH,
2424
2454
  ROOT_PARENT_ID,
2425
2455
  ResourceManager,
2426
2456
  SYSTEM_ADMIN_DEFAULT_KEY,
@@ -2443,6 +2473,7 @@ var SystemAdmin = (0, import_vue5.defineComponent)({
2443
2473
  getDeviceWorkerId,
2444
2474
  mapAuthorizationResource,
2445
2475
  mapMenuResource,
2476
+ resolveMenuDepth,
2446
2477
  snowyflake,
2447
2478
  useHasPermission,
2448
2479
  useHasRole,