com-angel-authorization 1.0.27 → 1.0.29

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.
@@ -584,6 +584,23 @@ function toStringArray(value) {
584
584
  }
585
585
  return [];
586
586
  }
587
+ function mapMenuPermissionPoints(value) {
588
+ if (!Array.isArray(value)) return void 0;
589
+ const points = value.map((item) => {
590
+ if (!item || typeof item !== "object") return null;
591
+ const row = item;
592
+ const name = String(row.name ?? "").trim();
593
+ if (!name) return null;
594
+ const resourceId = row.resourceId ?? row.resource_id ?? row.id;
595
+ const identification = row.identification ?? row.identity;
596
+ return {
597
+ ...resourceId !== void 0 && resourceId !== null && resourceId !== "" ? { resourceId: String(resourceId) } : {},
598
+ name,
599
+ ...identification !== void 0 && identification !== null && identification !== "" ? { identification: String(identification) } : {}
600
+ };
601
+ }).filter((item) => item !== null);
602
+ return points.length ? points : void 0;
603
+ }
587
604
  function toMenuType(value) {
588
605
  const v = String(value ?? "").toLowerCase();
589
606
  if (v === MENU_TYPE_PAGE || v === MENU_TYPE_MENU || v === MENU_TYPE_BUTTON) {
@@ -611,11 +628,14 @@ function mapMenuResource(item) {
611
628
  const row = item;
612
629
  const resourceId = row.resourceId ?? row.resource_id ?? row.id;
613
630
  if (resourceId === void 0 || resourceId === null || resourceId === "") return null;
631
+ const permissionPoints = mapMenuPermissionPoints(
632
+ row.permissionPoints ?? row.permission_points
633
+ );
614
634
  const permissionPointIds = toStringArray(
615
- row.permissionPointIds ?? row.permission_point_ids ?? row.permissionPoints ?? row.permissions
635
+ row.permissionPointIds ?? row.permission_point_ids ?? (permissionPoints?.length ? permissionPoints.map((p) => p.resourceId).filter(Boolean) : void 0) ?? row.permissions
616
636
  );
617
637
  const permissionNamesRaw = row.permissionPointNames ?? row.permission_point_names ?? row.permissionNames;
618
- const permissionPointNames = Array.isArray(permissionNamesRaw) ? permissionNamesRaw.map((n) => String(n ?? "")).filter(Boolean) : void 0;
638
+ const permissionPointNames = Array.isArray(permissionNamesRaw) ? permissionNamesRaw.map((n) => String(n ?? "")).filter(Boolean) : permissionPoints?.map((p) => p.name).filter(Boolean);
619
639
  const rawParentId = row.parentId ?? row.parent_id ?? (row.parent && typeof row.parent === "object" ? row.parent.resourceId ?? row.parent.resource_id ?? row.parent.id : void 0);
620
640
  const parentId = rawParentId === void 0 || rawParentId === null || rawParentId === "" || String(rawParentId) === "0" ? null : String(rawParentId);
621
641
  const rawDepth = row.depth;
@@ -635,7 +655,8 @@ function mapMenuResource(item) {
635
655
  name: String(row.name ?? ""),
636
656
  identification: String(row.identification ?? row.identity ?? row.path ?? ""),
637
657
  permissionPointIds,
638
- permissionPointNames,
658
+ permissionPoints,
659
+ permissionPointNames: permissionPointNames && permissionPointNames.length ? permissionPointNames : void 0,
639
660
  status: toResourceStatus(row.status),
640
661
  sort
641
662
  };
@@ -1835,6 +1856,7 @@ var MenuManager = (0, import_vue4.defineComponent)({
1835
1856
  const saving = (0, import_vue4.ref)(false);
1836
1857
  const deletingRow = (0, import_vue4.ref)(null);
1837
1858
  const deleting = (0, import_vue4.ref)(false);
1859
+ const permissionKeyword = (0, import_vue4.ref)("");
1838
1860
  const permissionNameMap = (0, import_vue4.computed)(() => {
1839
1861
  const map = /* @__PURE__ */ new Map();
1840
1862
  permissionPoints.value.forEach(
@@ -1842,6 +1864,13 @@ var MenuManager = (0, import_vue4.defineComponent)({
1842
1864
  );
1843
1865
  return map;
1844
1866
  });
1867
+ const filteredPermissionPoints = (0, import_vue4.computed)(() => {
1868
+ const kw = permissionKeyword.value.trim().toLowerCase();
1869
+ if (!kw) return permissionPoints.value;
1870
+ return permissionPoints.value.filter(
1871
+ (p) => p.name.toLowerCase().includes(kw) || p.identification.toLowerCase().includes(kw)
1872
+ );
1873
+ });
1845
1874
  const allKnownMenus = (0, import_vue4.computed)(() => {
1846
1875
  const map = /* @__PURE__ */ new Map();
1847
1876
  records.value.forEach((row) => map.set(row.resourceId, row));
@@ -1947,6 +1976,7 @@ var MenuManager = (0, import_vue4.defineComponent)({
1947
1976
  }
1948
1977
  function openCreate(parent) {
1949
1978
  editing.value = null;
1979
+ permissionKeyword.value = "";
1950
1980
  if (parent) {
1951
1981
  Object.assign(form, {
1952
1982
  ...emptyForm2(),
@@ -1962,6 +1992,7 @@ var MenuManager = (0, import_vue4.defineComponent)({
1962
1992
  function openEdit(row) {
1963
1993
  const parentId = resolveRowParentId(row);
1964
1994
  editing.value = row;
1995
+ permissionKeyword.value = "";
1965
1996
  Object.assign(form, {
1966
1997
  parentId,
1967
1998
  depth: row.depth > 0 ? row.depth : resolveMenuDepth(parentId, allKnownMenus.value),
@@ -1976,7 +2007,10 @@ var MenuManager = (0, import_vue4.defineComponent)({
1976
2007
  void loadPermissionPoints();
1977
2008
  }
1978
2009
  function closeDialog() {
1979
- if (!saving.value) dialogOpen.value = false;
2010
+ if (!saving.value) {
2011
+ dialogOpen.value = false;
2012
+ permissionKeyword.value = "";
2013
+ }
1980
2014
  }
1981
2015
  async function handleSubmit(event) {
1982
2016
  event.preventDefault();
@@ -2025,6 +2059,9 @@ var MenuManager = (0, import_vue4.defineComponent)({
2025
2059
  form.permissionPointIds = exists ? form.permissionPointIds.filter((x) => x !== id) : [...form.permissionPointIds, id];
2026
2060
  }
2027
2061
  function renderPermissionLabels(row) {
2062
+ if (row.permissionPoints?.length) {
2063
+ return row.permissionPoints.map((p) => p.name).filter(Boolean).join("\u3001") || "\u2014";
2064
+ }
2028
2065
  if (row.permissionPointNames?.length) {
2029
2066
  return row.permissionPointNames.join("\u3001");
2030
2067
  }
@@ -2324,6 +2361,21 @@ var MenuManager = (0, import_vue4.defineComponent)({
2324
2361
  ]),
2325
2362
  (0, import_vue4.h)("fieldset", { style: s2.fieldset }, [
2326
2363
  (0, import_vue4.h)("legend", { style: s2.label }, "\u6743\u9650\u6807\u8BC6"),
2364
+ permissionPoints.value.length > 0 ? [
2365
+ (0, import_vue4.h)("input", {
2366
+ style: { ...s2.input, marginBottom: "8px" },
2367
+ value: permissionKeyword.value,
2368
+ placeholder: "\u641C\u7D22\u6743\u9650\u540D\u79F0 / \u6807\u8BC6",
2369
+ onInput: (e) => {
2370
+ permissionKeyword.value = e.target.value;
2371
+ }
2372
+ }),
2373
+ (0, import_vue4.h)(
2374
+ "div",
2375
+ { style: s2.hint },
2376
+ permissionKeyword.value.trim() ? `\u5DF2\u9009 ${form.permissionPointIds.length} \u9879 \xB7 \u5339\u914D ${filteredPermissionPoints.value.length} / ${permissionPoints.value.length}` : `\u5DF2\u9009 ${form.permissionPointIds.length} \u9879 \xB7 \u5171 ${permissionPoints.value.length} \u9879`
2377
+ )
2378
+ ] : null,
2327
2379
  (0, import_vue4.h)(
2328
2380
  "div",
2329
2381
  { style: s2.multiSelect },
@@ -2333,7 +2385,7 @@ var MenuManager = (0, import_vue4.defineComponent)({
2333
2385
  { style: s2.hint },
2334
2386
  "\u6682\u65E0\u6743\u9650\u70B9\uFF0C\u8BF7\u5148\u5728\u6743\u9650\u70B9\u7BA1\u7406\u4E2D\u65B0\u589E"
2335
2387
  )
2336
- ] : permissionPoints.value.map(
2388
+ ] : filteredPermissionPoints.value.length === 0 ? [(0, import_vue4.h)("div", { style: s2.hint }, "\u65E0\u5339\u914D\u6743\u9650\u70B9")] : filteredPermissionPoints.value.map(
2337
2389
  (p) => (0, import_vue4.h)(
2338
2390
  "label",
2339
2391
  { key: p.resourceId, style: s2.checkItem },