sidebar.tsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. import React, { useEffect, useRef, useMemo, useState, Fragment } from "react";
  2. import styles from "./home.module.scss";
  3. import DragIcon from "../icons/drag.svg";
  4. import faviconSrc from "../icons/favicon.png";
  5. import deepSeekSrc from "../icons/deepSeek.png";
  6. import { AppstoreOutlined, EditOutlined, MenuOutlined } from '@ant-design/icons';
  7. import { useAppConfig, useChatStore, useGlobalStore } from "../store";
  8. import {
  9. DEFAULT_SIDEBAR_WIDTH,
  10. MAX_SIDEBAR_WIDTH,
  11. MIN_SIDEBAR_WIDTH,
  12. NARROW_SIDEBAR_WIDTH,
  13. } from "../constant";
  14. import { useLocation, useNavigate } from "react-router-dom";
  15. import { isIOS, useMobileScreen } from "../utils";
  16. import api from "@/app/api/api";
  17. import { Button, Drawer, Dropdown, Empty, Form, Input, Menu, message, Modal, Rate, Tag } from "antd";
  18. import { downloadFile } from "../utils/index";
  19. import dayjs from "dayjs";
  20. const FormItem = Form.Item;
  21. export function useHotKey() {
  22. const chatStore = useChatStore();
  23. useEffect(() => {
  24. const onKeyDown = (e: KeyboardEvent) => {
  25. if (e.altKey || e.ctrlKey) {
  26. if (e.key === "ArrowUp") {
  27. chatStore.nextSession(-1);
  28. } else if (e.key === "ArrowDown") {
  29. chatStore.nextSession(1);
  30. }
  31. }
  32. };
  33. window.addEventListener("keydown", onKeyDown);
  34. return () => window.removeEventListener("keydown", onKeyDown);
  35. });
  36. }
  37. export function useDragSideBar() {
  38. const limit = (x: number) => Math.min(MAX_SIDEBAR_WIDTH, x);
  39. const config = useAppConfig();
  40. const startX = useRef(0);
  41. const startDragWidth = useRef(config.sidebarWidth ?? DEFAULT_SIDEBAR_WIDTH);
  42. const lastUpdateTime = useRef(Date.now());
  43. const toggleSideBar = () => {
  44. config.update((config) => {
  45. if (config.sidebarWidth < MIN_SIDEBAR_WIDTH) {
  46. config.sidebarWidth = DEFAULT_SIDEBAR_WIDTH;
  47. } else {
  48. config.sidebarWidth = NARROW_SIDEBAR_WIDTH;
  49. }
  50. });
  51. };
  52. const onDragStart = (e: MouseEvent) => {
  53. // Remembers the initial width each time the mouse is pressed
  54. startX.current = e.clientX;
  55. startDragWidth.current = config.sidebarWidth;
  56. const dragStartTime = Date.now();
  57. const handleDragMove = (e: MouseEvent) => {
  58. if (Date.now() < lastUpdateTime.current + 20) {
  59. return;
  60. }
  61. lastUpdateTime.current = Date.now();
  62. const d = e.clientX - startX.current;
  63. const nextWidth = limit(startDragWidth.current + d);
  64. config.update((config) => {
  65. if (nextWidth < MIN_SIDEBAR_WIDTH) {
  66. config.sidebarWidth = NARROW_SIDEBAR_WIDTH;
  67. } else {
  68. config.sidebarWidth = nextWidth;
  69. }
  70. });
  71. };
  72. const handleDragEnd = () => {
  73. // In useRef the data is non-responsive, so `config.sidebarWidth` can't get the dynamic sidebarWidth
  74. window.removeEventListener("pointermove", handleDragMove);
  75. window.removeEventListener("pointerup", handleDragEnd);
  76. // if user click the drag icon, should toggle the sidebar
  77. const shouldFireClick = Date.now() - dragStartTime < 300;
  78. if (shouldFireClick) {
  79. toggleSideBar();
  80. }
  81. };
  82. window.addEventListener("pointermove", handleDragMove);
  83. window.addEventListener("pointerup", handleDragEnd);
  84. };
  85. const isMobileScreen = useMobileScreen();
  86. const shouldNarrow =
  87. !isMobileScreen && config.sidebarWidth < MIN_SIDEBAR_WIDTH;
  88. useEffect(() => {
  89. const barWidth = shouldNarrow
  90. ? NARROW_SIDEBAR_WIDTH
  91. : limit(config.sidebarWidth ?? DEFAULT_SIDEBAR_WIDTH);
  92. const sideBarWidth = isMobileScreen ? "100vw" : `${barWidth}px`;
  93. document.documentElement.style.setProperty("--sidebar-width", sideBarWidth);
  94. }, [config.sidebarWidth, isMobileScreen, shouldNarrow]);
  95. return {
  96. onDragStart,
  97. shouldNarrow,
  98. };
  99. }
  100. export function SideBarContainer(props: {
  101. children: React.ReactNode;
  102. onDragStart: (e: MouseEvent) => void;
  103. shouldNarrow: boolean;
  104. className?: string;
  105. }) {
  106. const isMobileScreen = useMobileScreen();
  107. const isIOSMobile = useMemo(
  108. () => isIOS() && isMobileScreen,
  109. [isMobileScreen],
  110. );
  111. const { children, className, onDragStart, shouldNarrow } = props;
  112. return (
  113. <div
  114. className={`${styles.sidebar} ${className} ${shouldNarrow && styles["narrow-sidebar"]
  115. }`}
  116. style={{
  117. transition: isMobileScreen && isIOSMobile ? "none" : undefined,
  118. background: '#FFFFFF',
  119. overflowY: "auto",
  120. }}
  121. >
  122. {children}
  123. <div
  124. className={styles["sidebar-drag"]}
  125. onPointerDown={(e) => onDragStart(e as any)}
  126. >
  127. <DragIcon />
  128. </div>
  129. </div>
  130. );
  131. }
  132. export function SideBarHeader(props: {
  133. title?: string | React.ReactNode;
  134. subTitle?: string | React.ReactNode;
  135. logo?: React.ReactNode;
  136. children?: React.ReactNode;
  137. }) {
  138. const { title, subTitle, logo, children } = props;
  139. return (
  140. <Fragment>
  141. <div className={styles["sidebar-header"]} data-tauri-drag-region>
  142. <div className={styles["sidebar-title-container"]}>
  143. <div className={styles["sidebar-title"]} data-tauri-drag-region>
  144. {title}
  145. </div>
  146. <div className={styles["sidebar-sub-title"]}>{subTitle}</div>
  147. </div>
  148. <div className={styles["sidebar-logo"] + " no-dark"}>{logo}</div>
  149. </div>
  150. {children}
  151. </Fragment>
  152. );
  153. }
  154. export function SideBarBody(props: {
  155. children: React.ReactNode;
  156. onClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
  157. }) {
  158. const { onClick, children } = props;
  159. return (
  160. <div className={styles["sidebar-body"]} onClick={onClick}>
  161. {children}
  162. </div>
  163. );
  164. }
  165. export function SideBarTail(props: {
  166. primaryAction?: React.ReactNode;
  167. secondaryAction?: React.ReactNode;
  168. }) {
  169. const { primaryAction, secondaryAction } = props;
  170. return (
  171. <div className={styles["sidebar-tail"]}>
  172. <div className={styles["sidebar-actions"]}>{primaryAction}</div>
  173. <div className={styles["sidebar-actions"]}>{secondaryAction}</div>
  174. </div>
  175. );
  176. }
  177. interface AppDrawerProps {
  178. isMobileScreen: boolean,
  179. selectedAppId: string,
  180. type: 'all' | 'collect',
  181. open: boolean,
  182. onClose: () => void,
  183. }
  184. const AppDrawer: React.FC<AppDrawerProps> = (props) => {
  185. const {
  186. isMobileScreen,
  187. selectedAppId,
  188. type,
  189. open,
  190. onClose,
  191. } = props;
  192. const navigate = useNavigate();
  193. const [listLoading, setListLoading] = useState(false);
  194. type List = {
  195. name: string,
  196. chatMode: string,
  197. appId: string,
  198. desc: string,
  199. createTime: string,
  200. typeName: string,
  201. isCollect: boolean,
  202. }[];
  203. const [list, setList] = useState<List>([]);
  204. const fetchAppList = async () => {
  205. setListLoading(true);
  206. try {
  207. const userId = '7';
  208. const res = await api.get(`/deepseek/api/project/app/${userId}`);
  209. if (type === 'all') {
  210. setList(res.data);
  211. } else {
  212. setList(res.data.filter((item: any) => item.isCollect));
  213. }
  214. } catch (error) {
  215. console.error(error);
  216. } finally {
  217. setListLoading(false);
  218. }
  219. };
  220. // 收藏应用
  221. const collectApp = async (appId: string) => {
  222. try {
  223. const userId = '7';
  224. await api.post('/deepseek/api/app/collect', {
  225. appId: appId,
  226. userId: userId,
  227. });
  228. message.success('收藏成功');
  229. await fetchAppList();
  230. } catch (error: any) {
  231. message.error(error.msg);
  232. }
  233. };
  234. // 取消收藏应用
  235. const cancelCollectApp = async (appId: string) => {
  236. try {
  237. const userId = '7';
  238. await api.delete(`/deepseek/api/app/collect/${userId}/${appId}`);
  239. message.success('操作成功');
  240. await fetchAppList();
  241. } catch (error: any) {
  242. message.error(error.msg);
  243. }
  244. };
  245. const init = async () => {
  246. await fetchAppList();
  247. }
  248. useEffect(() => {
  249. init();
  250. }, [])
  251. return (
  252. <Drawer
  253. width={isMobileScreen ? '100%' : 400}
  254. title={type === 'all' ? '我的应用' : '我的收藏'}
  255. open={open}
  256. loading={listLoading}
  257. onClose={onClose}
  258. >
  259. {
  260. list.length > 0 ?
  261. list.map((item, index) => {
  262. return <div
  263. style={{
  264. padding: 20,
  265. border: '1px solid #f0f0f0',
  266. borderRadius: 4,
  267. marginBottom: 20,
  268. cursor: 'pointer',
  269. }}
  270. key={index}
  271. >
  272. <div style={{ display: 'flex', marginBottom: 10 }}>
  273. <AppstoreOutlined style={{ fontSize: 40, color: '#3875f6', marginRight: 20 }} />
  274. <div>
  275. <div style={{ fontSize: 16, fontWeight: 'bold', marginBottom: 5 }}>
  276. {item.name}
  277. </div>
  278. <div style={{ color: '#d4d7de' }}>
  279. ID:{item.appId}
  280. </div>
  281. </div>
  282. </div>
  283. <div style={{ color: '#8f949e', marginBottom: 10 }}>
  284. {item.desc}
  285. </div>
  286. <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 10 }}>
  287. <div style={{ color: '#747a86' }}>
  288. {dayjs(item.createTime).format('YYYY-MM-DD')} 发布
  289. </div>
  290. <div>
  291. <Tag style={{ margin: 0 }} color="blue">
  292. {item.typeName}
  293. </Tag>
  294. </div>
  295. </div>
  296. <div
  297. style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
  298. <div onClick={async () => {
  299. if (item.isCollect) {
  300. await cancelCollectApp(item.appId);
  301. } else {
  302. await collectApp(item.appId);
  303. }
  304. }}>
  305. {
  306. item.isCollect ?
  307. <Rate count={1} value={1} />
  308. :
  309. <Rate count={1} />
  310. }
  311. </div>
  312. <Button type='primary' size="small" onClick={() => {
  313. const search = `?showMenu=false&chatMode=${item.chatMode}&appId=${item.appId}`;
  314. navigate({
  315. pathname: '/knowledgeChat',
  316. search: search,
  317. })
  318. location.reload();
  319. }}>
  320. 使用
  321. </Button>
  322. </div>
  323. </div>
  324. })
  325. :
  326. <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
  327. }
  328. </Drawer>
  329. )
  330. }
  331. export const SideBar = (props: { className?: string }) => {
  332. // useHotKey();
  333. const { onDragStart, shouldNarrow } = useDragSideBar();
  334. const [showPluginSelector, setShowPluginSelector] = useState(false);
  335. const navigate = useNavigate();
  336. const location = useLocation();
  337. const chatStore = useChatStore();
  338. const globalStore = useGlobalStore();
  339. const [menuList, setMenuList] = useState([])
  340. const [modalOpen, setModalOpen] = useState(false)
  341. const [form] = Form.useForm();
  342. const getType = (): 'bigModel' | 'deepSeek' => {
  343. if (['/knowledgeChat', '/newChat'].includes(location.pathname)) {
  344. return 'bigModel';
  345. } else if (['/deepseekChat', '/newDeepseekChat'].includes(location.pathname)) {
  346. return 'deepSeek';
  347. } else {
  348. return 'bigModel';
  349. }
  350. }
  351. // 获取聊天列表
  352. const fetchChatList = async (chatMode?: 'ONLINE' | 'LOCAL') => {
  353. try {
  354. let url = '';
  355. if (getType() === 'bigModel') {
  356. const appId = globalStore.selectedAppId;
  357. if (appId) {
  358. if (chatMode === 'LOCAL') {
  359. url = `/deepseek/api/dialog/list/${appId}`;
  360. } else {
  361. url = `/bigmodel/api/dialog/list/${appId}`;
  362. }
  363. }
  364. } else {
  365. const appId = '1881269958412521255';
  366. url = `/bigmodel/api/dialog/list/${appId}`;
  367. }
  368. const res = await api.get(url);
  369. const list = res.data.map((item: any) => {
  370. return {
  371. ...item,
  372. children: item.children.map((child: any) => {
  373. const items = [
  374. {
  375. key: '1',
  376. label: (
  377. <a onClick={() => {
  378. setModalOpen(true);
  379. form.setFieldsValue({
  380. dialogId: child.key,
  381. dialogName: child.label
  382. });
  383. }}>
  384. 重命名
  385. </a>
  386. ),
  387. },
  388. {
  389. key: '2',
  390. label: (
  391. <a onClick={async () => {
  392. try {
  393. let blob = null;
  394. if (getType() === 'bigModel') {
  395. if (chatMode === 'LOCAL') {
  396. blob = await api.post(`/deepseek/api/dialog/export/${child.key}`, {}, { responseType: 'blob' });
  397. } else {
  398. blob = await api.post(`/bigmodel/api/dialog/export/${child.key}`, {}, { responseType: 'blob' });
  399. }
  400. } else {
  401. blob = await api.post(`/bigmodel/api/dialog/export/${child.key}`, {}, { responseType: 'blob' });
  402. }
  403. const fileName = `${child.label}.xlsx`;
  404. downloadFile(blob, fileName);
  405. } catch (error) {
  406. console.error(error);
  407. }
  408. }}>
  409. 导出
  410. </a>
  411. ),
  412. },
  413. {
  414. key: '3',
  415. label: (
  416. <a onClick={async () => {
  417. try {
  418. if (getType() === 'bigModel') {
  419. if (chatMode === 'LOCAL') {
  420. await api.delete(`/deepseek/api/dialog/del/${child.key}`);
  421. await fetchChatList(chatMode);
  422. } else {
  423. await api.delete(`/bigmodel/api/dialog/del/${child.key}`);
  424. await fetchChatList();
  425. }
  426. } else {
  427. await api.delete(`/bigmodel/api/dialog/del/${child.key}`);
  428. await fetchChatList();
  429. }
  430. chatStore.clearSessions();
  431. useChatStore.setState({
  432. message: {
  433. content: '',
  434. role: 'assistant',
  435. }
  436. });
  437. } catch (error) {
  438. console.error(error);
  439. }
  440. }}>
  441. 删除
  442. </a>
  443. ),
  444. },
  445. ];
  446. return {
  447. ...child,
  448. label: <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
  449. <div style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', marginRight: 10 }}>
  450. {child.label}
  451. </div>
  452. <div style={{ width: 20 }}>
  453. <Dropdown menu={{ items }} trigger={['click']} placement="bottomRight">
  454. <EditOutlined onClick={(e) => e.stopPropagation()} />
  455. </Dropdown>
  456. </div>
  457. </div>
  458. }
  459. })
  460. }
  461. })
  462. setMenuList(list);
  463. } catch (error) {
  464. console.error(error)
  465. }
  466. }
  467. useEffect(() => {
  468. if (getType() === 'bigModel') {
  469. if (globalStore.selectedAppId) {
  470. fetchChatList(chatStore.chatMode);
  471. }
  472. }
  473. }, [globalStore.selectedAppId]);
  474. useEffect(() => {
  475. chatStore.clearSessions();
  476. useChatStore.setState({
  477. message: {
  478. content: '',
  479. role: 'assistant',
  480. }
  481. });
  482. }, []);
  483. useEffect(() => {
  484. fetchChatList(chatStore.chatMode);
  485. }, [chatStore.chatMode]);
  486. const isMobileScreen = useMobileScreen();
  487. const [drawerOpen, setDrawerOpen] = useState(false);
  488. const [drawerType, setDrawerType] = useState<'all' | 'collect'>('all');
  489. return (
  490. <>
  491. {
  492. globalStore.showMenu &&
  493. <SideBarContainer
  494. onDragStart={onDragStart}
  495. shouldNarrow={shouldNarrow}
  496. {...props}
  497. >
  498. {
  499. getType() === 'deepSeek' &&
  500. <div>
  501. <img style={{ width: '100%' }} src={deepSeekSrc.src} />
  502. </div>
  503. }
  504. <SideBarHeader
  505. title={getType() === 'bigModel' ?
  506. <div style={{ display: 'flex', alignItems: 'center' }}>
  507. {isMobileScreen && <div>
  508. <Button
  509. type='text'
  510. icon={<MenuOutlined />}
  511. onClick={() => {
  512. globalStore.setShowMenu(!globalStore.showMenu);
  513. }}
  514. />
  515. </div>}
  516. 问答历史
  517. </div>
  518. :
  519. ''
  520. }
  521. logo={getType() === 'bigModel' ? <img style={{ height: 40 }} src={faviconSrc.src} /> : ''}
  522. >
  523. <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 10 }}>
  524. <Button
  525. style={{ width: '48%' }}
  526. onClick={() => {
  527. navigate({ pathname: '/' });
  528. }}
  529. >
  530. 回到首页
  531. </Button>
  532. <Button
  533. style={{ width: '48%' }}
  534. onClick={async () => {
  535. chatStore.clearSessions();
  536. chatStore.updateCurrentSession((value) => {
  537. value.appId = globalStore.selectedAppId;
  538. });
  539. if (getType() === 'bigModel') {
  540. navigate({ pathname: '/newChat' });
  541. } else {
  542. navigate({ pathname: '/newDeepseekChat' });
  543. }
  544. if (getType() === 'bigModel') {
  545. if (chatStore.chatMode === 'LOCAL') {
  546. await fetchChatList(chatStore.chatMode);
  547. } else {
  548. await fetchChatList();
  549. }
  550. } else {
  551. await fetchChatList();
  552. }
  553. }}
  554. >
  555. 新建对话
  556. </Button>
  557. </div>
  558. <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 10 }}>
  559. <Button
  560. style={{ width: '48%' }}
  561. type="primary"
  562. onClick={() => {
  563. setDrawerType('all');
  564. setDrawerOpen(true);
  565. }}
  566. >
  567. 我的应用
  568. </Button>
  569. <Button
  570. style={{ width: '48%' }}
  571. type="primary"
  572. onClick={() => {
  573. setDrawerType('collect');
  574. setDrawerOpen(true);
  575. }}
  576. >
  577. 我的收藏
  578. </Button>
  579. </div>
  580. </SideBarHeader>
  581. <Menu
  582. style={{ border: 'none' }}
  583. onClick={async ({ key }) => {
  584. let url = ``;
  585. if (getType() === 'bigModel') {
  586. if (chatStore.chatMode === 'LOCAL') {
  587. url = `/deepseek/api/dialog/detail/${key}`;
  588. } else {
  589. url = `/bigmodel/api/dialog/detail/${key}`;
  590. }
  591. } else {
  592. url = `/bigmodel/api/dialog/detail/${key}`;
  593. }
  594. const res = await api.get(url);
  595. const list = res.data.map(((item: any) => {
  596. return {
  597. id: item.did,
  598. role: item.type,
  599. date: item.create_time,
  600. content: item.content,
  601. document: item.document ? item.document : undefined,
  602. sliceInfo: item.sliceInfo ? item.sliceInfo : undefined,
  603. networkInfo: item.networkInfo ? item.networkInfo : undefined,
  604. }
  605. }))
  606. const session = {
  607. appId: res.data.length ? res.data[0].appId : '',
  608. dialogName: res.data.length ? res.data[0].dialog_name : '',
  609. id: res.data.length ? res.data[0].id : '',
  610. messages: list,
  611. }
  612. globalStore.setCurrentSession(session);
  613. chatStore.clearSessions();
  614. chatStore.updateCurrentSession((value) => {
  615. value.appId = session.appId;
  616. value.topic = session.dialogName;
  617. value.id = session.id;
  618. value.messages = list;
  619. });
  620. if (getType() === 'bigModel') {
  621. navigate({ pathname: '/newChat' });
  622. } else {
  623. navigate({ pathname: '/newDeepseekChat' });
  624. }
  625. }}
  626. mode="inline"
  627. items={menuList}
  628. />
  629. <Modal
  630. title="重命名"
  631. open={modalOpen}
  632. width={300}
  633. maskClosable={false}
  634. onOk={() => {
  635. form.validateFields().then(async (values) => {
  636. setModalOpen(false);
  637. try {
  638. if (getType() === 'bigModel') {
  639. if (chatStore.chatMode === 'LOCAL') {
  640. await api.put(`/deepseek/api/dialog/update`, {
  641. id: values.dialogId,
  642. dialogName: values.dialogName
  643. });
  644. await fetchChatList(chatStore.chatMode);
  645. } else {
  646. await api.put(`/bigmodel/api/dialog/update`, {
  647. id: values.dialogId,
  648. dialogName: values.dialogName
  649. });
  650. await fetchChatList();
  651. }
  652. } else {
  653. await api.put(`/bigmodel/api/dialog/update`, {
  654. id: values.dialogId,
  655. dialogName: values.dialogName
  656. });
  657. await fetchChatList();
  658. }
  659. chatStore.updateCurrentSession((value) => {
  660. value.topic = values.dialogName;
  661. });
  662. } catch (error) {
  663. console.error(error);
  664. }
  665. }).catch((error) => {
  666. console.error(error);
  667. });
  668. }}
  669. onCancel={() => {
  670. setModalOpen(false);
  671. }}
  672. >
  673. <Form form={form} layout='inline'>
  674. <FormItem name='dialogId' noStyle />
  675. <FormItem
  676. label='名称'
  677. name='dialogName'
  678. rules={[{ required: true, message: '名称不能为空', whitespace: true }]}
  679. >
  680. <Input
  681. style={{ width: 300 }}
  682. placeholder='请输入'
  683. maxLength={20}
  684. />
  685. </FormItem>
  686. </Form>
  687. </Modal>
  688. </SideBarContainer>
  689. }
  690. {
  691. drawerOpen &&
  692. <AppDrawer
  693. isMobileScreen={isMobileScreen}
  694. selectedAppId={globalStore.selectedAppId}
  695. type={drawerType}
  696. open={drawerOpen}
  697. onClose={() => {
  698. setDrawerOpen(false);
  699. }}
  700. />
  701. }
  702. </>
  703. );
  704. }