From b5fa54a754c733ea23842cb48888eb9a4c42b732 Mon Sep 17 00:00:00 2001 From: williamhliu <137068196+williamhliu@users.noreply.github.com> Date: Tue, 30 Jul 2024 19:32:30 +0800 Subject: [PATCH] (improvement)(chat-sdk) set ant locale to zh-cn and optimize range picker style (#1489) --- webapp/packages/chat-sdk/src/Chat/index.tsx | 261 +++++++++--------- .../src/components/ChatItem/ParseTip.tsx | 20 +- 2 files changed, 143 insertions(+), 138 deletions(-) diff --git a/webapp/packages/chat-sdk/src/Chat/index.tsx b/webapp/packages/chat-sdk/src/Chat/index.tsx index 7bd7cad0f..64dc71da2 100644 --- a/webapp/packages/chat-sdk/src/Chat/index.tsx +++ b/webapp/packages/chat-sdk/src/Chat/index.tsx @@ -22,7 +22,12 @@ import { HistoryMsgItemType, MsgDataType, SendMsgParamsType } from '../common/ty import { getHistoryMsg } from '../service'; import ShowCase from '../ShowCase'; import { jsonParse } from '../utils/utils'; -import { Drawer, Modal, Row, Col, Space, Switch, Tooltip } from 'antd'; +import { ConfigProvider, Drawer, Modal, Row, Col, Space, Switch, Tooltip } from 'antd'; +import locale from 'antd/locale/zh_CN'; +import dayjs from 'dayjs'; +import 'dayjs/locale/zh-cn'; + +dayjs.locale('zh-cn'); type Props = { token?: string; @@ -377,140 +382,142 @@ const Chat: ForwardRefRenderFunction = ( }); return ( -
-
- {!isMobile && agentList.length > 1 && agentListVisible && ( - +
+
+ {!isMobile && agentList.length > 1 && agentListVisible && ( + + )} +
+ {currentConversation && ( +
+
+ {currentAgent && !isMobile && !noInput && ( +
+ + + +
{currentAgent.name}
+
{currentAgent.description}
+ + { + setIsSimpleMode(checked); + }} + /> + +
+ + +
+
+ )} + + {!noInput && ( + { + if (isMobile) { + setMobileAgentsVisible(true); + } else { + setAgentListVisible(!agentListVisible); + } + }} + onOpenShowcase={() => { + setShowCaseVisible(!showCaseVisible); + }} + ref={chatFooterRef} + /> + )} +
+
+ )} +
+ - )} -
- {currentConversation && ( -
-
- {currentAgent && !isMobile && !noInput && ( -
- - - -
{currentAgent.name}
-
{currentAgent.description}
- - { - setIsSimpleMode(checked); - }} - /> - -
- - -
-
- )} - { + setShowCaseVisible(false); + }} + > + + + ) : ( + { + setShowCaseVisible(false); + }} + > + - {!noInput && ( - { - if (isMobile) { - setMobileAgentsVisible(true); - } else { - setAgentListVisible(!agentListVisible); - } - }} - onOpenShowcase={() => { - setShowCaseVisible(!showCaseVisible); - }} - ref={chatFooterRef} - /> - )} -
-
- )} + + ))}
- { + setMobileAgentsVisible(false); + }} /> - {currentAgent && - (isMobile ? ( - { - setShowCaseVisible(false); - }} - > - - - ) : ( - { - setShowCaseVisible(false); - }} - > - - - ))}
- { - setMobileAgentsVisible(false); - }} - /> -
+ ); }; diff --git a/webapp/packages/chat-sdk/src/components/ChatItem/ParseTip.tsx b/webapp/packages/chat-sdk/src/components/ChatItem/ParseTip.tsx index 8ce72dfb8..1264268e5 100644 --- a/webapp/packages/chat-sdk/src/components/ChatItem/ParseTip.tsx +++ b/webapp/packages/chat-sdk/src/components/ChatItem/ParseTip.tsx @@ -9,8 +9,13 @@ import MarkDown from '../ChatMsg/MarkDown'; import classNames from 'classnames'; import { isMobile } from '../../utils/utils'; import dayjs, { Dayjs } from 'dayjs'; +import locale from 'antd/locale/zh_CN'; import quarterOfYear from 'dayjs/plugin/quarterOfYear'; + +import 'dayjs/locale/zh-cn'; + dayjs.extend(quarterOfYear); +dayjs.locale('zh-cn'); const { RangePicker } = DatePicker; @@ -257,24 +262,17 @@ const ParseTip: React.FC = ({ ( {Object.keys(ranges).map(key => ( - + ))}