com-angel-authorization 1.0.5 → 1.0.6

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.
package/dist/vue/index.js CHANGED
@@ -310,16 +310,35 @@ import {
310
310
 
311
311
  // src/resources/types.ts
312
312
  var RESOURCE_TYPE_API = "api";
313
+ var MENU_TYPE_PAGE = "page";
314
+ var MENU_TYPE_MENU = "menu";
315
+ var MENU_TYPE_BUTTON = "button";
316
+ var MENU_LIST_TYPE_PARAM = "page,menu,button";
317
+ var ROOT_PARENT_ID = "0";
313
318
  var RESOURCE_STATUS_ENABLED = 1;
314
319
  var RESOURCE_STATUS_DISABLED = 0;
315
320
  var RESOURCE_STATUS_OPTIONS = [
316
321
  { label: "\u542F\u7528", value: RESOURCE_STATUS_ENABLED },
317
322
  { label: "\u7981\u7528", value: RESOURCE_STATUS_DISABLED }
318
323
  ];
324
+ var MENU_VISIBILITY_OPTIONS = [
325
+ { label: "\u663E\u793A", value: RESOURCE_STATUS_ENABLED },
326
+ { label: "\u9690\u85CF", value: RESOURCE_STATUS_DISABLED }
327
+ ];
319
328
  var RESOURCE_PRIVATE_OPTIONS = [
320
329
  { label: "\u662F", value: true },
321
330
  { label: "\u5426", value: false }
322
331
  ];
332
+ var MENU_TYPE_OPTIONS = [
333
+ { label: "\u76EE\u5F55", value: MENU_TYPE_PAGE },
334
+ { label: "\u83DC\u5355", value: MENU_TYPE_MENU },
335
+ { label: "\u6309\u94AE", value: MENU_TYPE_BUTTON }
336
+ ];
337
+ var MENU_TYPE_LABEL = {
338
+ page: "\u76EE\u5F55",
339
+ menu: "\u83DC\u5355",
340
+ button: "\u6309\u94AE"
341
+ };
323
342
 
324
343
  // src/utils/snowflake.ts
325
344
  var DEVICE_WORKER_ID_KEY = "hgams_device_worker_id";
@@ -464,6 +483,29 @@ function toBoolean(value) {
464
483
  }
465
484
  return false;
466
485
  }
486
+ function toStringArray(value) {
487
+ if (Array.isArray(value)) {
488
+ return value.map((item) => {
489
+ if (item && typeof item === "object") {
490
+ const row = item;
491
+ const id = row.resourceId ?? row.resource_id ?? row.id;
492
+ return id === void 0 || id === null ? "" : String(id);
493
+ }
494
+ return String(item ?? "");
495
+ }).filter(Boolean);
496
+ }
497
+ if (typeof value === "string" && value.trim()) {
498
+ return value.split(",").map((s3) => s3.trim()).filter(Boolean);
499
+ }
500
+ return [];
501
+ }
502
+ function toMenuType(value) {
503
+ const v = String(value ?? "").toLowerCase();
504
+ if (v === MENU_TYPE_PAGE || v === MENU_TYPE_MENU || v === MENU_TYPE_BUTTON) {
505
+ return v;
506
+ }
507
+ return MENU_TYPE_MENU;
508
+ }
467
509
  function mapAuthorizationResource(item) {
468
510
  if (!item || typeof item !== "object") return null;
469
511
  const row = item;
@@ -479,9 +521,31 @@ function mapAuthorizationResource(item) {
479
521
  description: String(row.description ?? row.desc ?? "")
480
522
  };
481
523
  }
482
- function buildListUrl(params) {
524
+ function mapMenuResource(item) {
525
+ if (!item || typeof item !== "object") return null;
526
+ const row = item;
527
+ const resourceId = row.resourceId ?? row.resource_id ?? row.id;
528
+ if (resourceId === void 0 || resourceId === null || resourceId === "") return null;
529
+ const permissionPointIds = toStringArray(
530
+ row.permissionPointIds ?? row.permission_point_ids ?? row.permissionPoints ?? row.permissions
531
+ );
532
+ const permissionNamesRaw = row.permissionPointNames ?? row.permission_point_names ?? row.permissionNames;
533
+ const permissionPointNames = Array.isArray(permissionNamesRaw) ? permissionNamesRaw.map((n) => String(n ?? "")).filter(Boolean) : void 0;
534
+ const parentId = row.parentId ?? row.parent_id ?? ROOT_PARENT_ID;
535
+ return {
536
+ resourceId: String(resourceId),
537
+ parentId: parentId === void 0 || parentId === null ? ROOT_PARENT_ID : String(parentId),
538
+ type: toMenuType(row.type),
539
+ name: String(row.name ?? ""),
540
+ identification: String(row.identification ?? row.identity ?? row.path ?? ""),
541
+ permissionPointIds,
542
+ permissionPointNames,
543
+ status: toResourceStatus(row.status)
544
+ };
545
+ }
546
+ function buildListUrl(type, params) {
483
547
  const parts = [];
484
- appendQueryParam(parts, "type", RESOURCE_TYPE_API);
548
+ appendQueryParam(parts, "type", type);
485
549
  appendQueryParam(parts, "page-token", params?.pagination?.pageToken ?? "");
486
550
  appendQueryParam(parts, "page-size", params?.pagination?.pageSize ?? "20");
487
551
  appendQueryParam(parts, "page-direction", params?.pagination?.pageDirection ?? "current");
@@ -508,12 +572,33 @@ function buildUpdateBody(values) {
508
572
  description: values.description.trim()
509
573
  };
510
574
  }
575
+ function buildCreateMenuBody(values, resourceId = getAppClientId()) {
576
+ return {
577
+ resourceId,
578
+ parentId: values.parentId || ROOT_PARENT_ID,
579
+ type: values.type,
580
+ name: values.name.trim(),
581
+ identification: values.identification.trim(),
582
+ permissionPointIds: [...values.permissionPointIds],
583
+ status: values.status
584
+ };
585
+ }
586
+ function buildUpdateMenuBody(values) {
587
+ return {
588
+ parentId: values.parentId || ROOT_PARENT_ID,
589
+ type: values.type,
590
+ name: values.name.trim(),
591
+ identification: values.identification.trim(),
592
+ permissionPointIds: [...values.permissionPointIds],
593
+ status: values.status
594
+ };
595
+ }
511
596
  function createAuthorizationResourceApi(request) {
512
597
  return {
513
598
  async list(params, signal) {
514
599
  const json = await request({
515
600
  method: "GET",
516
- url: buildListUrl(params),
601
+ url: buildListUrl(RESOURCE_TYPE_API, params),
517
602
  signal
518
603
  });
519
604
  const records = extractRecords(json).map(mapAuthorizationResource).filter((item) => item !== null);
@@ -548,6 +633,50 @@ function createAuthorizationResourceApi(request) {
548
633
  }
549
634
  };
550
635
  }
636
+ function createMenuResourceApi(request) {
637
+ const permissionApi = createAuthorizationResourceApi(request);
638
+ return {
639
+ async list(params, signal) {
640
+ const json = await request({
641
+ method: "GET",
642
+ url: buildListUrl(MENU_LIST_TYPE_PARAM, params),
643
+ signal
644
+ });
645
+ const records = extractRecords(json).map(mapMenuResource).filter((item) => item !== null);
646
+ const pagination = extractPagination(json);
647
+ return {
648
+ records,
649
+ ...pagination
650
+ };
651
+ },
652
+ listPermissionPoints(params, signal) {
653
+ return permissionApi.list(params, signal);
654
+ },
655
+ async create(values, signal) {
656
+ return request({
657
+ method: "POST",
658
+ url: "/authorization-resources",
659
+ body: buildCreateMenuBody(values),
660
+ signal
661
+ });
662
+ },
663
+ async update(resourceId, values, signal) {
664
+ return request({
665
+ method: "PATCH",
666
+ url: `/authorization-resources/${encodeURIComponent(resourceId)}`,
667
+ body: buildUpdateMenuBody(values),
668
+ signal
669
+ });
670
+ },
671
+ async remove(resourceId, signal) {
672
+ return request({
673
+ method: "DELETE",
674
+ url: `/authorization-resources/${encodeURIComponent(resourceId)}`,
675
+ signal
676
+ });
677
+ }
678
+ };
679
+ }
551
680
  function createDefaultResourceRequest(options = {}) {
552
681
  const baseUrl = (options.baseUrl ?? "").replace(/\/+$/, "");
553
682
  const credentials = options.credentials ?? "include";
@@ -1248,8 +1377,813 @@ var ResourceManager = defineComponent2({
1248
1377
  ]);
1249
1378
  }
1250
1379
  });
1380
+
1381
+ // src/vue/MenuManager.ts
1382
+ import {
1383
+ computed as computed3,
1384
+ defineComponent as defineComponent3,
1385
+ h as h2,
1386
+ onMounted as onMounted2,
1387
+ reactive as reactive2,
1388
+ ref as ref2,
1389
+ watch as watch2
1390
+ } from "vue";
1391
+ var PAGE_SIZE_OPTIONS2 = ["10", "20", "50", "100"];
1392
+ function emptyForm2() {
1393
+ return {
1394
+ parentId: ROOT_PARENT_ID,
1395
+ type: MENU_TYPE_MENU,
1396
+ name: "",
1397
+ identification: "",
1398
+ permissionPointIds: [],
1399
+ status: RESOURCE_STATUS_ENABLED
1400
+ };
1401
+ }
1402
+ var s2 = {
1403
+ root: {
1404
+ display: "flex",
1405
+ flexDirection: "column",
1406
+ gap: "16px",
1407
+ padding: "16px",
1408
+ color: "#101828",
1409
+ fontFamily: '"PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif'
1410
+ },
1411
+ toolbar: {
1412
+ display: "flex",
1413
+ alignItems: "center",
1414
+ justifyContent: "space-between",
1415
+ gap: "12px"
1416
+ },
1417
+ title: { margin: "0", fontSize: "18px", fontWeight: "600" },
1418
+ toolbarRight: { display: "flex", alignItems: "center", gap: "8px" },
1419
+ error: {
1420
+ padding: "10px 12px",
1421
+ borderRadius: "8px",
1422
+ background: "#fef3f2",
1423
+ color: "#b42318",
1424
+ fontSize: "13px"
1425
+ },
1426
+ tableWrap: {
1427
+ overflow: "auto",
1428
+ border: "1px solid #eaecf0",
1429
+ borderRadius: "10px",
1430
+ background: "#fff"
1431
+ },
1432
+ table: { width: "100%", borderCollapse: "collapse", minWidth: "820px" },
1433
+ th: {
1434
+ textAlign: "left",
1435
+ padding: "12px 14px",
1436
+ fontSize: "13px",
1437
+ fontWeight: "600",
1438
+ color: "#475467",
1439
+ background: "#f9fafb",
1440
+ borderBottom: "1px solid #eaecf0"
1441
+ },
1442
+ td: {
1443
+ padding: "12px 14px",
1444
+ fontSize: "14px",
1445
+ borderBottom: "1px solid #f2f4f7",
1446
+ verticalAlign: "middle"
1447
+ },
1448
+ empty: {
1449
+ padding: "28px",
1450
+ textAlign: "center",
1451
+ color: "#98a2b3",
1452
+ fontSize: "14px"
1453
+ },
1454
+ code: {
1455
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
1456
+ fontSize: "13px",
1457
+ background: "#f2f4f7",
1458
+ padding: "2px 6px",
1459
+ borderRadius: "4px"
1460
+ },
1461
+ badge: {
1462
+ display: "inline-block",
1463
+ padding: "2px 8px",
1464
+ borderRadius: "999px",
1465
+ fontSize: "12px",
1466
+ fontWeight: "500"
1467
+ },
1468
+ linkBtn: {
1469
+ border: "none",
1470
+ background: "transparent",
1471
+ color: "#049BAD",
1472
+ cursor: "pointer",
1473
+ padding: "0 8px 0 0",
1474
+ fontSize: "13px"
1475
+ },
1476
+ pagination: {
1477
+ display: "flex",
1478
+ alignItems: "center",
1479
+ justifyContent: "space-between",
1480
+ gap: "12px"
1481
+ },
1482
+ pageSize: {
1483
+ display: "flex",
1484
+ alignItems: "center",
1485
+ gap: "8px",
1486
+ fontSize: "13px",
1487
+ color: "#475467"
1488
+ },
1489
+ pageBtns: { display: "flex", gap: "8px" },
1490
+ primaryBtn: {
1491
+ border: "none",
1492
+ background: "#049BAD",
1493
+ color: "#fff",
1494
+ borderRadius: "8px",
1495
+ padding: "8px 14px",
1496
+ cursor: "pointer",
1497
+ fontSize: "14px"
1498
+ },
1499
+ secondaryBtn: {
1500
+ border: "1px solid #d0d5dd",
1501
+ background: "#fff",
1502
+ color: "#344054",
1503
+ borderRadius: "8px",
1504
+ padding: "8px 14px",
1505
+ cursor: "pointer",
1506
+ fontSize: "14px"
1507
+ },
1508
+ dangerBtn: {
1509
+ border: "none",
1510
+ background: "#d92d20",
1511
+ color: "#fff",
1512
+ borderRadius: "8px",
1513
+ padding: "8px 14px",
1514
+ cursor: "pointer",
1515
+ fontSize: "14px"
1516
+ },
1517
+ select: {
1518
+ border: "1px solid #d0d5dd",
1519
+ borderRadius: "6px",
1520
+ padding: "4px 8px",
1521
+ fontSize: "13px",
1522
+ backgroundColor: "#ffffff",
1523
+ color: "#101828"
1524
+ },
1525
+ mask: {
1526
+ position: "fixed",
1527
+ inset: "0",
1528
+ background: "rgba(16, 24, 40, 0.45)",
1529
+ display: "flex",
1530
+ alignItems: "center",
1531
+ justifyContent: "center",
1532
+ zIndex: "1000",
1533
+ padding: "16px"
1534
+ },
1535
+ dialog: {
1536
+ width: "100%",
1537
+ maxWidth: "480px",
1538
+ background: "#fff",
1539
+ borderRadius: "12px",
1540
+ boxShadow: "0 20px 40px rgba(16,24,40,0.18)",
1541
+ maxHeight: "90vh",
1542
+ overflow: "auto"
1543
+ },
1544
+ dialogHeader: {
1545
+ display: "flex",
1546
+ alignItems: "center",
1547
+ justifyContent: "space-between",
1548
+ padding: "14px 16px",
1549
+ borderBottom: "1px solid #eaecf0",
1550
+ position: "sticky",
1551
+ top: "0",
1552
+ background: "#fff",
1553
+ zIndex: "1"
1554
+ },
1555
+ dialogTitle: { margin: "0", fontSize: "16px", fontWeight: "600" },
1556
+ iconBtn: {
1557
+ border: "none",
1558
+ background: "transparent",
1559
+ fontSize: "22px",
1560
+ lineHeight: "1",
1561
+ cursor: "pointer",
1562
+ color: "#667085"
1563
+ },
1564
+ form: { display: "flex", flexDirection: "column", gap: "12px", padding: "16px" },
1565
+ confirmBody: {
1566
+ display: "flex",
1567
+ flexDirection: "column",
1568
+ gap: "16px",
1569
+ padding: "16px"
1570
+ },
1571
+ confirmText: {
1572
+ margin: "0",
1573
+ fontSize: "14px",
1574
+ color: "#344054",
1575
+ lineHeight: "1.6"
1576
+ },
1577
+ field: { display: "flex", flexDirection: "column", gap: "6px" },
1578
+ fieldset: {
1579
+ margin: "0",
1580
+ padding: "0",
1581
+ border: "none",
1582
+ display: "flex",
1583
+ flexDirection: "column",
1584
+ gap: "8px"
1585
+ },
1586
+ label: { fontSize: "13px", color: "#344054", fontWeight: "500" },
1587
+ input: {
1588
+ border: "1px solid #d0d5dd",
1589
+ borderRadius: "8px",
1590
+ padding: "8px 10px",
1591
+ fontSize: "14px",
1592
+ outline: "none",
1593
+ backgroundColor: "#ffffff",
1594
+ color: "#101828",
1595
+ boxSizing: "border-box",
1596
+ width: "100%"
1597
+ },
1598
+ radioGroup: { display: "flex", flexWrap: "wrap", gap: "16px" },
1599
+ radioItem: {
1600
+ display: "flex",
1601
+ alignItems: "center",
1602
+ gap: "6px",
1603
+ fontSize: "14px",
1604
+ color: "#344054",
1605
+ cursor: "pointer"
1606
+ },
1607
+ multiSelect: {
1608
+ maxHeight: "160px",
1609
+ overflow: "auto",
1610
+ border: "1px solid #eaecf0",
1611
+ borderRadius: "8px",
1612
+ padding: "8px",
1613
+ background: "#f9fafb"
1614
+ },
1615
+ checkItem: {
1616
+ display: "flex",
1617
+ alignItems: "center",
1618
+ gap: "8px",
1619
+ padding: "6px 4px",
1620
+ fontSize: "13px",
1621
+ color: "#344054",
1622
+ cursor: "pointer"
1623
+ },
1624
+ hint: { fontSize: "13px", color: "#98a2b3", padding: "8px" },
1625
+ dialogFooter: {
1626
+ display: "flex",
1627
+ justifyContent: "flex-end",
1628
+ gap: "8px",
1629
+ paddingTop: "4px"
1630
+ }
1631
+ };
1632
+ var MenuManager = defineComponent3({
1633
+ name: "MenuManager",
1634
+ props: {
1635
+ api: {
1636
+ type: Object,
1637
+ required: true
1638
+ },
1639
+ title: {
1640
+ type: String,
1641
+ default: "\u83DC\u5355\u7BA1\u7406"
1642
+ },
1643
+ pageSize: {
1644
+ type: String,
1645
+ default: "20"
1646
+ }
1647
+ },
1648
+ setup(props, { slots }) {
1649
+ const records = ref2([]);
1650
+ const permissionPoints = ref2([]);
1651
+ const loading = ref2(false);
1652
+ const error = ref2("");
1653
+ const pageSize = ref2(props.pageSize);
1654
+ const pageToken = ref2("");
1655
+ const hasPreviousPage = ref2(false);
1656
+ const hasNextPage = ref2(false);
1657
+ const dialogOpen = ref2(false);
1658
+ const editing = ref2(null);
1659
+ const form = reactive2(emptyForm2());
1660
+ const saving = ref2(false);
1661
+ const deletingRow = ref2(null);
1662
+ const deleting = ref2(false);
1663
+ const permissionNameMap = computed3(() => {
1664
+ const map = /* @__PURE__ */ new Map();
1665
+ permissionPoints.value.forEach(
1666
+ (p) => map.set(p.resourceId, p.name || p.identification)
1667
+ );
1668
+ return map;
1669
+ });
1670
+ const parentOptions = computed3(
1671
+ () => records.value.filter((row) => !editing.value || row.resourceId !== editing.value.resourceId).map((row) => ({
1672
+ value: row.resourceId,
1673
+ label: `${row.name}\uFF08${MENU_TYPE_LABEL[row.type]}\uFF09`
1674
+ }))
1675
+ );
1676
+ async function loadList(direction = "current", token = pageToken.value) {
1677
+ loading.value = true;
1678
+ error.value = "";
1679
+ try {
1680
+ const result = await props.api.list({
1681
+ pagination: {
1682
+ pageToken: token,
1683
+ pageSize: pageSize.value,
1684
+ pageDirection: direction
1685
+ }
1686
+ });
1687
+ records.value = result.records;
1688
+ pageToken.value = result.pageToken;
1689
+ hasPreviousPage.value = result.hasPreviousPage;
1690
+ hasNextPage.value = result.hasNextPage;
1691
+ } catch (err) {
1692
+ error.value = err instanceof Error ? err.message : "\u52A0\u8F7D\u5931\u8D25";
1693
+ } finally {
1694
+ loading.value = false;
1695
+ }
1696
+ }
1697
+ async function loadPermissionPoints() {
1698
+ try {
1699
+ const result = await props.api.listPermissionPoints({
1700
+ pagination: { pageSize: "200", pageDirection: "current" }
1701
+ });
1702
+ permissionPoints.value = result.records;
1703
+ } catch {
1704
+ }
1705
+ }
1706
+ function openCreate() {
1707
+ editing.value = null;
1708
+ Object.assign(form, emptyForm2());
1709
+ dialogOpen.value = true;
1710
+ void loadPermissionPoints();
1711
+ }
1712
+ function openEdit(row) {
1713
+ editing.value = row;
1714
+ Object.assign(form, {
1715
+ parentId: row.parentId || ROOT_PARENT_ID,
1716
+ type: row.type,
1717
+ name: row.name,
1718
+ identification: row.identification,
1719
+ permissionPointIds: [...row.permissionPointIds],
1720
+ status: row.status
1721
+ });
1722
+ dialogOpen.value = true;
1723
+ void loadPermissionPoints();
1724
+ }
1725
+ function closeDialog() {
1726
+ if (!saving.value) dialogOpen.value = false;
1727
+ }
1728
+ async function handleSubmit(event) {
1729
+ event.preventDefault();
1730
+ if (!form.name.trim()) {
1731
+ error.value = "\u8BF7\u586B\u5199\u83DC\u5355\u540D\u79F0";
1732
+ return;
1733
+ }
1734
+ saving.value = true;
1735
+ error.value = "";
1736
+ try {
1737
+ if (editing.value) {
1738
+ await props.api.update(editing.value.resourceId, { ...form });
1739
+ } else {
1740
+ await props.api.create({ ...form });
1741
+ }
1742
+ dialogOpen.value = false;
1743
+ await loadList("current", "");
1744
+ } catch (err) {
1745
+ error.value = err instanceof Error ? err.message : "\u4FDD\u5B58\u5931\u8D25";
1746
+ } finally {
1747
+ saving.value = false;
1748
+ }
1749
+ }
1750
+ function askDelete(row) {
1751
+ deletingRow.value = row;
1752
+ }
1753
+ function closeDeleteDialog() {
1754
+ if (!deleting.value) deletingRow.value = null;
1755
+ }
1756
+ async function confirmDelete() {
1757
+ if (!deletingRow.value) return;
1758
+ deleting.value = true;
1759
+ error.value = "";
1760
+ try {
1761
+ await props.api.remove(deletingRow.value.resourceId);
1762
+ deletingRow.value = null;
1763
+ await loadList("current", "");
1764
+ } catch (err) {
1765
+ error.value = err instanceof Error ? err.message : "\u5220\u9664\u5931\u8D25";
1766
+ } finally {
1767
+ deleting.value = false;
1768
+ }
1769
+ }
1770
+ function togglePermission(id) {
1771
+ const exists = form.permissionPointIds.includes(id);
1772
+ form.permissionPointIds = exists ? form.permissionPointIds.filter((x) => x !== id) : [...form.permissionPointIds, id];
1773
+ }
1774
+ function renderPermissionLabels(row) {
1775
+ if (row.permissionPointNames?.length) {
1776
+ return row.permissionPointNames.join("\u3001");
1777
+ }
1778
+ if (!row.permissionPointIds.length) return "\u2014";
1779
+ return row.permissionPointIds.map((id) => permissionNameMap.value.get(id) ?? id).join("\u3001");
1780
+ }
1781
+ onMounted2(() => {
1782
+ void loadList("current", "");
1783
+ void loadPermissionPoints();
1784
+ });
1785
+ watch2(
1786
+ () => [props.api, pageSize.value],
1787
+ () => {
1788
+ pageToken.value = "";
1789
+ void loadList("current", "");
1790
+ }
1791
+ );
1792
+ return () => h2("div", { style: s2.root }, [
1793
+ h2("div", { style: s2.toolbar }, [
1794
+ h2("h2", { style: s2.title }, props.title),
1795
+ h2("div", { style: s2.toolbarRight }, [
1796
+ slots.toolbarExtra?.(),
1797
+ h2(
1798
+ "button",
1799
+ { type: "button", style: s2.primaryBtn, onClick: openCreate },
1800
+ "\u65B0\u589E"
1801
+ )
1802
+ ])
1803
+ ]),
1804
+ error.value ? h2("div", { style: s2.error }, error.value) : null,
1805
+ h2("div", { style: s2.tableWrap }, [
1806
+ h2("table", { style: s2.table }, [
1807
+ h2("thead", [
1808
+ h2("tr", [
1809
+ h2("th", { style: s2.th }, "\u83DC\u5355\u540D\u79F0"),
1810
+ h2("th", { style: s2.th }, "\u8BF7\u6C42\u5730\u5740"),
1811
+ h2("th", { style: { ...s2.th, width: "90px" } }, "\u7C7B\u578B"),
1812
+ h2("th", { style: { ...s2.th, width: "80px" } }, "\u53EF\u89C1"),
1813
+ h2("th", { style: s2.th }, "\u6743\u9650\u6807\u8BC6"),
1814
+ h2("th", { style: { ...s2.th, width: "140px" } }, "\u64CD\u4F5C")
1815
+ ])
1816
+ ]),
1817
+ h2(
1818
+ "tbody",
1819
+ loading.value ? [
1820
+ h2("tr", [
1821
+ h2("td", { colspan: 6, style: s2.empty }, "\u52A0\u8F7D\u4E2D\u2026")
1822
+ ])
1823
+ ] : records.value.length === 0 ? [
1824
+ h2("tr", [
1825
+ h2("td", { colspan: 6, style: s2.empty }, "\u6682\u65E0\u6570\u636E")
1826
+ ])
1827
+ ] : records.value.map(
1828
+ (row) => h2("tr", { key: row.resourceId }, [
1829
+ h2("td", { style: s2.td }, row.name),
1830
+ h2("td", { style: s2.td }, [
1831
+ h2(
1832
+ "code",
1833
+ { style: s2.code },
1834
+ row.identification || "\u2014"
1835
+ )
1836
+ ]),
1837
+ h2("td", { style: s2.td }, MENU_TYPE_LABEL[row.type]),
1838
+ h2("td", { style: s2.td }, [
1839
+ h2(
1840
+ "span",
1841
+ {
1842
+ style: {
1843
+ ...s2.badge,
1844
+ background: row.status === RESOURCE_STATUS_ENABLED ? "#e8f7ef" : "#f4f4f5",
1845
+ color: row.status === RESOURCE_STATUS_ENABLED ? "#067647" : "#667085"
1846
+ }
1847
+ },
1848
+ row.status === RESOURCE_STATUS_ENABLED ? "\u663E\u793A" : "\u9690\u85CF"
1849
+ )
1850
+ ]),
1851
+ h2("td", { style: s2.td }, renderPermissionLabels(row)),
1852
+ h2("td", { style: s2.td }, [
1853
+ h2(
1854
+ "button",
1855
+ {
1856
+ type: "button",
1857
+ style: s2.linkBtn,
1858
+ onClick: () => openEdit(row)
1859
+ },
1860
+ "\u7F16\u8F91"
1861
+ ),
1862
+ h2(
1863
+ "button",
1864
+ {
1865
+ type: "button",
1866
+ style: { ...s2.linkBtn, color: "#d92d20" },
1867
+ onClick: () => askDelete(row)
1868
+ },
1869
+ "\u5220\u9664"
1870
+ )
1871
+ ])
1872
+ ])
1873
+ )
1874
+ )
1875
+ ])
1876
+ ]),
1877
+ h2("div", { style: s2.pagination }, [
1878
+ h2("label", { style: s2.pageSize }, [
1879
+ "\u6BCF\u9875",
1880
+ h2(
1881
+ "select",
1882
+ {
1883
+ style: s2.select,
1884
+ value: pageSize.value,
1885
+ onChange: (e) => {
1886
+ pageSize.value = e.target.value;
1887
+ }
1888
+ },
1889
+ PAGE_SIZE_OPTIONS2.map(
1890
+ (size) => h2("option", { key: size, value: size }, size)
1891
+ )
1892
+ )
1893
+ ]),
1894
+ h2("div", { style: s2.pageBtns }, [
1895
+ h2(
1896
+ "button",
1897
+ {
1898
+ type: "button",
1899
+ style: s2.secondaryBtn,
1900
+ disabled: !hasPreviousPage.value || loading.value,
1901
+ onClick: () => void loadList("previous")
1902
+ },
1903
+ "\u4E0A\u4E00\u9875"
1904
+ ),
1905
+ h2(
1906
+ "button",
1907
+ {
1908
+ type: "button",
1909
+ style: s2.secondaryBtn,
1910
+ disabled: !hasNextPage.value || loading.value,
1911
+ onClick: () => void loadList("next")
1912
+ },
1913
+ "\u4E0B\u4E00\u9875"
1914
+ )
1915
+ ])
1916
+ ]),
1917
+ dialogOpen.value ? h2(
1918
+ "div",
1919
+ { style: s2.mask, onClick: closeDialog },
1920
+ [
1921
+ h2(
1922
+ "div",
1923
+ {
1924
+ style: { ...s2.dialog, maxWidth: "520px" },
1925
+ role: "dialog",
1926
+ "aria-modal": "true",
1927
+ onClick: (e) => e.stopPropagation()
1928
+ },
1929
+ [
1930
+ h2("div", { style: s2.dialogHeader }, [
1931
+ h2(
1932
+ "h3",
1933
+ { style: s2.dialogTitle },
1934
+ editing.value ? "\u7F16\u8F91\u83DC\u5355" : "\u65B0\u589E\u83DC\u5355"
1935
+ ),
1936
+ h2(
1937
+ "button",
1938
+ {
1939
+ type: "button",
1940
+ style: s2.iconBtn,
1941
+ "aria-label": "\u5173\u95ED",
1942
+ onClick: closeDialog
1943
+ },
1944
+ "\xD7"
1945
+ )
1946
+ ]),
1947
+ h2(
1948
+ "form",
1949
+ {
1950
+ style: s2.form,
1951
+ onSubmit: (e) => void handleSubmit(e)
1952
+ },
1953
+ [
1954
+ h2("label", { style: s2.field }, [
1955
+ h2("span", { style: s2.label }, "\u4E0A\u7EA7\u83DC\u5355"),
1956
+ h2(
1957
+ "select",
1958
+ {
1959
+ style: s2.input,
1960
+ value: form.parentId,
1961
+ onChange: (e) => {
1962
+ form.parentId = e.target.value;
1963
+ }
1964
+ },
1965
+ [
1966
+ h2("option", { value: ROOT_PARENT_ID }, "\u6839\u76EE\u5F55"),
1967
+ ...parentOptions.value.map(
1968
+ (opt) => h2(
1969
+ "option",
1970
+ { key: opt.value, value: opt.value },
1971
+ opt.label
1972
+ )
1973
+ )
1974
+ ]
1975
+ )
1976
+ ]),
1977
+ h2("fieldset", { style: s2.fieldset }, [
1978
+ h2("legend", { style: s2.label }, "\u83DC\u5355\u7C7B\u578B"),
1979
+ h2(
1980
+ "div",
1981
+ { style: s2.radioGroup },
1982
+ MENU_TYPE_OPTIONS.map(
1983
+ (opt) => h2("label", { key: opt.value, style: s2.radioItem }, [
1984
+ h2("input", {
1985
+ type: "radio",
1986
+ name: "menu-type",
1987
+ checked: form.type === opt.value,
1988
+ onChange: () => {
1989
+ form.type = opt.value;
1990
+ }
1991
+ }),
1992
+ opt.label
1993
+ ])
1994
+ )
1995
+ )
1996
+ ]),
1997
+ h2("label", { style: s2.field }, [
1998
+ h2("span", { style: s2.label }, "\u83DC\u5355\u540D\u79F0"),
1999
+ h2("input", {
2000
+ style: s2.input,
2001
+ value: form.name,
2002
+ placeholder: "\u8BF7\u8F93\u5165\u83DC\u5355\u540D\u79F0",
2003
+ required: true,
2004
+ onInput: (e) => {
2005
+ form.name = e.target.value;
2006
+ }
2007
+ })
2008
+ ]),
2009
+ h2("label", { style: s2.field }, [
2010
+ h2("span", { style: s2.label }, "\u8BF7\u6C42\u5730\u5740"),
2011
+ h2("input", {
2012
+ style: s2.input,
2013
+ value: form.identification,
2014
+ placeholder: "\u5982 /system/user",
2015
+ onInput: (e) => {
2016
+ form.identification = e.target.value;
2017
+ }
2018
+ })
2019
+ ]),
2020
+ h2("fieldset", { style: s2.fieldset }, [
2021
+ h2("legend", { style: s2.label }, "\u6743\u9650\u6807\u8BC6"),
2022
+ h2(
2023
+ "div",
2024
+ { style: s2.multiSelect },
2025
+ permissionPoints.value.length === 0 ? [
2026
+ h2(
2027
+ "div",
2028
+ { style: s2.hint },
2029
+ "\u6682\u65E0\u6743\u9650\u70B9\uFF0C\u8BF7\u5148\u5728\u6743\u9650\u70B9\u7BA1\u7406\u4E2D\u65B0\u589E"
2030
+ )
2031
+ ] : permissionPoints.value.map(
2032
+ (p) => h2(
2033
+ "label",
2034
+ { key: p.resourceId, style: s2.checkItem },
2035
+ [
2036
+ h2("input", {
2037
+ type: "checkbox",
2038
+ checked: form.permissionPointIds.includes(
2039
+ p.resourceId
2040
+ ),
2041
+ onChange: () => togglePermission(p.resourceId)
2042
+ }),
2043
+ h2("span", [
2044
+ p.name,
2045
+ h2(
2046
+ "code",
2047
+ {
2048
+ style: {
2049
+ ...s2.code,
2050
+ marginLeft: "6px"
2051
+ }
2052
+ },
2053
+ p.identification
2054
+ )
2055
+ ])
2056
+ ]
2057
+ )
2058
+ )
2059
+ )
2060
+ ]),
2061
+ h2("fieldset", { style: s2.fieldset }, [
2062
+ h2("legend", { style: s2.label }, "\u72B6\u6001"),
2063
+ h2(
2064
+ "div",
2065
+ { style: s2.radioGroup },
2066
+ MENU_VISIBILITY_OPTIONS.map(
2067
+ (opt) => h2("label", { key: opt.value, style: s2.radioItem }, [
2068
+ h2("input", {
2069
+ type: "radio",
2070
+ name: "menu-status",
2071
+ checked: form.status === opt.value,
2072
+ onChange: () => {
2073
+ form.status = opt.value;
2074
+ }
2075
+ }),
2076
+ opt.label
2077
+ ])
2078
+ )
2079
+ )
2080
+ ]),
2081
+ h2("div", { style: s2.dialogFooter }, [
2082
+ h2(
2083
+ "button",
2084
+ {
2085
+ type: "button",
2086
+ style: s2.secondaryBtn,
2087
+ onClick: closeDialog
2088
+ },
2089
+ "\u53D6\u6D88"
2090
+ ),
2091
+ h2(
2092
+ "button",
2093
+ {
2094
+ type: "submit",
2095
+ style: s2.primaryBtn,
2096
+ disabled: saving.value
2097
+ },
2098
+ saving.value ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58"
2099
+ )
2100
+ ])
2101
+ ]
2102
+ )
2103
+ ]
2104
+ )
2105
+ ]
2106
+ ) : null,
2107
+ deletingRow.value ? h2(
2108
+ "div",
2109
+ { style: s2.mask, onClick: closeDeleteDialog },
2110
+ [
2111
+ h2(
2112
+ "div",
2113
+ {
2114
+ style: { ...s2.dialog, maxWidth: "420px" },
2115
+ role: "dialog",
2116
+ "aria-modal": "true",
2117
+ "aria-labelledby": "angel-auth-menu-delete-title",
2118
+ onClick: (e) => e.stopPropagation()
2119
+ },
2120
+ [
2121
+ h2("div", { style: s2.dialogHeader }, [
2122
+ h2(
2123
+ "h3",
2124
+ {
2125
+ id: "angel-auth-menu-delete-title",
2126
+ style: s2.dialogTitle
2127
+ },
2128
+ "\u786E\u8BA4\u5220\u9664"
2129
+ ),
2130
+ h2(
2131
+ "button",
2132
+ {
2133
+ type: "button",
2134
+ style: s2.iconBtn,
2135
+ "aria-label": "\u5173\u95ED",
2136
+ onClick: closeDeleteDialog
2137
+ },
2138
+ "\xD7"
2139
+ )
2140
+ ]),
2141
+ h2("div", { style: s2.confirmBody }, [
2142
+ h2("p", { style: s2.confirmText }, [
2143
+ "\u786E\u8BA4\u5220\u9664\u83DC\u5355\u300C",
2144
+ h2("strong", deletingRow.value.name),
2145
+ "\u300D\u5417\uFF1F\u5220\u9664\u540E\u4E0D\u53EF\u6062\u590D\u3002"
2146
+ ]),
2147
+ h2("div", { style: s2.dialogFooter }, [
2148
+ h2(
2149
+ "button",
2150
+ {
2151
+ type: "button",
2152
+ style: s2.secondaryBtn,
2153
+ disabled: deleting.value,
2154
+ onClick: closeDeleteDialog
2155
+ },
2156
+ "\u53D6\u6D88"
2157
+ ),
2158
+ h2(
2159
+ "button",
2160
+ {
2161
+ type: "button",
2162
+ style: s2.dangerBtn,
2163
+ disabled: deleting.value,
2164
+ onClick: () => void confirmDelete()
2165
+ },
2166
+ deleting.value ? "\u5220\u9664\u4E2D\u2026" : "\u786E\u8BA4\u5220\u9664"
2167
+ )
2168
+ ])
2169
+ ])
2170
+ ]
2171
+ )
2172
+ ]
2173
+ ) : null
2174
+ ]);
2175
+ }
2176
+ });
1251
2177
  export {
1252
2178
  Can,
2179
+ MENU_LIST_TYPE_PARAM,
2180
+ MENU_TYPE_BUTTON,
2181
+ MENU_TYPE_LABEL,
2182
+ MENU_TYPE_MENU,
2183
+ MENU_TYPE_OPTIONS,
2184
+ MENU_TYPE_PAGE,
2185
+ MENU_VISIBILITY_OPTIONS,
2186
+ MenuManager,
1253
2187
  PERMISSION_STORE_KEY,
1254
2188
  PermissionStore,
1255
2189
  RESOURCE_PRIVATE_OPTIONS,
@@ -1257,12 +2191,16 @@ export {
1257
2191
  RESOURCE_STATUS_ENABLED,
1258
2192
  RESOURCE_STATUS_OPTIONS,
1259
2193
  RESOURCE_TYPE_API,
2194
+ ROOT_PARENT_ID,
1260
2195
  ResourceManager,
1261
2196
  appendQueryParam,
1262
2197
  buildCreateBody,
2198
+ buildCreateMenuBody,
1263
2199
  buildUpdateBody,
2200
+ buildUpdateMenuBody,
1264
2201
  createAuthorizationResourceApi,
1265
2202
  createDefaultResourceRequest,
2203
+ createMenuResourceApi,
1266
2204
  createPermissionPlugin,
1267
2205
  createPermissionStore,
1268
2206
  createVPermission,
@@ -1271,6 +2209,7 @@ export {
1271
2209
  getAppClientId,
1272
2210
  getDeviceWorkerId,
1273
2211
  mapAuthorizationResource,
2212
+ mapMenuResource,
1274
2213
  snowyflake,
1275
2214
  useHasPermission,
1276
2215
  useHasRole,