com-angel-authorization 1.0.7 → 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,
@@ -369,7 +371,8 @@ var MENU_TYPE_PAGE = "page";
369
371
  var MENU_TYPE_MENU = "menu";
370
372
  var MENU_TYPE_BUTTON = "button";
371
373
  var MENU_LIST_TYPE_PARAM = "page,menu,button";
372
- var ROOT_PARENT_ID = "0";
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 = [
@@ -586,10 +589,15 @@ function mapMenuResource(item) {
586
589
  );
587
590
  const permissionNamesRaw = row.permissionPointNames ?? row.permission_point_names ?? row.permissionNames;
588
591
  const permissionPointNames = Array.isArray(permissionNamesRaw) ? permissionNamesRaw.map((n) => String(n ?? "")).filter(Boolean) : void 0;
589
- const parentId = row.parentId ?? row.parent_id ?? ROOT_PARENT_ID;
592
+ const rawParentId = row.parentId ?? row.parent_id;
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;
590
597
  return {
591
598
  resourceId: String(resourceId),
592
- parentId: parentId === void 0 || parentId === null ? ROOT_PARENT_ID : String(parentId),
599
+ parentId,
600
+ depth,
593
601
  type: toMenuType(row.type),
594
602
  name: String(row.name ?? ""),
595
603
  identification: String(row.identification ?? row.identity ?? row.path ?? ""),
@@ -598,6 +606,12 @@ function mapMenuResource(item) {
598
606
  status: toResourceStatus(row.status)
599
607
  };
600
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
+ }
601
615
  function buildListUrl(type, params) {
602
616
  const parts = [];
603
617
  appendQueryParam(parts, "type", type);
@@ -628,9 +642,11 @@ function buildUpdateBody(values) {
628
642
  };
629
643
  }
630
644
  function buildCreateMenuBody(values, resourceId = getAppClientId()) {
645
+ const parentId = values.parentId ? values.parentId : null;
631
646
  return {
632
647
  resourceId,
633
- parentId: values.parentId || ROOT_PARENT_ID,
648
+ parentId,
649
+ depth: values.depth > 0 ? Math.floor(values.depth) : parentId ? ROOT_MENU_DEPTH + 1 : ROOT_MENU_DEPTH,
634
650
  type: values.type,
635
651
  name: values.name.trim(),
636
652
  identification: values.identification.trim(),
@@ -639,8 +655,10 @@ function buildCreateMenuBody(values, resourceId = getAppClientId()) {
639
655
  };
640
656
  }
641
657
  function buildUpdateMenuBody(values) {
658
+ const parentId = values.parentId ? values.parentId : null;
642
659
  return {
643
- parentId: values.parentId || ROOT_PARENT_ID,
660
+ parentId,
661
+ depth: values.depth > 0 ? Math.floor(values.depth) : parentId ? ROOT_MENU_DEPTH + 1 : ROOT_MENU_DEPTH,
644
662
  type: values.type,
645
663
  name: values.name.trim(),
646
664
  identification: values.identification.trim(),
@@ -1438,7 +1456,8 @@ var import_vue4 = require("vue");
1438
1456
  var PAGE_SIZE_OPTIONS2 = ["10", "20", "50", "100"];
1439
1457
  function emptyForm2() {
1440
1458
  return {
1441
- parentId: ROOT_PARENT_ID,
1459
+ parentId: null,
1460
+ depth: ROOT_MENU_DEPTH,
1442
1461
  type: MENU_TYPE_MENU,
1443
1462
  name: "",
1444
1463
  identification: "",
@@ -1759,7 +1778,8 @@ var MenuManager = (0, import_vue4.defineComponent)({
1759
1778
  function openEdit(row) {
1760
1779
  editing.value = row;
1761
1780
  Object.assign(form, {
1762
- parentId: row.parentId || ROOT_PARENT_ID,
1781
+ parentId: row.parentId ?? null,
1782
+ depth: resolveMenuDepth(row.parentId ?? null, records.value),
1763
1783
  type: row.type,
1764
1784
  name: row.name,
1765
1785
  identification: row.identification,
@@ -2004,13 +2024,16 @@ var MenuManager = (0, import_vue4.defineComponent)({
2004
2024
  "select",
2005
2025
  {
2006
2026
  style: s2.input,
2007
- value: form.parentId,
2027
+ value: form.parentId ?? ROOT_PARENT_ID,
2008
2028
  onChange: (e) => {
2009
- form.parentId = e.target.value;
2029
+ const value = e.target.value;
2030
+ const parentId = value ? value : null;
2031
+ form.parentId = parentId;
2032
+ form.depth = resolveMenuDepth(parentId, records.value);
2010
2033
  }
2011
2034
  },
2012
2035
  [
2013
- (0, import_vue4.h)("option", { value: ROOT_PARENT_ID }, "\u6839\u76EE\u5F55"),
2036
+ (0, import_vue4.h)("option", { value: ROOT_PARENT_ID }, "\u65E0"),
2014
2037
  ...parentOptions.value.map(
2015
2038
  (opt) => (0, import_vue4.h)(
2016
2039
  "option",
@@ -2021,6 +2044,14 @@ var MenuManager = (0, import_vue4.defineComponent)({
2021
2044
  ]
2022
2045
  )
2023
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
+ ]),
2024
2055
  (0, import_vue4.h)("fieldset", { style: s2.fieldset }, [
2025
2056
  (0, import_vue4.h)("legend", { style: s2.label }, "\u83DC\u5355\u7C7B\u578B"),
2026
2057
  (0, import_vue4.h)(
@@ -2419,6 +2450,7 @@ var SystemAdmin = (0, import_vue5.defineComponent)({
2419
2450
  RESOURCE_STATUS_ENABLED,
2420
2451
  RESOURCE_STATUS_OPTIONS,
2421
2452
  RESOURCE_TYPE_API,
2453
+ ROOT_MENU_DEPTH,
2422
2454
  ROOT_PARENT_ID,
2423
2455
  ResourceManager,
2424
2456
  SYSTEM_ADMIN_DEFAULT_KEY,
@@ -2441,6 +2473,7 @@ var SystemAdmin = (0, import_vue5.defineComponent)({
2441
2473
  getDeviceWorkerId,
2442
2474
  mapAuthorizationResource,
2443
2475
  mapMenuResource,
2476
+ resolveMenuDepth,
2444
2477
  snowyflake,
2445
2478
  useHasPermission,
2446
2479
  useHasRole,