From 9f04fb1e0f94efbcd29b164266256e0d912ab502 Mon Sep 17 00:00:00 2001 From: BiggerRain <15911122312@163.COM> Date: Thu, 17 Apr 2025 17:34:42 +0800 Subject: [PATCH] style: search data display (#380) * style: search date display * style: adjust style * style: search detail display * docs: update notes * build: build error --- docs/content.en/docs/release-notes/_index.md | 3 +- src/components/Assistant/ChatHeader.tsx | 14 +-- src/components/ChatMessage/FetchSource.tsx | 6 +- src/components/Common/UI/Footer.tsx | 2 +- src/components/Common/UI/NoResults.tsx | 4 +- src/components/Common/VisibleKey.tsx | 29 +++--- src/components/Search/DocumentDetail.tsx | 97 ++++++++++---------- src/components/Search/DropdownList.tsx | 6 +- src/components/Search/InputBox.tsx | 36 ++++---- src/components/Search/ListRight.tsx | 16 +--- src/components/Search/SearchHeader.tsx | 6 +- src/components/Search/SearchListItem.tsx | 16 ++-- src/components/Search/SearchPopover.tsx | 3 +- src/components/SearchChat/index.tsx | 6 +- src/hooks/useIsMobile.ts | 2 +- src/pages/web/index.tsx | 2 +- tailwind.config.js | 3 + 17 files changed, 119 insertions(+), 132 deletions(-) diff --git a/docs/content.en/docs/release-notes/_index.md b/docs/content.en/docs/release-notes/_index.md index ef5739d9..2b82ad83 100644 --- a/docs/content.en/docs/release-notes/_index.md +++ b/docs/content.en/docs/release-notes/_index.md @@ -29,14 +29,13 @@ Information about release notes of Coco Server is provided here. - fix: active shadow setting #354 - fix: chat history was not show up #377 - ### Improvements - refactor: web components #331 - refactor: refactoring login callback, receive access_token from coco-server - chore: adjust web component styles #362 - style: modify the style #370 -- style: search list details display #378 +- style: search list details display #378 #380 ## 0.3.0 (2025-03-31) diff --git a/src/components/Assistant/ChatHeader.tsx b/src/components/Assistant/ChatHeader.tsx index 26429217..78436c16 100644 --- a/src/components/Assistant/ChatHeader.tsx +++ b/src/components/Assistant/ChatHeader.tsx @@ -54,7 +54,7 @@ export function ChatHeader({ reconnect, setIsLogin, isChatPage = false, - showChatHistory, + showChatHistory = true, }: ChatHeaderProps) { const { t } = useTranslation(); @@ -199,20 +199,20 @@ export function ChatHeader({ data-tauri-drag-region >
- {isTauri && ( + {showChatHistory && ( )} @@ -250,13 +250,13 @@ export function ChatHeader({ ) : null} - {showChatHistory && isTauri ? ( + {showChatHistory ? ( ) : null} diff --git a/src/components/ChatMessage/FetchSource.tsx b/src/components/ChatMessage/FetchSource.tsx index b55eaaa2..6ddea9f5 100644 --- a/src/components/ChatMessage/FetchSource.tsx +++ b/src/components/ChatMessage/FetchSource.tsx @@ -10,7 +10,6 @@ import { useTranslation } from "react-i18next"; import { OpenURLWithBrowser } from "@/utils/index"; import type { IChunkData } from "@/components/Assistant/types"; import RetrieveIcon from "@/icons/Retrieve"; -import { useAppStore } from "@/stores/appStore"; interface FetchSourceProps { Detail?: any; @@ -41,7 +40,6 @@ export const FetchSource = ({ loading, }: FetchSourceProps) => { const { t } = useTranslation(); - const isTauri = useAppStore((state) => state.isTauri); const [isSourceExpanded, setIsSourceExpanded] = useState(false); @@ -138,9 +136,7 @@ export const FetchSource = ({
{item.source?.name} diff --git a/src/components/Common/UI/Footer.tsx b/src/components/Common/UI/Footer.tsx index 8281313d..9f7b8c18 100644 --- a/src/components/Common/UI/Footer.tsx +++ b/src/components/Common/UI/Footer.tsx @@ -100,7 +100,7 @@ export default function Footer({ )}
{t("search.footer.select")}: diff --git a/src/components/Common/UI/NoResults.tsx b/src/components/Common/UI/NoResults.tsx index 18c27ef6..dad4c344 100644 --- a/src/components/Common/UI/NoResults.tsx +++ b/src/components/Common/UI/NoResults.tsx @@ -4,12 +4,10 @@ import { useTranslation } from "react-i18next"; import { isMac } from "@/utils/platform"; import { useShortcutsStore } from "@/stores/shortcutsStore"; import noDataImg from "@/assets/coconut-tree.png"; -import { useAppStore } from "@/stores/appStore"; export const NoResults = () => { const { t } = useTranslation(); - const isTauri = useAppStore((state) => state.isTauri); const modeSwitch = useShortcutsStore((state) => state.modeSwitch); return ( @@ -21,7 +19,7 @@ export const NoResults = () => {
{t("search.main.noResults")}
-
+
{t("search.main.askCoco")} {isMac ? ( diff --git a/src/components/Common/VisibleKey.tsx b/src/components/Common/VisibleKey.tsx index 151194d7..14a76773 100644 --- a/src/components/Common/VisibleKey.tsx +++ b/src/components/Common/VisibleKey.tsx @@ -1,8 +1,9 @@ -import { POPOVER_PANEL_SELECTOR } from "@/constants"; -import { useShortcutsStore } from "@/stores/shortcutsStore"; +import { FC, ReactNode, useEffect, useRef, useState } from "react"; import { useKeyPress } from "ahooks"; import clsx from "clsx"; -import { FC, ReactNode, useEffect, useRef, useState } from "react"; + +import { POPOVER_PANEL_SELECTOR } from "@/constants"; +import { useShortcutsStore } from "@/stores/shortcutsStore"; interface VisibleKeyProps { shortcut: string; @@ -64,17 +65,23 @@ const VisibleKey: FC = (props) => { return shortcut; }; - return visibleShortcut ? ( + return (
- {renderShortcut()} + {children} + {visibleShortcut ? ( +
+ {renderShortcut()} +
+ ) : null}
- ) : ( -
{children}
); }; diff --git a/src/components/Search/DocumentDetail.tsx b/src/components/Search/DocumentDetail.tsx index 1c435919..a49de813 100644 --- a/src/components/Search/DocumentDetail.tsx +++ b/src/components/Search/DocumentDetail.tsx @@ -3,6 +3,8 @@ import { useTranslation } from "react-i18next"; import { formatter } from "@/utils/index"; import TypeIcon from "@/components/Common/Icons/TypeIcon"; +import defaultThumbnail from "@/assets/coconut-tree.png"; +import ItemIcon from "@/components/Common/Icons/ItemIcon"; interface DocumentDetailProps { document: any; @@ -16,9 +18,9 @@ interface DetailItemProps { } const DetailItem: React.FC = ({ label, value, icon }) => ( -
-
{label}
-
+
+
{label}
+
{icon} {value}
@@ -30,17 +32,52 @@ export const DocumentDetail: React.FC = ({ document }) => { const { t } = useTranslation(); return ( -
-
+
+ {/*
{t("search.document.details")} +
*/} +
+ {document?.title || "-"}
-
- {/* Basic Information */} - +
+ {/* Document Thumbnail */} +
+ {document.thumbnail ? ( + thumbnail { + const target = e.target as HTMLImageElement; + target.src = defaultThumbnail; + }} + /> + ) : ( + + )} +
+ + {/* Document Summary */} + {document?.summary && ( +
+ {document.summary} +
+ )} + + {/* Document Tags */} + {document?.tags && document.tags.length > 0 && ( +
+ {document.tags.map((tag: string, index: number) => ( + + {tag} + + ))} +
+ )} = ({ document }) => { /> )} - {/* Document Thumbnail */} - {document?.thumbnail && ( - - } - /> - )} - {/* Document Identifier */} {document?.id && ( @@ -117,30 +140,6 @@ export const DocumentDetail: React.FC = ({ document }) => { /> )} - {/* Document Tags */} - {document?.tags && document.tags.length > 0 && ( - - {document.tags.join(", ")} -
- } - /> - )} - - {/* Document Summary */} - {document?.summary && ( - - {document.summary} -
- } - /> - )} - {/* Last Update Time */} {document?.updated && ( ; @@ -190,7 +191,10 @@ function DropdownList({ {showIndex && sourceName === selectedName ? ( -
+
+ +
+ ) : null}
) : null} diff --git a/src/components/Search/InputBox.tsx b/src/components/Search/InputBox.tsx index 8309d15e..e0f821e5 100644 --- a/src/components/Search/InputBox.tsx +++ b/src/components/Search/InputBox.tsx @@ -18,7 +18,7 @@ import { DataSource } from "@/types/commands"; // import { useConnectStore } from "@/stores/connectStore"; import { useShortcutsStore } from "@/stores/shortcutsStore"; import Copyright from "@/components/Common/Copyright"; -import VisibleKey from "../Common/VisibleKey"; +import VisibleKey from "@/components/Common/VisibleKey"; interface ChatInputProps { onSend: (message: string) => void; @@ -335,15 +335,18 @@ export default function ChatInput({ /> )} {showTooltip && !isChatMode && sourceData && ( - +
+ +
)} {showTooltip && ( - + > + +
)}
@@ -390,7 +393,9 @@ export default function ChatInput({ ) : null} */} {showTooltip && isChatMode && ( - +
+ +
)} {!connected && isChatMode ? ( @@ -441,11 +446,7 @@ export default function ChatInput({ )} onClick={DeepThinkClick} > - + )} {!hasFeature.includes("search") && !hasFeature.includes("think") ? ( -
+
) : null} @@ -489,10 +490,9 @@ export default function ChatInput({ {isChatPage || hasModules?.length !== 2 ? null : (
{showTooltip && ( - +
+ +
)} state.isTauri); return (
{item?.rich_categories ? null : (
{ e.stopPropagation(); goToTwoPage && goToTwoPage(item); @@ -52,9 +44,7 @@ export default function ListRight({
{ e.stopPropagation(); goToTwoPage && goToTwoPage(item); diff --git a/src/components/Search/SearchHeader.tsx b/src/components/Search/SearchHeader.tsx index 3f8eeffe..9f2dfcbb 100644 --- a/src/components/Search/SearchHeader.tsx +++ b/src/components/Search/SearchHeader.tsx @@ -2,8 +2,6 @@ import React from "react"; import { AlignLeft, Columns2 } from "lucide-react"; import { useTranslation } from "react-i18next"; -import { useAppStore } from "@/stores/appStore"; - interface SearchHeaderProps { total: number; viewMode: "detail" | "list"; @@ -17,8 +15,6 @@ export const SearchHeader: React.FC = ({ }) => { const { t } = useTranslation(); - const isTauri = useAppStore((state) => state.isTauri); - return (
@@ -28,7 +24,7 @@ export const SearchHeader: React.FC = ({ {t('search.header.results')}
-
+