react-toolkits 2.13.18 → 2.13.20

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # react-toolkits
2
2
 
3
+ ## 2.13.20
4
+
5
+ ### Patch Changes
6
+
7
+ - 4e7f741: fix: menu list app-id header should not be global
8
+
9
+ ## 2.13.19
10
+
11
+ ### Patch Changes
12
+
13
+ - ca774c6: fix: isGlobal should be true
14
+
3
15
  ## 2.13.18
4
16
 
5
17
  ### Patch Changes
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@ import { jwtDecode } from 'jwt-decode';
3
3
  import { useStore, create, createStore } from 'zustand';
4
4
  import { persist, createJSONStorage } from 'zustand/middleware';
5
5
  import * as Antd2 from 'antd';
6
- import { Modal, Form, Spin, Result, Table, Button, Card, Input, Select, theme, Space, Tag, Typography, Alert, Divider, Menu, App, Switch, InputNumber, Row, Col, Breadcrumb, Descriptions, Skeleton, Empty, Dropdown, Tooltip, Popconfirm, Collapse, Checkbox } from 'antd';
6
+ import { Modal, Form, Spin, Result, Table, Button, Card, Input, Select, App, Switch, InputNumber, theme, Space, Tag, Typography, Alert, Divider, Menu, Popconfirm, Row, Col, Breadcrumb, Descriptions, Skeleton, Empty, Dropdown, Tooltip, Collapse, Checkbox } from 'antd';
7
7
  import { forwardRef, lazy, useContext, useMemo, useState, useEffect, useImperativeHandle, cloneElement, useRef, createContext, memo, useCallback, Fragment as Fragment$1, Suspense } from 'react';
8
8
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
9
  import { last, has, template, get, isEqual, first } from 'lodash-es';
@@ -11,7 +11,7 @@ import { flushSync } from 'react-dom';
11
11
  import { createRoot } from 'react-dom/client';
12
12
  import useSWR5, { mutate, unstable_serialize } from 'swr';
13
13
  import logoUrl from './logo-L6MFCL6M.png';
14
- import { Routes, Route, Navigate, useNavigate, useLocation, useParams, Link } from 'react-router-dom';
14
+ import { Routes, Route, Navigate, useNavigate, useParams, useLocation, Link } from 'react-router-dom';
15
15
  import { PlusOutlined, UserAddOutlined, UsergroupAddOutlined, LogoutOutlined, UserOutlined, MenuUnfoldOutlined, MenuFoldOutlined, MinusCircleOutlined } from '@ant-design/icons';
16
16
  import useSWRMutation2 from 'swr/mutation';
17
17
  import { Editor } from '@monaco-editor/react';
@@ -520,14 +520,15 @@ var init_highlight = __esm({
520
520
  function useMenuList() {
521
521
  const { signInPath, axios: axios2, gameId } = useToolkitsStore((s) => s);
522
522
  return useSWR5(
523
- window.location.pathname !== signInPath ? ["/api/usystem/menu/navbar", gameId] : null,
524
- ([url4]) => axios2(url4).then((response) => response.data.data)
523
+ window.location.pathname !== signInPath ? { url: "/api/usystem/menu/navbar", headers: { [APP_ID_HEADER]: gameId } } : null,
524
+ ({ url: url4, headers }) => axios2(url4, { headers }).then((response) => response.data.data)
525
525
  );
526
526
  }
527
527
  var usePermissions, usePermission;
528
528
  var init_hooks2 = __esm({
529
529
  "src/hooks/index.ts"() {
530
530
  init_toolkitsProvider();
531
+ init_constants();
531
532
  usePermissions = (codes = [], config) => {
532
533
  const { axios: axios2, permissionVersion } = useToolkitsStore((s) => s);
533
534
  const { data, ...rest } = useSWR5(
@@ -1474,118 +1475,122 @@ var init_menuItemList = __esm({
1474
1475
  init_highlight();
1475
1476
  init_locale();
1476
1477
  init_queryList();
1478
+ init_toolkitsProvider();
1477
1479
  init_menu();
1478
1480
  init_hooks4();
1479
1481
  init_hooks2();
1480
- MenuItemList = () => {
1481
- const { t } = useTranslation();
1482
- const { message } = App.useApp();
1483
- const remove = useRemoveMenu();
1484
- const { refetch } = useQueryListStore();
1485
- const { mutate: mutate2 } = useMenuList();
1486
- const navigate = useNavigate();
1487
- const columns = [
1488
- {
1489
- title: "\u83DC\u5355\u540D\u79F0",
1490
- dataIndex: "category",
1491
- key: "category"
1492
- },
1493
- {
1494
- title: "\u524D\u7AEF\u8DEF\u7531",
1495
- dataIndex: "front_route"
1496
- },
1497
- {
1498
- title: "Order",
1499
- dataIndex: "order"
1500
- },
1501
- {
1502
- title: "Is Common",
1503
- dataIndex: "is_common",
1504
- key: "is_common",
1505
- render: (value) => value ? "\u662F" : "\u5426"
1506
- },
1507
- {
1508
- title: "\u6A21\u677F\u540D\u79F0",
1509
- dataIndex: "model_name",
1510
- key: "model_name"
1511
- },
1512
- // {
1513
- // title: '是否预设',
1514
- // dataIndex: 'is_model',
1515
- // key: 'is_model',
1516
- // render: value => (value ? '' : '是'),
1517
- // },
1518
- {
1519
- title: "\u64CD\u4F5C",
1520
- key: "action",
1521
- width: 150,
1522
- align: "center",
1523
- render(_, record) {
1524
- if (record.is_model) {
1525
- return /* @__PURE__ */ jsxs(Space, { size: "small", children: [
1526
- /* @__PURE__ */ jsx(
1527
- Button,
1528
- {
1529
- type: "link",
1530
- onClick: () => {
1531
- navigate(`./update/${record.id}`);
1532
- },
1533
- children: t("global.update")
1534
- }
1535
- ),
1536
- /* @__PURE__ */ jsx(
1537
- Popconfirm,
1538
- {
1539
- title: "\u5220\u9664\u83DC\u5355",
1540
- placement: "topRight",
1541
- description: /* @__PURE__ */ jsxs(Highlight_default, { texts: [record.category], children: [
1542
- "\u786E\u5B9A\u8981\u5220\u9664\u83DC\u5355 ",
1543
- record.category,
1544
- " \u5417\uFF1F"
1545
- ] }),
1546
- onConfirm: async () => {
1547
- await remove.trigger(record.id);
1548
- refetch(url);
1549
- mutate2();
1550
- message.success("\u5220\u9664\u6210\u529F");
1551
- },
1552
- children: /* @__PURE__ */ jsx(Button, { danger: true, type: "link", size: "small", children: t("global.delete") })
1553
- }
1554
- )
1555
- ] });
1482
+ MenuItemList = withContext(
1483
+ () => {
1484
+ const { t } = useTranslation();
1485
+ const { message } = App.useApp();
1486
+ const remove = useRemoveMenu();
1487
+ const { refetch } = useQueryListStore();
1488
+ const { mutate: mutate2 } = useMenuList();
1489
+ const navigate = useNavigate();
1490
+ const columns = [
1491
+ {
1492
+ title: "\u83DC\u5355\u540D\u79F0",
1493
+ dataIndex: "category",
1494
+ key: "category"
1495
+ },
1496
+ {
1497
+ title: "\u524D\u7AEF\u8DEF\u7531",
1498
+ dataIndex: "front_route"
1499
+ },
1500
+ {
1501
+ title: "Order",
1502
+ dataIndex: "order"
1503
+ },
1504
+ {
1505
+ title: "Is Common",
1506
+ dataIndex: "is_common",
1507
+ key: "is_common",
1508
+ render: (value) => value ? "\u662F" : "\u5426"
1509
+ },
1510
+ {
1511
+ title: "\u6A21\u677F\u540D\u79F0",
1512
+ dataIndex: "model_name",
1513
+ key: "model_name"
1514
+ },
1515
+ // {
1516
+ // title: '是否预设',
1517
+ // dataIndex: 'is_model',
1518
+ // key: 'is_model',
1519
+ // render: value => (value ? '否' : '是'),
1520
+ // },
1521
+ {
1522
+ title: "\u64CD\u4F5C",
1523
+ key: "action",
1524
+ width: 150,
1525
+ align: "center",
1526
+ render(_, record) {
1527
+ if (record.is_model) {
1528
+ return /* @__PURE__ */ jsxs(Space, { size: "small", children: [
1529
+ /* @__PURE__ */ jsx(
1530
+ Button,
1531
+ {
1532
+ type: "link",
1533
+ onClick: () => {
1534
+ navigate(`./update/${record.id}`);
1535
+ },
1536
+ children: t("global.update")
1537
+ }
1538
+ ),
1539
+ /* @__PURE__ */ jsx(
1540
+ Popconfirm,
1541
+ {
1542
+ title: "\u5220\u9664\u83DC\u5355",
1543
+ placement: "topRight",
1544
+ description: /* @__PURE__ */ jsxs(Highlight_default, { texts: [record.category], children: [
1545
+ "\u786E\u5B9A\u8981\u5220\u9664\u83DC\u5355 ",
1546
+ record.category,
1547
+ " \u5417\uFF1F"
1548
+ ] }),
1549
+ onConfirm: async () => {
1550
+ await remove.trigger(record.id);
1551
+ refetch(url);
1552
+ mutate2();
1553
+ message.success("\u5220\u9664\u6210\u529F");
1554
+ },
1555
+ children: /* @__PURE__ */ jsx(Button, { danger: true, type: "link", size: "small", children: t("global.delete") })
1556
+ }
1557
+ )
1558
+ ] });
1559
+ }
1560
+ return null;
1556
1561
  }
1557
- return null;
1558
1562
  }
1559
- }
1560
- ];
1561
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
1562
- Card,
1563
- {
1564
- title: "\u83DC\u5355\u7BA1\u7406",
1565
- extra: /* @__PURE__ */ jsx(
1566
- Button,
1567
- {
1568
- type: "primary",
1569
- onClick: () => {
1570
- navigate("./create");
1571
- },
1572
- children: "\u521B\u5EFA\u83DC\u5355\u9879"
1573
- }
1574
- ),
1575
- children: /* @__PURE__ */ jsx(
1576
- QueryList_default,
1577
- {
1578
- onePage: true,
1579
- code: "9900001",
1580
- rowKey: "id",
1581
- url,
1582
- columns,
1583
- getDataSource: (response) => response
1584
- }
1585
- )
1586
- }
1587
- ) });
1588
- };
1563
+ ];
1564
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
1565
+ Card,
1566
+ {
1567
+ title: "\u83DC\u5355\u7BA1\u7406",
1568
+ extra: /* @__PURE__ */ jsx(
1569
+ Button,
1570
+ {
1571
+ type: "primary",
1572
+ onClick: () => {
1573
+ navigate("./create");
1574
+ },
1575
+ children: "\u521B\u5EFA\u83DC\u5355\u9879"
1576
+ }
1577
+ ),
1578
+ children: /* @__PURE__ */ jsx(
1579
+ QueryList_default,
1580
+ {
1581
+ onePage: true,
1582
+ code: "9900001",
1583
+ rowKey: "id",
1584
+ url,
1585
+ columns,
1586
+ getDataSource: (response) => response
1587
+ }
1588
+ )
1589
+ }
1590
+ ) });
1591
+ },
1592
+ { isGlobal: true }
1593
+ );
1589
1594
  menuItemList_default = MenuItemList;
1590
1595
  }
1591
1596
  });
@@ -1598,82 +1603,86 @@ __export(createMenuItem_exports, {
1598
1603
  var CreateMenuItem, createMenuItem_default;
1599
1604
  var init_createMenuItem = __esm({
1600
1605
  "src/pages/menu/createMenuItem/index.tsx"() {
1606
+ init_toolkitsProvider();
1601
1607
  init_constants();
1602
1608
  init_menu();
1603
1609
  init_hooks2();
1604
- CreateMenuItem = () => {
1605
- const { message } = App.useApp();
1606
- const [form] = Form.useForm();
1607
- const navigate = useNavigate();
1608
- const { trigger } = useCreateMenu();
1609
- const { mutate: mutate2 } = useMenuList();
1610
- const onFinish = async (values) => {
1611
- const { permissions, front_route, ...rest } = values;
1612
- await trigger({
1613
- ...rest,
1614
- front_route: FRONTEND_ROUTE_PREFIX + front_route,
1615
- permissions: permissions ? JSON.parse(permissions) : void 0
1616
- });
1617
- mutate2();
1618
- message.success("\u521B\u5EFA\u6210\u529F", 0.8, () => navigate("..", { relative: "route" }));
1619
- };
1620
- return /* @__PURE__ */ jsx(Card, { title: "\u521B\u5EFA\u83DC\u5355\u9879", children: /* @__PURE__ */ jsxs(
1621
- Form,
1622
- {
1623
- scrollToFirstError: true,
1624
- form,
1625
- labelCol: { flex: "120px" },
1626
- initialValues: { is_common: false, is_model: false, order: 0 },
1627
- onFinish,
1628
- children: [
1629
- /* @__PURE__ */ jsx(Form.Item, { label: "\u83DC\u5355\u9879\u540D\u79F0", name: "category", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1630
- /* @__PURE__ */ jsx(Form.Item, { label: "\u524D\u7AEF\u8DEF\u7531", name: "front_route", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, { prefix: FRONTEND_ROUTE_PREFIX }) }),
1631
- /* @__PURE__ */ jsx(Form.Item, { label: "\u6A21\u677F\u540D\u79F0", name: "model_name", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1632
- /* @__PURE__ */ jsx(Form.Item, { label: "Is Common", name: "is_common", rules: [{ required: true }], valuePropName: "checked", children: /* @__PURE__ */ jsx(Switch, {}) }),
1633
- /* @__PURE__ */ jsx(Form.Item, { label: "Order", name: "order", children: /* @__PURE__ */ jsx(InputNumber, { className: "w-full" }) }),
1634
- /* @__PURE__ */ jsx(Form.Item, { label: "\u63A5\u53E3\u89C4\u5219", name: "permissions", children: /* @__PURE__ */ jsx(
1635
- Editor,
1636
- {
1637
- theme: "vs-dark",
1638
- height: "300px",
1639
- language: "json",
1640
- options: {
1641
- minimap: {
1642
- enabled: false
1643
- }
1644
- }
1645
- }
1646
- ) }),
1647
- /* @__PURE__ */ jsx(Form.Item, { label: "Schema", name: "scheme", rules: [{ required: true }], children: /* @__PURE__ */ jsx(
1648
- Editor,
1649
- {
1650
- theme: "vs-dark",
1651
- height: "600px",
1652
- language: "json",
1653
- options: {
1654
- minimap: {
1655
- enabled: false
1610
+ CreateMenuItem = withContext(
1611
+ () => {
1612
+ const { message } = App.useApp();
1613
+ const [form] = Form.useForm();
1614
+ const navigate = useNavigate();
1615
+ const { trigger } = useCreateMenu();
1616
+ const { mutate: mutate2 } = useMenuList();
1617
+ const onFinish = async (values) => {
1618
+ const { permissions, front_route, ...rest } = values;
1619
+ await trigger({
1620
+ ...rest,
1621
+ front_route: FRONTEND_ROUTE_PREFIX + front_route,
1622
+ permissions: permissions ? JSON.parse(permissions) : void 0
1623
+ });
1624
+ mutate2();
1625
+ message.success("\u521B\u5EFA\u6210\u529F", 0.8, () => navigate("..", { relative: "route" }));
1626
+ };
1627
+ return /* @__PURE__ */ jsx(Card, { title: "\u521B\u5EFA\u83DC\u5355\u9879", children: /* @__PURE__ */ jsxs(
1628
+ Form,
1629
+ {
1630
+ scrollToFirstError: true,
1631
+ form,
1632
+ labelCol: { flex: "120px" },
1633
+ initialValues: { is_common: false, is_model: false, order: 0 },
1634
+ onFinish,
1635
+ children: [
1636
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u83DC\u5355\u9879\u540D\u79F0", name: "category", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1637
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u524D\u7AEF\u8DEF\u7531", name: "front_route", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, { prefix: FRONTEND_ROUTE_PREFIX }) }),
1638
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u6A21\u677F\u540D\u79F0", name: "model_name", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1639
+ /* @__PURE__ */ jsx(Form.Item, { label: "Is Common", name: "is_common", rules: [{ required: true }], valuePropName: "checked", children: /* @__PURE__ */ jsx(Switch, {}) }),
1640
+ /* @__PURE__ */ jsx(Form.Item, { label: "Order", name: "order", children: /* @__PURE__ */ jsx(InputNumber, { className: "w-full" }) }),
1641
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u63A5\u53E3\u89C4\u5219", name: "permissions", children: /* @__PURE__ */ jsx(
1642
+ Editor,
1643
+ {
1644
+ theme: "vs-dark",
1645
+ height: "300px",
1646
+ language: "json",
1647
+ options: {
1648
+ minimap: {
1649
+ enabled: false
1650
+ }
1656
1651
  }
1657
1652
  }
1658
- }
1659
- ) }),
1660
- /* @__PURE__ */ jsx(Form.Item, { label: "Ext", name: "ext", children: /* @__PURE__ */ jsx(Input.TextArea, { rows: 5 }) }),
1661
- /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-center gap-8", children: [
1662
- /* @__PURE__ */ jsx(Button, { type: "primary", htmlType: "submit", children: "\u63D0\u4EA4" }),
1663
- /* @__PURE__ */ jsx(
1664
- Button,
1653
+ ) }),
1654
+ /* @__PURE__ */ jsx(Form.Item, { label: "Schema", name: "scheme", rules: [{ required: true }], children: /* @__PURE__ */ jsx(
1655
+ Editor,
1665
1656
  {
1666
- onClick: () => {
1667
- navigate("..", { relative: "path" });
1668
- },
1669
- children: "\u53D6\u6D88"
1657
+ theme: "vs-dark",
1658
+ height: "600px",
1659
+ language: "json",
1660
+ options: {
1661
+ minimap: {
1662
+ enabled: false
1663
+ }
1664
+ }
1670
1665
  }
1671
- )
1672
- ] }) })
1673
- ]
1674
- }
1675
- ) });
1676
- };
1666
+ ) }),
1667
+ /* @__PURE__ */ jsx(Form.Item, { label: "Ext", name: "ext", children: /* @__PURE__ */ jsx(Input.TextArea, { rows: 5 }) }),
1668
+ /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-center gap-8", children: [
1669
+ /* @__PURE__ */ jsx(Button, { type: "primary", htmlType: "submit", children: "\u63D0\u4EA4" }),
1670
+ /* @__PURE__ */ jsx(
1671
+ Button,
1672
+ {
1673
+ onClick: () => {
1674
+ navigate("..", { relative: "path" });
1675
+ },
1676
+ children: "\u53D6\u6D88"
1677
+ }
1678
+ )
1679
+ ] }) })
1680
+ ]
1681
+ }
1682
+ ) });
1683
+ },
1684
+ { isGlobal: true }
1685
+ );
1677
1686
  createMenuItem_default = CreateMenuItem;
1678
1687
  }
1679
1688
  });
@@ -1690,96 +1699,99 @@ var init_updateMenuItem = __esm({
1690
1699
  init_constants();
1691
1700
  init_menu();
1692
1701
  init_hooks2();
1693
- EditMenuItem = () => {
1694
- const { message } = App.useApp();
1695
- const [form] = Form.useForm();
1696
- const navigate = useNavigate();
1697
- const { trigger } = useUpdateMenu();
1698
- const params = useParams();
1699
- const { mutate: mutate2 } = useMenuList();
1700
- const { axios: axios2 } = useToolkitsStore((s) => s);
1701
- const { data, isLoading } = useSWR5(
1702
- `/api/usystem/menu/info?id=${params.id}`,
1703
- (url4) => axios2(url4).then((response) => response.data.data)
1704
- );
1705
- const onFinish = async (values) => {
1706
- const { permissions, front_route, ...rest } = values;
1707
- await trigger({
1708
- ...rest,
1709
- permissions: permissions ? JSON.parse(permissions) : void 0,
1710
- front_route: FRONTEND_ROUTE_PREFIX + front_route,
1711
- id: +params.id
1712
- });
1713
- mutate2();
1714
- message.success("\u66F4\u65B0\u6210\u529F", 0.8, () => navigate("../..", { relative: "route" }));
1715
- };
1716
- useEffect(() => {
1717
- const { permissions, front_route, ...rest } = data ?? {};
1718
- const permissionsString = JSON.stringify(permissions || [], null, 2);
1719
- const frontRoute = front_route?.replace(FRONTEND_ROUTE_PREFIX, "");
1720
- form.setFieldsValue({
1721
- ...rest,
1722
- permissions: permissionsString,
1723
- front_route: frontRoute
1724
- });
1725
- }, [data]);
1726
- return /* @__PURE__ */ jsx(Card, { title: "\u66F4\u65B0\u83DC\u5355\u9879", loading: isLoading, children: /* @__PURE__ */ jsxs(
1727
- Form,
1728
- {
1729
- scrollToFirstError: true,
1730
- form,
1731
- labelCol: { flex: "120px" },
1732
- initialValues: { is_common: false, is_model: false, order: 0 },
1733
- onFinish,
1734
- children: [
1735
- /* @__PURE__ */ jsx(Form.Item, { label: "\u83DC\u5355\u9879\u540D\u79F0", name: "category", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1736
- /* @__PURE__ */ jsx(Form.Item, { label: "\u524D\u7AEF\u8DEF\u7531", name: "front_route", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, { prefix: FRONTEND_ROUTE_PREFIX }) }),
1737
- /* @__PURE__ */ jsx(Form.Item, { label: "\u6A21\u677F\u540D\u79F0", name: "model_name", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1738
- /* @__PURE__ */ jsx(Form.Item, { label: "Is Common", name: "is_common", rules: [{ required: true }], valuePropName: "checked", children: /* @__PURE__ */ jsx(Switch, {}) }),
1739
- /* @__PURE__ */ jsx(Form.Item, { label: "Order", name: "order", children: /* @__PURE__ */ jsx(InputNumber, { className: "w-full" }) }),
1740
- /* @__PURE__ */ jsx(Form.Item, { label: "\u63A5\u53E3\u89C4\u5219", name: "permissions", children: /* @__PURE__ */ jsx(
1741
- Editor,
1742
- {
1743
- theme: "vs-dark",
1744
- height: "300px",
1745
- language: "json",
1746
- options: {
1747
- minimap: {
1748
- enabled: false
1749
- }
1750
- }
1751
- }
1752
- ) }),
1753
- /* @__PURE__ */ jsx(Form.Item, { label: "Schema", name: "scheme", rules: [{ required: true }], children: /* @__PURE__ */ jsx(
1754
- Editor,
1755
- {
1756
- theme: "vs-dark",
1757
- height: "600px",
1758
- language: "json",
1759
- options: {
1760
- minimap: {
1761
- enabled: false
1702
+ EditMenuItem = withContext(
1703
+ () => {
1704
+ const { message } = App.useApp();
1705
+ const [form] = Form.useForm();
1706
+ const navigate = useNavigate();
1707
+ const { trigger } = useUpdateMenu();
1708
+ const params = useParams();
1709
+ const { mutate: mutate2 } = useMenuList();
1710
+ const { axios: axios2 } = useToolkitsStore((s) => s);
1711
+ const { data, isLoading } = useSWR5(
1712
+ `/api/usystem/menu/info?id=${params.id}`,
1713
+ (url4) => axios2(url4).then((response) => response.data.data)
1714
+ );
1715
+ const onFinish = async (values) => {
1716
+ const { permissions, front_route, ...rest } = values;
1717
+ await trigger({
1718
+ ...rest,
1719
+ permissions: permissions ? JSON.parse(permissions) : void 0,
1720
+ front_route: FRONTEND_ROUTE_PREFIX + front_route,
1721
+ id: +params.id
1722
+ });
1723
+ mutate2();
1724
+ message.success("\u66F4\u65B0\u6210\u529F", 0.8, () => navigate("../..", { relative: "route" }));
1725
+ };
1726
+ useEffect(() => {
1727
+ const { permissions, front_route, ...rest } = data ?? {};
1728
+ const permissionsString = JSON.stringify(permissions || [], null, 2);
1729
+ const frontRoute = front_route?.replace(FRONTEND_ROUTE_PREFIX, "");
1730
+ form.setFieldsValue({
1731
+ ...rest,
1732
+ permissions: permissionsString,
1733
+ front_route: frontRoute
1734
+ });
1735
+ }, [data]);
1736
+ return /* @__PURE__ */ jsx(Card, { title: "\u66F4\u65B0\u83DC\u5355\u9879", loading: isLoading, children: /* @__PURE__ */ jsxs(
1737
+ Form,
1738
+ {
1739
+ scrollToFirstError: true,
1740
+ form,
1741
+ labelCol: { flex: "120px" },
1742
+ initialValues: { is_common: false, is_model: false, order: 0 },
1743
+ onFinish,
1744
+ children: [
1745
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u83DC\u5355\u9879\u540D\u79F0", name: "category", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1746
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u524D\u7AEF\u8DEF\u7531", name: "front_route", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, { prefix: FRONTEND_ROUTE_PREFIX }) }),
1747
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u6A21\u677F\u540D\u79F0", name: "model_name", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1748
+ /* @__PURE__ */ jsx(Form.Item, { label: "Is Common", name: "is_common", rules: [{ required: true }], valuePropName: "checked", children: /* @__PURE__ */ jsx(Switch, {}) }),
1749
+ /* @__PURE__ */ jsx(Form.Item, { label: "Order", name: "order", children: /* @__PURE__ */ jsx(InputNumber, { className: "w-full" }) }),
1750
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u63A5\u53E3\u89C4\u5219", name: "permissions", children: /* @__PURE__ */ jsx(
1751
+ Editor,
1752
+ {
1753
+ theme: "vs-dark",
1754
+ height: "300px",
1755
+ language: "json",
1756
+ options: {
1757
+ minimap: {
1758
+ enabled: false
1759
+ }
1762
1760
  }
1763
1761
  }
1764
- }
1765
- ) }),
1766
- /* @__PURE__ */ jsx(Form.Item, { label: "Ext", name: "ext", children: /* @__PURE__ */ jsx(Input.TextArea, { rows: 5 }) }),
1767
- /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-center gap-8", children: [
1768
- /* @__PURE__ */ jsx(Button, { type: "primary", htmlType: "submit", children: "\u63D0\u4EA4" }),
1769
- /* @__PURE__ */ jsx(
1770
- Button,
1762
+ ) }),
1763
+ /* @__PURE__ */ jsx(Form.Item, { label: "Schema", name: "scheme", rules: [{ required: true }], children: /* @__PURE__ */ jsx(
1764
+ Editor,
1771
1765
  {
1772
- onClick: () => {
1773
- navigate("../..", { relative: "path" });
1774
- },
1775
- children: "\u53D6\u6D88"
1766
+ theme: "vs-dark",
1767
+ height: "600px",
1768
+ language: "json",
1769
+ options: {
1770
+ minimap: {
1771
+ enabled: false
1772
+ }
1773
+ }
1776
1774
  }
1777
- )
1778
- ] }) })
1779
- ]
1780
- }
1781
- ) });
1782
- };
1775
+ ) }),
1776
+ /* @__PURE__ */ jsx(Form.Item, { label: "Ext", name: "ext", children: /* @__PURE__ */ jsx(Input.TextArea, { rows: 5 }) }),
1777
+ /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-center gap-8", children: [
1778
+ /* @__PURE__ */ jsx(Button, { type: "primary", htmlType: "submit", children: "\u63D0\u4EA4" }),
1779
+ /* @__PURE__ */ jsx(
1780
+ Button,
1781
+ {
1782
+ onClick: () => {
1783
+ navigate("../..", { relative: "path" });
1784
+ },
1785
+ children: "\u53D6\u6D88"
1786
+ }
1787
+ )
1788
+ ] }) })
1789
+ ]
1790
+ }
1791
+ ) });
1792
+ },
1793
+ { isGlobal: true }
1794
+ );
1783
1795
  updateMenuItem_default = EditMenuItem;
1784
1796
  }
1785
1797
  });