react-toolkits 2.13.17 → 2.13.19

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.19
4
+
5
+ ### Patch Changes
6
+
7
+ - ca774c6: fix: isGlobal should be true
8
+
9
+ ## 2.13.18
10
+
11
+ ### Patch Changes
12
+
13
+ - c95938f: fix: Skelton not work
14
+
3
15
  ## 2.13.17
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, Skeleton, Form, Spin, Result, Table, Button, Card, Input, Select, theme, Space, Tag, Typography, Alert, Divider, Menu, App, Switch, InputNumber, Row, Col, Breadcrumb, Descriptions, 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';
@@ -1043,12 +1043,9 @@ function useModal(props) {
1043
1043
  const open = isOpen(_id);
1044
1044
  const [confirmLoading, setConfirmLoading] = useState(false);
1045
1045
  const isRenderFunction = typeof content === "function";
1046
- const [loading, setLoading] = useState(false);
1047
1046
  const _show = async () => {
1048
1047
  show(_id);
1049
- setLoading(true);
1050
1048
  await afterOpen?.();
1051
- setLoading(false);
1052
1049
  };
1053
1050
  const _hide = () => {
1054
1051
  hide(_id);
@@ -1065,7 +1062,7 @@ function useModal(props) {
1065
1062
  setConfirmLoading(false);
1066
1063
  }
1067
1064
  };
1068
- const internalModal = /* @__PURE__ */ jsx(Modal, { ...modalProps, open, confirmLoading, onOk, onCancel, children: /* @__PURE__ */ jsx(Skeleton, { loading, children: isRenderFunction ? content({ hide: _hide }) : content }) });
1065
+ const internalModal = /* @__PURE__ */ jsx(Modal, { ...modalProps, open, confirmLoading, onOk, onCancel, children: isRenderFunction ? content({ hide: _hide }) : content });
1069
1066
  return {
1070
1067
  id: _id,
1071
1068
  show: _show,
@@ -1477,118 +1474,122 @@ var init_menuItemList = __esm({
1477
1474
  init_highlight();
1478
1475
  init_locale();
1479
1476
  init_queryList();
1477
+ init_toolkitsProvider();
1480
1478
  init_menu();
1481
1479
  init_hooks4();
1482
1480
  init_hooks2();
1483
- MenuItemList = () => {
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
- ] });
1481
+ MenuItemList = withContext(
1482
+ () => {
1483
+ const { t } = useTranslation();
1484
+ const { message } = App.useApp();
1485
+ const remove = useRemoveMenu();
1486
+ const { refetch } = useQueryListStore();
1487
+ const { mutate: mutate2 } = useMenuList();
1488
+ const navigate = useNavigate();
1489
+ const columns = [
1490
+ {
1491
+ title: "\u83DC\u5355\u540D\u79F0",
1492
+ dataIndex: "category",
1493
+ key: "category"
1494
+ },
1495
+ {
1496
+ title: "\u524D\u7AEF\u8DEF\u7531",
1497
+ dataIndex: "front_route"
1498
+ },
1499
+ {
1500
+ title: "Order",
1501
+ dataIndex: "order"
1502
+ },
1503
+ {
1504
+ title: "Is Common",
1505
+ dataIndex: "is_common",
1506
+ key: "is_common",
1507
+ render: (value) => value ? "\u662F" : "\u5426"
1508
+ },
1509
+ {
1510
+ title: "\u6A21\u677F\u540D\u79F0",
1511
+ dataIndex: "model_name",
1512
+ key: "model_name"
1513
+ },
1514
+ // {
1515
+ // title: '是否预设',
1516
+ // dataIndex: 'is_model',
1517
+ // key: 'is_model',
1518
+ // render: value => (value ? '否' : '是'),
1519
+ // },
1520
+ {
1521
+ title: "\u64CD\u4F5C",
1522
+ key: "action",
1523
+ width: 150,
1524
+ align: "center",
1525
+ render(_, record) {
1526
+ if (record.is_model) {
1527
+ return /* @__PURE__ */ jsxs(Space, { size: "small", children: [
1528
+ /* @__PURE__ */ jsx(
1529
+ Button,
1530
+ {
1531
+ type: "link",
1532
+ onClick: () => {
1533
+ navigate(`./update/${record.id}`);
1534
+ },
1535
+ children: t("global.update")
1536
+ }
1537
+ ),
1538
+ /* @__PURE__ */ jsx(
1539
+ Popconfirm,
1540
+ {
1541
+ title: "\u5220\u9664\u83DC\u5355",
1542
+ placement: "topRight",
1543
+ description: /* @__PURE__ */ jsxs(Highlight_default, { texts: [record.category], children: [
1544
+ "\u786E\u5B9A\u8981\u5220\u9664\u83DC\u5355 ",
1545
+ record.category,
1546
+ " \u5417\uFF1F"
1547
+ ] }),
1548
+ onConfirm: async () => {
1549
+ await remove.trigger(record.id);
1550
+ refetch(url);
1551
+ mutate2();
1552
+ message.success("\u5220\u9664\u6210\u529F");
1553
+ },
1554
+ children: /* @__PURE__ */ jsx(Button, { danger: true, type: "link", size: "small", children: t("global.delete") })
1555
+ }
1556
+ )
1557
+ ] });
1558
+ }
1559
+ return null;
1559
1560
  }
1560
- return null;
1561
1561
  }
1562
- }
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
- };
1562
+ ];
1563
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
1564
+ Card,
1565
+ {
1566
+ title: "\u83DC\u5355\u7BA1\u7406",
1567
+ extra: /* @__PURE__ */ jsx(
1568
+ Button,
1569
+ {
1570
+ type: "primary",
1571
+ onClick: () => {
1572
+ navigate("./create");
1573
+ },
1574
+ children: "\u521B\u5EFA\u83DC\u5355\u9879"
1575
+ }
1576
+ ),
1577
+ children: /* @__PURE__ */ jsx(
1578
+ QueryList_default,
1579
+ {
1580
+ onePage: true,
1581
+ code: "9900001",
1582
+ rowKey: "id",
1583
+ url,
1584
+ columns,
1585
+ getDataSource: (response) => response
1586
+ }
1587
+ )
1588
+ }
1589
+ ) });
1590
+ },
1591
+ { isGlobal: true }
1592
+ );
1592
1593
  menuItemList_default = MenuItemList;
1593
1594
  }
1594
1595
  });
@@ -1601,82 +1602,86 @@ __export(createMenuItem_exports, {
1601
1602
  var CreateMenuItem, createMenuItem_default;
1602
1603
  var init_createMenuItem = __esm({
1603
1604
  "src/pages/menu/createMenuItem/index.tsx"() {
1605
+ init_toolkitsProvider();
1604
1606
  init_constants();
1605
1607
  init_menu();
1606
1608
  init_hooks2();
1607
- CreateMenuItem = () => {
1608
- const { message } = App.useApp();
1609
- const [form] = Form.useForm();
1610
- const navigate = useNavigate();
1611
- const { trigger } = useCreateMenu();
1612
- const { mutate: mutate2 } = useMenuList();
1613
- const onFinish = async (values) => {
1614
- const { permissions, front_route, ...rest } = values;
1615
- await trigger({
1616
- ...rest,
1617
- front_route: FRONTEND_ROUTE_PREFIX + front_route,
1618
- permissions: permissions ? JSON.parse(permissions) : void 0
1619
- });
1620
- mutate2();
1621
- message.success("\u521B\u5EFA\u6210\u529F", 0.8, () => navigate("..", { relative: "route" }));
1622
- };
1623
- return /* @__PURE__ */ jsx(Card, { title: "\u521B\u5EFA\u83DC\u5355\u9879", children: /* @__PURE__ */ jsxs(
1624
- Form,
1625
- {
1626
- scrollToFirstError: true,
1627
- form,
1628
- labelCol: { flex: "120px" },
1629
- initialValues: { is_common: false, is_model: false, order: 0 },
1630
- onFinish,
1631
- children: [
1632
- /* @__PURE__ */ jsx(Form.Item, { label: "\u83DC\u5355\u9879\u540D\u79F0", name: "category", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1633
- /* @__PURE__ */ jsx(Form.Item, { label: "\u524D\u7AEF\u8DEF\u7531", name: "front_route", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, { prefix: FRONTEND_ROUTE_PREFIX }) }),
1634
- /* @__PURE__ */ jsx(Form.Item, { label: "\u6A21\u677F\u540D\u79F0", name: "model_name", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1635
- /* @__PURE__ */ jsx(Form.Item, { label: "Is Common", name: "is_common", rules: [{ required: true }], valuePropName: "checked", children: /* @__PURE__ */ jsx(Switch, {}) }),
1636
- /* @__PURE__ */ jsx(Form.Item, { label: "Order", name: "order", children: /* @__PURE__ */ jsx(InputNumber, { className: "w-full" }) }),
1637
- /* @__PURE__ */ jsx(Form.Item, { label: "\u63A5\u53E3\u89C4\u5219", name: "permissions", children: /* @__PURE__ */ jsx(
1638
- Editor,
1639
- {
1640
- theme: "vs-dark",
1641
- height: "300px",
1642
- language: "json",
1643
- options: {
1644
- minimap: {
1645
- enabled: false
1646
- }
1647
- }
1648
- }
1649
- ) }),
1650
- /* @__PURE__ */ jsx(Form.Item, { label: "Schema", name: "scheme", rules: [{ required: true }], children: /* @__PURE__ */ jsx(
1651
- Editor,
1652
- {
1653
- theme: "vs-dark",
1654
- height: "600px",
1655
- language: "json",
1656
- options: {
1657
- minimap: {
1658
- enabled: false
1609
+ CreateMenuItem = withContext(
1610
+ () => {
1611
+ const { message } = App.useApp();
1612
+ const [form] = Form.useForm();
1613
+ const navigate = useNavigate();
1614
+ const { trigger } = useCreateMenu();
1615
+ const { mutate: mutate2 } = useMenuList();
1616
+ const onFinish = async (values) => {
1617
+ const { permissions, front_route, ...rest } = values;
1618
+ await trigger({
1619
+ ...rest,
1620
+ front_route: FRONTEND_ROUTE_PREFIX + front_route,
1621
+ permissions: permissions ? JSON.parse(permissions) : void 0
1622
+ });
1623
+ mutate2();
1624
+ message.success("\u521B\u5EFA\u6210\u529F", 0.8, () => navigate("..", { relative: "route" }));
1625
+ };
1626
+ return /* @__PURE__ */ jsx(Card, { title: "\u521B\u5EFA\u83DC\u5355\u9879", children: /* @__PURE__ */ jsxs(
1627
+ Form,
1628
+ {
1629
+ scrollToFirstError: true,
1630
+ form,
1631
+ labelCol: { flex: "120px" },
1632
+ initialValues: { is_common: false, is_model: false, order: 0 },
1633
+ onFinish,
1634
+ children: [
1635
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u83DC\u5355\u9879\u540D\u79F0", name: "category", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1636
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u524D\u7AEF\u8DEF\u7531", name: "front_route", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, { prefix: FRONTEND_ROUTE_PREFIX }) }),
1637
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u6A21\u677F\u540D\u79F0", name: "model_name", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1638
+ /* @__PURE__ */ jsx(Form.Item, { label: "Is Common", name: "is_common", rules: [{ required: true }], valuePropName: "checked", children: /* @__PURE__ */ jsx(Switch, {}) }),
1639
+ /* @__PURE__ */ jsx(Form.Item, { label: "Order", name: "order", children: /* @__PURE__ */ jsx(InputNumber, { className: "w-full" }) }),
1640
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u63A5\u53E3\u89C4\u5219", name: "permissions", children: /* @__PURE__ */ jsx(
1641
+ Editor,
1642
+ {
1643
+ theme: "vs-dark",
1644
+ height: "300px",
1645
+ language: "json",
1646
+ options: {
1647
+ minimap: {
1648
+ enabled: false
1649
+ }
1659
1650
  }
1660
1651
  }
1661
- }
1662
- ) }),
1663
- /* @__PURE__ */ jsx(Form.Item, { label: "Ext", name: "ext", children: /* @__PURE__ */ jsx(Input.TextArea, { rows: 5 }) }),
1664
- /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-center gap-8", children: [
1665
- /* @__PURE__ */ jsx(Button, { type: "primary", htmlType: "submit", children: "\u63D0\u4EA4" }),
1666
- /* @__PURE__ */ jsx(
1667
- Button,
1652
+ ) }),
1653
+ /* @__PURE__ */ jsx(Form.Item, { label: "Schema", name: "scheme", rules: [{ required: true }], children: /* @__PURE__ */ jsx(
1654
+ Editor,
1668
1655
  {
1669
- onClick: () => {
1670
- navigate("..", { relative: "path" });
1671
- },
1672
- children: "\u53D6\u6D88"
1656
+ theme: "vs-dark",
1657
+ height: "600px",
1658
+ language: "json",
1659
+ options: {
1660
+ minimap: {
1661
+ enabled: false
1662
+ }
1663
+ }
1673
1664
  }
1674
- )
1675
- ] }) })
1676
- ]
1677
- }
1678
- ) });
1679
- };
1665
+ ) }),
1666
+ /* @__PURE__ */ jsx(Form.Item, { label: "Ext", name: "ext", children: /* @__PURE__ */ jsx(Input.TextArea, { rows: 5 }) }),
1667
+ /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-center gap-8", children: [
1668
+ /* @__PURE__ */ jsx(Button, { type: "primary", htmlType: "submit", children: "\u63D0\u4EA4" }),
1669
+ /* @__PURE__ */ jsx(
1670
+ Button,
1671
+ {
1672
+ onClick: () => {
1673
+ navigate("..", { relative: "path" });
1674
+ },
1675
+ children: "\u53D6\u6D88"
1676
+ }
1677
+ )
1678
+ ] }) })
1679
+ ]
1680
+ }
1681
+ ) });
1682
+ },
1683
+ { isGlobal: true }
1684
+ );
1680
1685
  createMenuItem_default = CreateMenuItem;
1681
1686
  }
1682
1687
  });
@@ -1693,96 +1698,99 @@ var init_updateMenuItem = __esm({
1693
1698
  init_constants();
1694
1699
  init_menu();
1695
1700
  init_hooks2();
1696
- EditMenuItem = () => {
1697
- const { message } = App.useApp();
1698
- const [form] = Form.useForm();
1699
- const navigate = useNavigate();
1700
- const { trigger } = useUpdateMenu();
1701
- const params = useParams();
1702
- const { mutate: mutate2 } = useMenuList();
1703
- const { axios: axios2 } = useToolkitsStore((s) => s);
1704
- const { data, isLoading } = useSWR5(
1705
- `/api/usystem/menu/info?id=${params.id}`,
1706
- (url4) => axios2(url4).then((response) => response.data.data)
1707
- );
1708
- const onFinish = async (values) => {
1709
- const { permissions, front_route, ...rest } = values;
1710
- await trigger({
1711
- ...rest,
1712
- permissions: permissions ? JSON.parse(permissions) : void 0,
1713
- front_route: FRONTEND_ROUTE_PREFIX + front_route,
1714
- id: +params.id
1715
- });
1716
- mutate2();
1717
- message.success("\u66F4\u65B0\u6210\u529F", 0.8, () => navigate("../..", { relative: "route" }));
1718
- };
1719
- useEffect(() => {
1720
- const { permissions, front_route, ...rest } = data ?? {};
1721
- const permissionsString = JSON.stringify(permissions || [], null, 2);
1722
- const frontRoute = front_route?.replace(FRONTEND_ROUTE_PREFIX, "");
1723
- form.setFieldsValue({
1724
- ...rest,
1725
- permissions: permissionsString,
1726
- front_route: frontRoute
1727
- });
1728
- }, [data]);
1729
- return /* @__PURE__ */ jsx(Card, { title: "\u66F4\u65B0\u83DC\u5355\u9879", loading: isLoading, children: /* @__PURE__ */ jsxs(
1730
- Form,
1731
- {
1732
- scrollToFirstError: true,
1733
- form,
1734
- labelCol: { flex: "120px" },
1735
- initialValues: { is_common: false, is_model: false, order: 0 },
1736
- onFinish,
1737
- children: [
1738
- /* @__PURE__ */ jsx(Form.Item, { label: "\u83DC\u5355\u9879\u540D\u79F0", name: "category", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1739
- /* @__PURE__ */ jsx(Form.Item, { label: "\u524D\u7AEF\u8DEF\u7531", name: "front_route", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, { prefix: FRONTEND_ROUTE_PREFIX }) }),
1740
- /* @__PURE__ */ jsx(Form.Item, { label: "\u6A21\u677F\u540D\u79F0", name: "model_name", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1741
- /* @__PURE__ */ jsx(Form.Item, { label: "Is Common", name: "is_common", rules: [{ required: true }], valuePropName: "checked", children: /* @__PURE__ */ jsx(Switch, {}) }),
1742
- /* @__PURE__ */ jsx(Form.Item, { label: "Order", name: "order", children: /* @__PURE__ */ jsx(InputNumber, { className: "w-full" }) }),
1743
- /* @__PURE__ */ jsx(Form.Item, { label: "\u63A5\u53E3\u89C4\u5219", name: "permissions", children: /* @__PURE__ */ jsx(
1744
- Editor,
1745
- {
1746
- theme: "vs-dark",
1747
- height: "300px",
1748
- language: "json",
1749
- options: {
1750
- minimap: {
1751
- enabled: false
1752
- }
1753
- }
1754
- }
1755
- ) }),
1756
- /* @__PURE__ */ jsx(Form.Item, { label: "Schema", name: "scheme", rules: [{ required: true }], children: /* @__PURE__ */ jsx(
1757
- Editor,
1758
- {
1759
- theme: "vs-dark",
1760
- height: "600px",
1761
- language: "json",
1762
- options: {
1763
- minimap: {
1764
- enabled: false
1701
+ EditMenuItem = withContext(
1702
+ () => {
1703
+ const { message } = App.useApp();
1704
+ const [form] = Form.useForm();
1705
+ const navigate = useNavigate();
1706
+ const { trigger } = useUpdateMenu();
1707
+ const params = useParams();
1708
+ const { mutate: mutate2 } = useMenuList();
1709
+ const { axios: axios2 } = useToolkitsStore((s) => s);
1710
+ const { data, isLoading } = useSWR5(
1711
+ `/api/usystem/menu/info?id=${params.id}`,
1712
+ (url4) => axios2(url4).then((response) => response.data.data)
1713
+ );
1714
+ const onFinish = async (values) => {
1715
+ const { permissions, front_route, ...rest } = values;
1716
+ await trigger({
1717
+ ...rest,
1718
+ permissions: permissions ? JSON.parse(permissions) : void 0,
1719
+ front_route: FRONTEND_ROUTE_PREFIX + front_route,
1720
+ id: +params.id
1721
+ });
1722
+ mutate2();
1723
+ message.success("\u66F4\u65B0\u6210\u529F", 0.8, () => navigate("../..", { relative: "route" }));
1724
+ };
1725
+ useEffect(() => {
1726
+ const { permissions, front_route, ...rest } = data ?? {};
1727
+ const permissionsString = JSON.stringify(permissions || [], null, 2);
1728
+ const frontRoute = front_route?.replace(FRONTEND_ROUTE_PREFIX, "");
1729
+ form.setFieldsValue({
1730
+ ...rest,
1731
+ permissions: permissionsString,
1732
+ front_route: frontRoute
1733
+ });
1734
+ }, [data]);
1735
+ return /* @__PURE__ */ jsx(Card, { title: "\u66F4\u65B0\u83DC\u5355\u9879", loading: isLoading, children: /* @__PURE__ */ jsxs(
1736
+ Form,
1737
+ {
1738
+ scrollToFirstError: true,
1739
+ form,
1740
+ labelCol: { flex: "120px" },
1741
+ initialValues: { is_common: false, is_model: false, order: 0 },
1742
+ onFinish,
1743
+ children: [
1744
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u83DC\u5355\u9879\u540D\u79F0", name: "category", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1745
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u524D\u7AEF\u8DEF\u7531", name: "front_route", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, { prefix: FRONTEND_ROUTE_PREFIX }) }),
1746
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u6A21\u677F\u540D\u79F0", name: "model_name", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, {}) }),
1747
+ /* @__PURE__ */ jsx(Form.Item, { label: "Is Common", name: "is_common", rules: [{ required: true }], valuePropName: "checked", children: /* @__PURE__ */ jsx(Switch, {}) }),
1748
+ /* @__PURE__ */ jsx(Form.Item, { label: "Order", name: "order", children: /* @__PURE__ */ jsx(InputNumber, { className: "w-full" }) }),
1749
+ /* @__PURE__ */ jsx(Form.Item, { label: "\u63A5\u53E3\u89C4\u5219", name: "permissions", children: /* @__PURE__ */ jsx(
1750
+ Editor,
1751
+ {
1752
+ theme: "vs-dark",
1753
+ height: "300px",
1754
+ language: "json",
1755
+ options: {
1756
+ minimap: {
1757
+ enabled: false
1758
+ }
1765
1759
  }
1766
1760
  }
1767
- }
1768
- ) }),
1769
- /* @__PURE__ */ jsx(Form.Item, { label: "Ext", name: "ext", children: /* @__PURE__ */ jsx(Input.TextArea, { rows: 5 }) }),
1770
- /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-center gap-8", children: [
1771
- /* @__PURE__ */ jsx(Button, { type: "primary", htmlType: "submit", children: "\u63D0\u4EA4" }),
1772
- /* @__PURE__ */ jsx(
1773
- Button,
1761
+ ) }),
1762
+ /* @__PURE__ */ jsx(Form.Item, { label: "Schema", name: "scheme", rules: [{ required: true }], children: /* @__PURE__ */ jsx(
1763
+ Editor,
1774
1764
  {
1775
- onClick: () => {
1776
- navigate("../..", { relative: "path" });
1777
- },
1778
- children: "\u53D6\u6D88"
1765
+ theme: "vs-dark",
1766
+ height: "600px",
1767
+ language: "json",
1768
+ options: {
1769
+ minimap: {
1770
+ enabled: false
1771
+ }
1772
+ }
1779
1773
  }
1780
- )
1781
- ] }) })
1782
- ]
1783
- }
1784
- ) });
1785
- };
1774
+ ) }),
1775
+ /* @__PURE__ */ jsx(Form.Item, { label: "Ext", name: "ext", children: /* @__PURE__ */ jsx(Input.TextArea, { rows: 5 }) }),
1776
+ /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-center gap-8", children: [
1777
+ /* @__PURE__ */ jsx(Button, { type: "primary", htmlType: "submit", children: "\u63D0\u4EA4" }),
1778
+ /* @__PURE__ */ jsx(
1779
+ Button,
1780
+ {
1781
+ onClick: () => {
1782
+ navigate("../..", { relative: "path" });
1783
+ },
1784
+ children: "\u53D6\u6D88"
1785
+ }
1786
+ )
1787
+ ] }) })
1788
+ ]
1789
+ }
1790
+ ) });
1791
+ },
1792
+ { isGlobal: true }
1793
+ );
1786
1794
  updateMenuItem_default = EditMenuItem;
1787
1795
  }
1788
1796
  });