com-angel-authorization 1.0.25 → 1.0.27

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.
@@ -616,7 +616,7 @@ function mapMenuResource(item) {
616
616
  );
617
617
  const permissionNamesRaw = row.permissionPointNames ?? row.permission_point_names ?? row.permissionNames;
618
618
  const permissionPointNames = Array.isArray(permissionNamesRaw) ? permissionNamesRaw.map((n) => String(n ?? "")).filter(Boolean) : void 0;
619
- const rawParentId = row.parentId ?? row.parent_id;
619
+ 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
620
  const parentId = rawParentId === void 0 || rawParentId === null || rawParentId === "" || String(rawParentId) === "0" ? null : String(rawParentId);
621
621
  const rawDepth = row.depth;
622
622
  const parsedDepth = Number(rawDepth);
@@ -773,7 +773,11 @@ function createMenuResourceApi(request) {
773
773
  url: `/authorization-resources/${encodeURIComponent(resourceId)}/sub-resources`,
774
774
  signal
775
775
  });
776
- return extractRecords(json).map(mapMenuResource).filter((item) => item !== null);
776
+ return extractRecords(json).map(mapMenuResource).filter((item) => item !== null).map((item) => ({
777
+ ...item,
778
+ // 子资源接口常不回 parentId,用请求路径上的父级补齐
779
+ parentId: item.parentId ?? resourceId
780
+ }));
777
781
  },
778
782
  listPermissionPoints(params, signal) {
779
783
  return permissionApi.list(params, signal);
@@ -1741,6 +1745,11 @@ var s2 = {
1741
1745
  boxSizing: "border-box",
1742
1746
  width: "100%"
1743
1747
  },
1748
+ inputReadonly: {
1749
+ backgroundColor: "#f9fafb",
1750
+ color: "#667085",
1751
+ cursor: "not-allowed"
1752
+ },
1744
1753
  control: {
1745
1754
  width: "16px",
1746
1755
  height: "16px",
@@ -1841,12 +1850,31 @@ var MenuManager = (0, import_vue4.defineComponent)({
1841
1850
  });
1842
1851
  return Array.from(map.values());
1843
1852
  });
1844
- const parentOptions = (0, import_vue4.computed)(
1845
- () => allKnownMenus.value.filter((row) => !editing.value || row.resourceId !== editing.value.resourceId).map((row) => ({
1853
+ function resolveRowParentId(row) {
1854
+ if (row.parentId) return row.parentId;
1855
+ for (const [parentId, children] of Object.entries(childrenMap.value)) {
1856
+ if (children.some((child) => child.resourceId === row.resourceId)) {
1857
+ return parentId;
1858
+ }
1859
+ }
1860
+ return null;
1861
+ }
1862
+ const parentOptions = (0, import_vue4.computed)(() => {
1863
+ const opts = allKnownMenus.value.filter((row) => !editing.value || row.resourceId !== editing.value.resourceId).map((row) => ({
1846
1864
  value: row.resourceId,
1847
1865
  label: `${row.name}\uFF08${MENU_TYPE_LABEL[row.type]}\uFF09`
1848
- }))
1849
- );
1866
+ }));
1867
+ if (form.parentId && !opts.some((opt) => opt.value === form.parentId)) {
1868
+ const parent = allKnownMenus.value.find(
1869
+ (row) => row.resourceId === form.parentId
1870
+ );
1871
+ opts.unshift({
1872
+ value: form.parentId,
1873
+ label: parent ? `${parent.name}\uFF08${MENU_TYPE_LABEL[parent.type]}\uFF09` : form.parentId
1874
+ });
1875
+ }
1876
+ return opts;
1877
+ });
1850
1878
  const flatRows = (0, import_vue4.computed)(() => {
1851
1879
  const rows = [];
1852
1880
  const walk = (list) => {
@@ -1932,10 +1960,11 @@ var MenuManager = (0, import_vue4.defineComponent)({
1932
1960
  void loadPermissionPoints();
1933
1961
  }
1934
1962
  function openEdit(row) {
1963
+ const parentId = resolveRowParentId(row);
1935
1964
  editing.value = row;
1936
1965
  Object.assign(form, {
1937
- parentId: row.parentId ?? null,
1938
- depth: resolveMenuDepth(row.parentId ?? null, allKnownMenus.value),
1966
+ parentId,
1967
+ depth: row.depth > 0 ? row.depth : resolveMenuDepth(parentId, allKnownMenus.value),
1939
1968
  type: row.type,
1940
1969
  name: row.name,
1941
1970
  identification: row.identification,
@@ -2217,14 +2246,10 @@ var MenuManager = (0, import_vue4.defineComponent)({
2217
2246
  (0, import_vue4.h)(
2218
2247
  "select",
2219
2248
  {
2220
- style: s2.input,
2249
+ style: { ...s2.input, ...s2.inputReadonly },
2221
2250
  value: form.parentId ?? ROOT_PARENT_ID,
2222
- onChange: (e) => {
2223
- const value = e.target.value;
2224
- const parentId = value ? value : null;
2225
- form.parentId = parentId;
2226
- form.depth = resolveMenuDepth(parentId, allKnownMenus.value);
2227
- }
2251
+ disabled: true,
2252
+ "aria-readonly": "true"
2228
2253
  },
2229
2254
  [
2230
2255
  (0, import_vue4.h)("option", { value: ROOT_PARENT_ID }, "\u65E0"),