com-angel-authorization 1.0.9 → 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.
@@ -228,6 +228,10 @@ type MenuResource = {
228
228
  * 菜单层级:无上级(根)为 1,其余为上级 depth + 1
229
229
  */
230
230
  depth: number;
231
+ /**
232
+ * 是否叶子节点:`1` 表示无下级菜单,不可再展开
233
+ */
234
+ leaf: number;
231
235
  type: MenuResourceType;
232
236
  name: string;
233
237
  identification: string;
@@ -252,6 +256,8 @@ type CreateMenuResourceBody = MenuResourceFormValues & {
252
256
  };
253
257
  type UpdateMenuResourceBody = Partial<MenuResourceFormValues>;
254
258
  type FetchMenuResourcesParams = {
259
+ /** 列表默认传 1,只拉根层 */
260
+ depth?: number;
255
261
  pagination?: ListPaginationParams;
256
262
  };
257
263
  type MenuResourceListResult = {
@@ -260,6 +266,9 @@ type MenuResourceListResult = {
260
266
  hasPreviousPage: boolean;
261
267
  hasNextPage: boolean;
262
268
  };
269
+ /** leaf === 1 表示无下级 */
270
+ declare const MENU_LEAF_YES = 1;
271
+ declare const MENU_LEAF_NO = 0;
263
272
  declare const RESOURCE_TYPE_API: ApiResourceType;
264
273
  declare const MENU_TYPE_PAGE: MenuResourceType;
265
274
  declare const MENU_TYPE_MENU: MenuResourceType;
@@ -313,6 +322,8 @@ type AuthorizationResourceApi = {
313
322
  };
314
323
  type MenuResourceApi = {
315
324
  list: (params?: FetchMenuResourcesParams, signal?: AbortSignal) => Promise<MenuResourceListResult>;
325
+ /** 展开下级:GET /authorization-resources/{resource-id}/sub-resources */
326
+ listSubResources: (resourceId: string, signal?: AbortSignal) => Promise<MenuResource[]>;
316
327
  /** 拉取权限点(type=api),供菜单表单多选 */
317
328
  listPermissionPoints: (params?: FetchAuthorizationResourcesParams, signal?: AbortSignal) => Promise<AuthorizationResourceListResult>;
318
329
  create: (values: MenuResourceFormValues, signal?: AbortSignal) => Promise<unknown>;
@@ -321,6 +332,10 @@ type MenuResourceApi = {
321
332
  };
322
333
  declare function mapAuthorizationResource(item: unknown): AuthorizationResource | null;
323
334
  declare function mapMenuResource(item: unknown): MenuResource | null;
335
+ /**
336
+ * leaf === 1 表示无下级菜单。
337
+ */
338
+ declare function isMenuLeaf(row: Pick<MenuResource, 'leaf'>): boolean;
324
339
  /**
325
340
  * 根据上级菜单计算 depth:无上级为 1,否则为上级 depth + 1。
326
341
  */
@@ -523,4 +538,4 @@ declare const snowyflake: ConfigurableSnowflake;
523
538
  declare function getAppClientId(): string;
524
539
  declare function getDeviceWorkerId(): string;
525
540
 
526
- export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_MENU_DEPTH, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
541
+ export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LEAF_NO, MENU_LEAF_YES, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_MENU_DEPTH, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, isMenuLeaf, mapAuthorizationResource, mapMenuResource, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
@@ -228,6 +228,10 @@ type MenuResource = {
228
228
  * 菜单层级:无上级(根)为 1,其余为上级 depth + 1
229
229
  */
230
230
  depth: number;
231
+ /**
232
+ * 是否叶子节点:`1` 表示无下级菜单,不可再展开
233
+ */
234
+ leaf: number;
231
235
  type: MenuResourceType;
232
236
  name: string;
233
237
  identification: string;
@@ -252,6 +256,8 @@ type CreateMenuResourceBody = MenuResourceFormValues & {
252
256
  };
253
257
  type UpdateMenuResourceBody = Partial<MenuResourceFormValues>;
254
258
  type FetchMenuResourcesParams = {
259
+ /** 列表默认传 1,只拉根层 */
260
+ depth?: number;
255
261
  pagination?: ListPaginationParams;
256
262
  };
257
263
  type MenuResourceListResult = {
@@ -260,6 +266,9 @@ type MenuResourceListResult = {
260
266
  hasPreviousPage: boolean;
261
267
  hasNextPage: boolean;
262
268
  };
269
+ /** leaf === 1 表示无下级 */
270
+ declare const MENU_LEAF_YES = 1;
271
+ declare const MENU_LEAF_NO = 0;
263
272
  declare const RESOURCE_TYPE_API: ApiResourceType;
264
273
  declare const MENU_TYPE_PAGE: MenuResourceType;
265
274
  declare const MENU_TYPE_MENU: MenuResourceType;
@@ -313,6 +322,8 @@ type AuthorizationResourceApi = {
313
322
  };
314
323
  type MenuResourceApi = {
315
324
  list: (params?: FetchMenuResourcesParams, signal?: AbortSignal) => Promise<MenuResourceListResult>;
325
+ /** 展开下级:GET /authorization-resources/{resource-id}/sub-resources */
326
+ listSubResources: (resourceId: string, signal?: AbortSignal) => Promise<MenuResource[]>;
316
327
  /** 拉取权限点(type=api),供菜单表单多选 */
317
328
  listPermissionPoints: (params?: FetchAuthorizationResourcesParams, signal?: AbortSignal) => Promise<AuthorizationResourceListResult>;
318
329
  create: (values: MenuResourceFormValues, signal?: AbortSignal) => Promise<unknown>;
@@ -321,6 +332,10 @@ type MenuResourceApi = {
321
332
  };
322
333
  declare function mapAuthorizationResource(item: unknown): AuthorizationResource | null;
323
334
  declare function mapMenuResource(item: unknown): MenuResource | null;
335
+ /**
336
+ * leaf === 1 表示无下级菜单。
337
+ */
338
+ declare function isMenuLeaf(row: Pick<MenuResource, 'leaf'>): boolean;
324
339
  /**
325
340
  * 根据上级菜单计算 depth:无上级为 1,否则为上级 depth + 1。
326
341
  */
@@ -523,4 +538,4 @@ declare const snowyflake: ConfigurableSnowflake;
523
538
  declare function getAppClientId(): string;
524
539
  declare function getDeviceWorkerId(): string;
525
540
 
526
- export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_MENU_DEPTH, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
541
+ export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LEAF_NO, MENU_LEAF_YES, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_MENU_DEPTH, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, isMenuLeaf, mapAuthorizationResource, mapMenuResource, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
package/dist/vue/index.js CHANGED
@@ -309,6 +309,8 @@ import {
309
309
  } from "vue";
310
310
 
311
311
  // src/resources/types.ts
312
+ var MENU_LEAF_YES = 1;
313
+ var MENU_LEAF_NO = 0;
312
314
  var RESOURCE_TYPE_API = "api";
313
315
  var MENU_TYPE_PAGE = "page";
314
316
  var MENU_TYPE_MENU = "menu";
@@ -537,10 +539,13 @@ function mapMenuResource(item) {
537
539
  const rawDepth = row.depth;
538
540
  const parsedDepth = Number(rawDepth);
539
541
  const depth = Number.isFinite(parsedDepth) && parsedDepth > 0 ? Math.floor(parsedDepth) : parentId ? ROOT_MENU_DEPTH + 1 : ROOT_MENU_DEPTH;
542
+ const rawLeaf = row.leaf;
543
+ const leaf = rawLeaf === true || rawLeaf === 1 || rawLeaf === "1" || String(rawLeaf).toLowerCase() === "true" ? MENU_LEAF_YES : Number(rawLeaf) === MENU_LEAF_YES ? MENU_LEAF_YES : 0;
540
544
  return {
541
545
  resourceId: String(resourceId),
542
546
  parentId,
543
547
  depth,
548
+ leaf,
544
549
  type: toMenuType(row.type),
545
550
  name: String(row.name ?? ""),
546
551
  identification: String(row.identification ?? row.identity ?? row.path ?? ""),
@@ -549,6 +554,9 @@ function mapMenuResource(item) {
549
554
  status: toResourceStatus(row.status)
550
555
  };
551
556
  }
557
+ function isMenuLeaf(row) {
558
+ return Number(row.leaf) === MENU_LEAF_YES;
559
+ }
552
560
  function resolveMenuDepth(parentId, menus) {
553
561
  if (!parentId) return ROOT_MENU_DEPTH;
554
562
  const parent = menus.find((item) => item.resourceId === parentId);
@@ -558,6 +566,9 @@ function resolveMenuDepth(parentId, menus) {
558
566
  function buildListUrl(type, params) {
559
567
  const parts = [];
560
568
  appendQueryParam(parts, "type", type);
569
+ if (params?.depth !== void 0 && params?.depth !== null && String(params.depth) !== "") {
570
+ appendQueryParam(parts, "depth", String(params.depth));
571
+ }
561
572
  appendQueryParam(parts, "page-token", params?.pagination?.pageToken ?? "");
562
573
  appendQueryParam(parts, "page-size", params?.pagination?.pageSize ?? "20");
563
574
  appendQueryParam(parts, "page-direction", params?.pagination?.pageDirection ?? "current");
@@ -655,7 +666,10 @@ function createMenuResourceApi(request) {
655
666
  async list(params, signal) {
656
667
  const json = await request({
657
668
  method: "GET",
658
- url: buildListUrl(MENU_LIST_TYPE_PARAM, params),
669
+ url: buildListUrl(MENU_LIST_TYPE_PARAM, {
670
+ pagination: params?.pagination,
671
+ depth: params?.depth ?? ROOT_MENU_DEPTH
672
+ }),
659
673
  signal
660
674
  });
661
675
  const records = extractRecords(json).map(mapMenuResource).filter((item) => item !== null);
@@ -665,6 +679,14 @@ function createMenuResourceApi(request) {
665
679
  ...pagination
666
680
  };
667
681
  },
682
+ async listSubResources(resourceId, signal) {
683
+ const json = await request({
684
+ method: "GET",
685
+ url: `/authorization-resources/${encodeURIComponent(resourceId)}/sub-resources`,
686
+ signal
687
+ });
688
+ return extractRecords(json).map(mapMenuResource).filter((item) => item !== null);
689
+ },
668
690
  listPermissionPoints(params, signal) {
669
691
  return permissionApi.list(params, signal);
670
692
  },
@@ -1462,6 +1484,30 @@ var s2 = {
1462
1484
  borderBottom: "1px solid #f2f4f7",
1463
1485
  verticalAlign: "middle"
1464
1486
  },
1487
+ treeCell: {
1488
+ display: "flex",
1489
+ alignItems: "center",
1490
+ gap: "6px"
1491
+ },
1492
+ treeToggle: {
1493
+ width: "22px",
1494
+ height: "22px",
1495
+ border: "1px solid #d0d5dd",
1496
+ borderRadius: "4px",
1497
+ background: "#fff",
1498
+ color: "#475467",
1499
+ cursor: "pointer",
1500
+ fontSize: "10px",
1501
+ lineHeight: "20px",
1502
+ padding: "0",
1503
+ flexShrink: "0"
1504
+ },
1505
+ treeSpacer: {
1506
+ width: "22px",
1507
+ height: "22px",
1508
+ flexShrink: "0",
1509
+ display: "inline-block"
1510
+ },
1465
1511
  empty: {
1466
1512
  padding: "28px",
1467
1513
  textAlign: "center",
@@ -1664,6 +1710,9 @@ var MenuManager = defineComponent3({
1664
1710
  },
1665
1711
  setup(props, { slots }) {
1666
1712
  const records = ref2([]);
1713
+ const childrenMap = ref2({});
1714
+ const expandedIds = ref2({});
1715
+ const expandingIds = ref2({});
1667
1716
  const permissionPoints = ref2([]);
1668
1717
  const loading = ref2(false);
1669
1718
  const error = ref2("");
@@ -1684,17 +1733,39 @@ var MenuManager = defineComponent3({
1684
1733
  );
1685
1734
  return map;
1686
1735
  });
1736
+ const allKnownMenus = computed3(() => {
1737
+ const map = /* @__PURE__ */ new Map();
1738
+ records.value.forEach((row) => map.set(row.resourceId, row));
1739
+ Object.values(childrenMap.value).forEach((list) => {
1740
+ list.forEach((row) => map.set(row.resourceId, row));
1741
+ });
1742
+ return Array.from(map.values());
1743
+ });
1687
1744
  const parentOptions = computed3(
1688
- () => records.value.filter((row) => !editing.value || row.resourceId !== editing.value.resourceId).map((row) => ({
1745
+ () => allKnownMenus.value.filter((row) => !editing.value || row.resourceId !== editing.value.resourceId).map((row) => ({
1689
1746
  value: row.resourceId,
1690
1747
  label: `${row.name}\uFF08${MENU_TYPE_LABEL[row.type]}\uFF09`
1691
1748
  }))
1692
1749
  );
1750
+ const flatRows = computed3(() => {
1751
+ const rows = [];
1752
+ const walk = (list) => {
1753
+ list.forEach((row) => {
1754
+ rows.push(row);
1755
+ if (expandedIds.value[row.resourceId] && childrenMap.value[row.resourceId]?.length) {
1756
+ walk(childrenMap.value[row.resourceId]);
1757
+ }
1758
+ });
1759
+ };
1760
+ walk(records.value);
1761
+ return rows;
1762
+ });
1693
1763
  async function loadList(direction = "current", token = pageToken.value) {
1694
1764
  loading.value = true;
1695
1765
  error.value = "";
1696
1766
  try {
1697
1767
  const result = await props.api.list({
1768
+ depth: ROOT_MENU_DEPTH,
1698
1769
  pagination: {
1699
1770
  pageToken: token,
1700
1771
  pageSize: pageSize.value,
@@ -1702,6 +1773,9 @@ var MenuManager = defineComponent3({
1702
1773
  }
1703
1774
  });
1704
1775
  records.value = result.records;
1776
+ childrenMap.value = {};
1777
+ expandedIds.value = {};
1778
+ expandingIds.value = {};
1705
1779
  pageToken.value = result.pageToken;
1706
1780
  hasPreviousPage.value = result.hasPreviousPage;
1707
1781
  hasNextPage.value = result.hasNextPage;
@@ -1720,6 +1794,29 @@ var MenuManager = defineComponent3({
1720
1794
  } catch {
1721
1795
  }
1722
1796
  }
1797
+ async function toggleExpand(row) {
1798
+ if (isMenuLeaf(row)) return;
1799
+ const id = row.resourceId;
1800
+ if (expandedIds.value[id]) {
1801
+ expandedIds.value = { ...expandedIds.value, [id]: false };
1802
+ return;
1803
+ }
1804
+ if (!childrenMap.value[id]) {
1805
+ expandingIds.value = { ...expandingIds.value, [id]: true };
1806
+ error.value = "";
1807
+ try {
1808
+ const children = await props.api.listSubResources(id);
1809
+ childrenMap.value = { ...childrenMap.value, [id]: children };
1810
+ expandedIds.value = { ...expandedIds.value, [id]: true };
1811
+ } catch (err) {
1812
+ error.value = err instanceof Error ? err.message : "\u52A0\u8F7D\u4E0B\u7EA7\u83DC\u5355\u5931\u8D25";
1813
+ } finally {
1814
+ expandingIds.value = { ...expandingIds.value, [id]: false };
1815
+ }
1816
+ return;
1817
+ }
1818
+ expandedIds.value = { ...expandedIds.value, [id]: true };
1819
+ }
1723
1820
  function openCreate() {
1724
1821
  editing.value = null;
1725
1822
  Object.assign(form, emptyForm2());
@@ -1730,7 +1827,7 @@ var MenuManager = defineComponent3({
1730
1827
  editing.value = row;
1731
1828
  Object.assign(form, {
1732
1829
  parentId: row.parentId ?? null,
1733
- depth: resolveMenuDepth(row.parentId ?? null, records.value),
1830
+ depth: resolveMenuDepth(row.parentId ?? null, allKnownMenus.value),
1734
1831
  type: row.type,
1735
1832
  name: row.name,
1736
1833
  identification: row.identification,
@@ -1838,13 +1935,41 @@ var MenuManager = defineComponent3({
1838
1935
  h2("tr", [
1839
1936
  h2("td", { colspan: 6, style: s2.empty }, "\u52A0\u8F7D\u4E2D\u2026")
1840
1937
  ])
1841
- ] : records.value.length === 0 ? [
1938
+ ] : flatRows.value.length === 0 ? [
1842
1939
  h2("tr", [
1843
1940
  h2("td", { colspan: 6, style: s2.empty }, "\u6682\u65E0\u6570\u636E")
1844
1941
  ])
1845
- ] : records.value.map(
1846
- (row) => h2("tr", { key: row.resourceId }, [
1847
- h2("td", { style: s2.td }, row.name),
1942
+ ] : flatRows.value.map((row) => {
1943
+ const leaf = isMenuLeaf(row);
1944
+ const expanded = Boolean(expandedIds.value[row.resourceId]);
1945
+ const expanding = Boolean(expandingIds.value[row.resourceId]);
1946
+ const indent = Math.max(0, (row.depth || 1) - 1) * 18;
1947
+ return h2("tr", { key: row.resourceId }, [
1948
+ h2("td", { style: s2.td }, [
1949
+ h2(
1950
+ "div",
1951
+ {
1952
+ style: {
1953
+ ...s2.treeCell,
1954
+ paddingLeft: `${indent}px`
1955
+ }
1956
+ },
1957
+ [
1958
+ leaf ? h2("span", { style: s2.treeSpacer }) : h2(
1959
+ "button",
1960
+ {
1961
+ type: "button",
1962
+ style: s2.treeToggle,
1963
+ disabled: expanding,
1964
+ "aria-label": expanded ? "\u6536\u8D77" : "\u5C55\u5F00",
1965
+ onClick: () => void toggleExpand(row)
1966
+ },
1967
+ expanding ? "\u2026" : expanded ? "\u25BC" : "\u25B6"
1968
+ ),
1969
+ h2("span", row.name)
1970
+ ]
1971
+ )
1972
+ ]),
1848
1973
  h2("td", { style: s2.td }, [
1849
1974
  h2(
1850
1975
  "code",
@@ -1887,8 +2012,8 @@ var MenuManager = defineComponent3({
1887
2012
  "\u5220\u9664"
1888
2013
  )
1889
2014
  ])
1890
- ])
1891
- )
2015
+ ]);
2016
+ })
1892
2017
  )
1893
2018
  ])
1894
2019
  ]),
@@ -1980,7 +2105,7 @@ var MenuManager = defineComponent3({
1980
2105
  const value = e.target.value;
1981
2106
  const parentId = value ? value : null;
1982
2107
  form.parentId = parentId;
1983
- form.depth = resolveMenuDepth(parentId, records.value);
2108
+ form.depth = resolveMenuDepth(parentId, allKnownMenus.value);
1984
2109
  }
1985
2110
  },
1986
2111
  [
@@ -2385,6 +2510,8 @@ var SystemAdmin = defineComponent4({
2385
2510
  });
2386
2511
  export {
2387
2512
  Can,
2513
+ MENU_LEAF_NO,
2514
+ MENU_LEAF_YES,
2388
2515
  MENU_LIST_TYPE_PARAM,
2389
2516
  MENU_TYPE_BUTTON,
2390
2517
  MENU_TYPE_LABEL,
@@ -2421,6 +2548,7 @@ export {
2421
2548
  extractRecords,
2422
2549
  getAppClientId,
2423
2550
  getDeviceWorkerId,
2551
+ isMenuLeaf,
2424
2552
  mapAuthorizationResource,
2425
2553
  mapMenuResource,
2426
2554
  resolveMenuDepth,