From 5a20c5282e4f49eca476a1e7f938d1bd86a6d0b8 Mon Sep 17 00:00:00 2001 From: Zhang Minghan Date: Sun, 5 Nov 2023 10:06:47 +0800 Subject: [PATCH] update scroll action and fix file style in mobile --- app/src/assets/common/file.less | 9 + app/src/assets/markdown/all.less | 1 + app/src/assets/pages/chat.less | 10 +- app/src/assets/pages/home.less | 1 + app/src/components/EditorProvider.tsx | 18 +- app/src/components/FileProvider.tsx | 13 +- app/src/components/ReloadService.tsx | 1 + app/src/components/home/ChatFooter.tsx | 53 ++++ app/src/components/home/ChatInterface.tsx | 44 +--- app/src/components/home/ChatSpace.tsx | 84 +++++++ app/src/components/home/ChatWrapper.tsx | 229 +++--------------- .../{ModelSelector.tsx => ModelFinder.tsx} | 6 +- .../components/home/components/ChatInput.tsx | 41 ++++ .../home/components/ScrollAction.tsx | 45 ++++ .../components/home/components/SendButton.tsx | 28 +++ .../components/home/components/WebToggle.tsx | 41 ++++ app/src/conf.ts | 2 +- app/src/events/chat.ts | 5 + app/src/routes/Article.tsx | 4 +- app/src/routes/Generation.tsx | 4 +- app/src/store/chat.ts | 3 +- 21 files changed, 375 insertions(+), 267 deletions(-) create mode 100644 app/src/components/home/ChatFooter.tsx create mode 100644 app/src/components/home/ChatSpace.tsx rename app/src/components/home/{ModelSelector.tsx => ModelFinder.tsx} (96%) create mode 100644 app/src/components/home/components/ChatInput.tsx create mode 100644 app/src/components/home/components/ScrollAction.tsx create mode 100644 app/src/components/home/components/SendButton.tsx create mode 100644 app/src/components/home/components/WebToggle.tsx create mode 100644 app/src/events/chat.ts diff --git a/app/src/assets/common/file.less b/app/src/assets/common/file.less index b2425ef..75585b4 100644 --- a/app/src/assets/common/file.less +++ b/app/src/assets/common/file.less @@ -22,6 +22,7 @@ .file-wrapper { margin-top: 24px !important; padding: 8px 0; + max-width: calc(90vw - 3rem); } .drop-window { @@ -103,3 +104,11 @@ } } } + +.file-name { + word-wrap: anywhere; + word-break: break-all; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} diff --git a/app/src/assets/markdown/all.less b/app/src/assets/markdown/all.less index 0340140..98c9f2c 100644 --- a/app/src/assets/markdown/all.less +++ b/app/src/assets/markdown/all.less @@ -13,6 +13,7 @@ border: 1px solid hsl(var(--border-hover)); background: hsl(var(--background-container)) !important; border-radius: var(--radius); + white-space: pre-wrap; svg { width: 16px; diff --git a/app/src/assets/pages/chat.less b/app/src/assets/pages/chat.less index 1e88412..cd7b668 100644 --- a/app/src/assets/pages/chat.less +++ b/app/src/assets/pages/chat.less @@ -14,10 +14,11 @@ .scroll-action { position: absolute; z-index: 12; - bottom: 112px; - right: 36px; opacity: 0; + right: 36px; + bottom: 12rem; transition: .25s; + pointer-events: none; button { border-color: rgba(0,0,0,0) !important; @@ -25,6 +26,11 @@ &.active { opacity: 0.8; + pointer-events: all; + } + + @media (max-width: 668px) { + bottom: 8.5rem; } } diff --git a/app/src/assets/pages/home.less b/app/src/assets/pages/home.less index 92b694d..61574cc 100644 --- a/app/src/assets/pages/home.less +++ b/app/src/assets/pages/home.less @@ -318,6 +318,7 @@ padding: 6px 24px; .input-wrapper { + position: relative; display: flex; flex-direction: row; align-items: center; diff --git a/app/src/components/EditorProvider.tsx b/app/src/components/EditorProvider.tsx index d37ba86..826a766 100644 --- a/app/src/components/EditorProvider.tsx +++ b/app/src/components/EditorProvider.tsx @@ -19,19 +19,11 @@ import { Button } from "./ui/button.tsx"; type RichEditorProps = { value: string; onChange: (value: string) => void; - className?: string; - id?: string; - placeholder?: string; maxLength?: number; }; -function RichEditor({ - value, - onChange, - id, - placeholder, - maxLength, -}: RichEditorProps) { +function RichEditor({ value, onChange, maxLength }: RichEditorProps) { + const { t } = useTranslation(); const input = useRef(null); const [openPreview, setOpenPreview] = useState(!mobile); const [openInput, setOpenInput] = useState(true); @@ -117,10 +109,10 @@ function RichEditor({ > {openInput && (