diff --git a/src/assets/locale/zh/settings.json b/src/assets/locale/zh/settings.json index f201179..7186d04 100644 --- a/src/assets/locale/zh/settings.json +++ b/src/assets/locale/zh/settings.json @@ -316,6 +316,10 @@ "title": "管理知识", "heading": "配置知识库" }, + "iodSettings": { + "title": "数联网 设置", + "heading": "配置数联网" + }, "rag": { "title": "RAG 设置", "ragSettings": { diff --git a/src/components/Common/PageAssistProvider.tsx b/src/components/Common/PageAssistProvider.tsx index cd5cac8..6606418 100644 --- a/src/components/Common/PageAssistProvider.tsx +++ b/src/components/Common/PageAssistProvider.tsx @@ -11,6 +11,11 @@ export const PageAssistProvider = ({ const [controller, setController] = React.useState( null ) + + const [iodLoading, setIodLoading] = React.useState(false) + const [currentMessageId, setCurrentMessageId] = React.useState('') + + const [embeddingController, setEmbeddingController] = React.useState(null) @@ -20,6 +25,12 @@ export const PageAssistProvider = ({ messages, setMessages, + iodLoading, + setIodLoading, + + currentMessageId, + setCurrentMessageId, + controller, setController, diff --git a/src/components/Common/Playground/Data.tsx b/src/components/Common/Playground/Data.tsx index 4078b67..3838d97 100644 --- a/src/components/Common/Playground/Data.tsx +++ b/src/components/Common/Playground/Data.tsx @@ -1,57 +1,99 @@ -import React from "react" +import React, { useMemo, useState } from "react" import { DataNavigation } from "@/components/Common/DataNavigation.tsx" -import { Card, Drawer, List } from "antd" -import { useCallback, useState } from "react" +import { Card, Drawer, Skeleton } from "antd" +import { useMessageOption } from "@/hooks/useMessageOption.tsx" +import { IodRegistryEntry } from "@/types/iod.ts" -export const PlaygroundData = () => { - // 模拟数据 - const data: { - title: string - description: string - time: string - metadata?: string - }[] = [ - { - title: "2019-2024年黄海清浅海域中河湖代数生物物种数据集", - description: - "数字对象标识: CSTR:13452.11.01.11.2021.242 国家海洋科学数据中心", - time: "包括2019年8月,2021年8月和2024年6月", - metadata: "热 榜 第2" - }, - { - title: "祁连山老虎沟大本营10米气象每日值数据集(V1.0)(2018-2023)", - description: - "中国科学院西北生态环境资源研究院,2021年8月3日发布,2021年8月3日20:48更新", - time: "包括2019年8月,2021年8月和2024年6月", - metadata: "热 榜 第2" - }, - { - title: "李嘉图为研究老虎沟大本营2014-2018年...", - description: - "中国科学院西北生态环境资源研究院,2021年8月3日发布,2021年8月3日20:48更新", - time: "包括2019年8月,2021年8月和2024年6月", - metadata: "热 榜 第2" - }, - { - title: "青海玉树B1区俄日矿勘探数据2017-2023", - description: - "数字中国集团,CSTR:3260.11.1528414774204895456,DT2023年地质勘探补充调查", - time: "包括2019年8月,2021年8月和2024年6月", - metadata: "热 榜 第2" - } - ] - - for (let i = 0; i < 10; i++) { - data.push({ - title: "中国资源环境网", - description: "中国资源环境网,2021年8月3日发布,2021年8月3日20:48更新", - time: "包括2019年8月,2021年8月和2024年6月" - }) +const defaultData: IodRegistryEntry[] = [ + { + name: "2019-2024年黄海清浅海域中河湖代数生物物种数据集", + doId: "CSTR:13452.11.01.11.2021.242", + description: + "数字对象标识: CSTR:13452.11.01.11.2021.242 国家海洋科学数据中心" + }, + { + name: "祁连山老虎沟大本营10米气象每日值数据集(V1.0)(2018-2023)", + doId: "CSTR:13452.11.01.11.2021.343", + description: "黄海清浅海域中河湖代数生物物种数据集" + }, + { + name: "李嘉图为研究老虎沟大本营2014-2018年", + doId: "CSTR:3260.11.1528414789920489545", + description: + "中国科学院西北生态环境资源研究院,2021年8月3日发布,2021年8月3日20:48更新" + }, + { + name: "青海玉树B1区俄日矿勘探数据2017-2023", + doId: "CSTR:3260.11.152841477420489545", + description: + "数字中国集团,CSTR:3260.11.1528414774204895456,DT2023年地质勘探补充调查" } +] + +type ShowCardProps = { + loading: boolean + record: IodRegistryEntry + truncate?: boolean +} + +const ShowCard: React.FC = ({ + loading, + record, + truncate = true +}) => ( + + {loading ? ( + + ) : ( +
+

+ {record.name} +

+

+ 数字对象标识:{record.doId} +

+

+ {record.description} +

+
+ )} +
+) +export const PlaygroundData = () => { + const { messages, iodLoading, currentMessageId, iodSearch } = useMessageOption() + + const data = useMemo(() => { + // 确保loading状态时数据大于3 + if (iodLoading) { + return defaultData + } + + if (messages.length && iodSearch) { + const currentMessage = messages?.find( + (message) => message.id === currentMessageId + ) + return currentMessage?.iodSources.data.data ?? [] + } + + return defaultData + }, [currentMessageId, messages, iodLoading, iodSearch]) + + const title = useMemo(() => { + return messages.length > 0 ? "推荐数据" : "热点数据" + }, [messages]) const [open, setOpen] = useState(false) const showDrawer = () => { + if (iodLoading) { + return + } setOpen(true) } @@ -67,7 +109,7 @@ export const PlaygroundData = () => { {/* 数据导航 */} +
{ + fill="#3581e3"> - 相关数据 + {title}
} onClick={showDrawer} @@ -89,59 +131,23 @@ export const PlaygroundData = () => { {/* 数据列表 */}
- {data.slice(0, 3).map((item, index) => ( - -
-

- {item.title} -

-

- {item.description} -

-

{item.time}

- {item.metadata && ( -
- - {item.metadata} - -
- )} -
-
- ))} + {data.slice(0, 3).map((item, index) => { + return ( + + ) + })}
- {/* 抽屉 */}
- {data.slice(0, 3).map((item, index) => ( - -
-

- {item.title} -

-

{item.description}

-

{item.time}

- {item.metadata && ( -
- - {item.metadata} - -
- )} -
-
+ {data.map((item, index) => ( + ))}
diff --git a/src/components/Common/Playground/History.tsx b/src/components/Common/Playground/History.tsx index bf49e40..7f3d25a 100644 --- a/src/components/Common/Playground/History.tsx +++ b/src/components/Common/Playground/History.tsx @@ -67,7 +67,7 @@ export const PlaygroundHistory = () => { return [ { key: "qaPrompt", - label: "热门搜索", + label: "热点问题", type: "group" as const, children: qaPrompt.map((item) => { return { diff --git a/src/components/Common/Playground/IodRelevant.tsx b/src/components/Common/Playground/IodRelevant.tsx index 287673c..b47ba9e 100644 --- a/src/components/Common/Playground/IodRelevant.tsx +++ b/src/components/Common/Playground/IodRelevant.tsx @@ -1,8 +1,8 @@ -import React from "react" -import { Button, Card } from "antd" +import React, { useMemo } from "react" +import { Card } from "antd" // 使用 CSS-in-JS 方式 -import styled, { keyframes } from 'styled-components' +import styled, { keyframes } from "styled-components" const rotate = keyframes` 0% { @@ -25,20 +25,22 @@ const breathe = keyframes` } ` -const CircleElement = styled.div<{ delay: number }>` +const CircleElement = styled.div<{ delay: number; playing: boolean }>` position: absolute; width: 300px; height: 160px; - background: #3b82f6; // blue-500 + background: #3b82f6; // blue-500 opacity: 0.2; border-radius: 50%; top: 55%; left: 50%; - animation: ${rotate} 6s linear infinite, ${breathe} 2s infinite alternate; - animation-delay: ${props => props.delay}s; + animation: + ${rotate} 6s linear infinite, + ${breathe} 2s infinite alternate; + animation-delay: ${(props) => props.delay}s; + animation-play-state: ${(props) => (props.playing ? "running" : "paused")}; ` - const SuccessIcon = () => { return ( { viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" - p-id="8408" + p-id="29588" width="18" height="18"> + d="M483.712 888.064a52.437333 52.437333 0 1 1 52.48 52.352 52.394667 52.394667 0 0 1-52.48-52.352z m-235.434667-53.76a65.578667 65.578667 0 1 1 46.421334 19.242667 65.962667 65.962667 0 0 1-46.378667-19.242667z m499.584-16.597333a41.984 41.984 0 0 1 59.264-59.434667 42.282667 42.282667 0 0 1 0 59.434667 41.941333 41.941333 0 0 1-59.264 0zM112.853333 546.602667a81.92 81.92 0 1 1 81.92 81.92 81.834667 81.834667 0 0 1-81.92-81.877334z m731.008 0a33.536 33.536 0 1 1 33.493334 33.578666 33.578667 33.578667 0 0 1-33.450667-33.536zM222.208 377.6a102.4 102.4 0 1 1 72.533333 29.866667 102.869333 102.869333 0 0 1-72.533333-29.824z m536.32-53.504a26.666667 26.666667 0 1 1 18.816 7.936 26.368 26.368 0 0 1-18.773333-7.893333zM414.378667 205.184a121.642667 121.642667 0 1 1 121.813333 121.6A121.728 121.728 0 0 1 414.378667 205.226667z" + p-id="29589" + fill="#4284f6"> ) } @@ -94,60 +96,110 @@ const SearchIcon = () => { } export const PlaygroundIodRelevant: React.FC = () => { - const data = [ - { - title:

已在29个科学数据中心50万个科学数据集中进行搜索

, - description:

已发现 4个 数据集

, - status: "success" - }, - { - title:

已在100万篇论文2800个科创场景中进行搜索

, - description: "已发现4个数据集", - status: "success" - }, - { - title:

正在1000位智库专家12万个创新机构中进行搜索

, - status: "loading" - } - ] + const { messages, iodLoading, currentMessageId, iodSearch } = + useMessageOption() - for (let i = 0; i < 10; i++) { - data.push({ - title:

正在1000位智库专家12万个创新机构中进行搜索{i}

, - description: "已发现4个数据集", - status: "success" - }) - } + const showDescription = useMemo(() => { + return iodSearch && messages.length > 0 && !iodLoading + }, [iodSearch, messages, iodLoading]) + const data = useMemo(() => { + const currentMessage = messages?.find( + (message) => message.id === currentMessageId + ) + return [ + { + title: ( +

+ 已连接 11家 + 国家科学数据中心的 + 500000+个 科学数据集中 +

+ ), + description: showDescription ? ( +

+ 已发现 + + {" "} + {currentMessage?.iodSources.data.total}个{" "} + + 数据集 +

+ ) : ( + "" + ) + }, + { + title: ( +

+ 已连接 1000000+篇 论文和 + 50000+个 科创场景 +

+ ), + description: showDescription ? ( +

+ 已发现 + + {" "} + {currentMessage?.iodSources.scenario.total}个{" "} + + 科创场景 +

+ ) : ( + "" + ) + }, + { + title: ( +

+ 已连接 1000+位 智库专家 + 763家 高校和科研机构和 + 21000+家 科技企业 +

+ ), + description: showDescription ? ( +

+ 已发现 + + {" "} + {currentMessage?.iodSources.organization.total}个{" "} + + 科技企业 +

+ ) : ( + "" + ) + } + ] + }, [messages, iodLoading]) return ( + className="flex flex-col h-full [&_.ant-card-body]:h-full [&_.ant-card-body]:!p-[20px] translate-y-[-2px] !bg-[#f0f9ff]">
{/* 花瓣效果 */}
- - - + + +
{/* Header */}
-

-
+

+
数联网搜索相关内容
- + {/**/}

-

+

下面是在数联网上进行深度搜索的相关内容

@@ -156,25 +208,30 @@ export const PlaygroundIodRelevant: React.FC = () => {
{data.map((item, index) => ( -
-
- {item.status === "success" ? ( - - ) : ( - - )} + className="[&_.ant-card-body]:!p-3 [&_.ant-card-body]:h-full shadow-md h-[88px]" + key={index}> +
+
+
+ {iodSearch && iodLoading ? ( + + ) : ( + + )} +
+

+ {item.title} +

-
-

{item.title}

- {item.description && ( -

+ {item.description && ( +

+

{item.description}

- )} -
+
+ )}
))} diff --git a/src/components/Common/Playground/Message.tsx b/src/components/Common/Playground/Message.tsx index fc4c798..3ed01d4 100644 --- a/src/components/Common/Playground/Message.tsx +++ b/src/components/Common/Playground/Message.tsx @@ -1,30 +1,31 @@ import Markdown from "../../Common/Markdown" import React from "react" -import { Tag, Image, Tooltip, Collapse, Popover } from "antd" +import { Collapse, Image, Popover, Tag, Tooltip } from "antd" import { WebSearch } from "./WebSearch" import { + ArrowUpSquare, CheckIcon, ClipboardIcon, InfoIcon, + MessageSquareShare, Pen, PlayIcon, RotateCcw, Square, Star, - ThumbsUp, ThumbsDown, - MessageSquareShare, - ArrowUpSquare + ThumbsUp } from "lucide-react" import { EditMessageForm } from "./EditMessageForm" import { useTranslation } from "react-i18next" import { MessageSource } from "./MessageSource" import { useTTS } from "@/hooks/useTTS" import { tagColors } from "@/utils/color" -import { removeModelSuffix } from "@/db/models" import { GenerationInfo } from "./GenerationInfo" import { parseReasoning } from "@/libs/reasoning" import { humanizeMilliseconds } from "@/utils/humanize-milliseconds" +import { AllIodRegistryEntry } from "@/types/iod.ts" + type Props = { message: string message_type?: string @@ -42,7 +43,7 @@ type Props = { webSearch?: {} isSearchingInternet?: boolean webSources?: any[] - iodSources?: any[] + iodSources?: AllIodRegistryEntry hideEditAndRegenerate?: boolean onSourceClick?: (source: any) => void isTTSEnabled?: boolean @@ -60,7 +61,8 @@ export const PlaygroundMessage = (props: Props) => { return (
{/*
*/} -
+
{props.isBot ? ( @@ -77,8 +79,7 @@ export const PlaygroundMessage = (props: Props) => {
- - + {props.isBot && props.isSearchingInternet && @@ -101,6 +102,7 @@ export const PlaygroundMessage = (props: Props) => { return ( { ) : (

{props.message} {/*{props.message}*/} @@ -170,9 +171,10 @@ export const PlaygroundMessage = (props: Props) => { {t("webCitations")} @@ -194,13 +196,14 @@ export const PlaygroundMessage = (props: Props) => { ]} /> )} - {props.isBot && props?.iodSources && props?.iodSources.length > 0 && ( + {props.isBot && props?.iodSources && Object.values(props?.iodSources).map(item => item.data).flat().length > 0 && ( {t("iodCitations")} @@ -208,7 +211,7 @@ export const PlaygroundMessage = (props: Props) => { ), children: (

- {props?.iodSources?.map((source, index) => ( + {Object.values(props?.iodSources).map(item => item.data).flat()?.map((source, index) => ( { )} - { ( + { - )} - { ( + } + { - )} - { ( + } + { - )} - { ( + } + { - )} - { ( + } + { - )} + }
) : ( // add invisible div to prevent layout shift diff --git a/src/components/Common/Playground/Scene.tsx b/src/components/Common/Playground/Scene.tsx index 837ab44..27204d9 100644 --- a/src/components/Common/Playground/Scene.tsx +++ b/src/components/Common/Playground/Scene.tsx @@ -1,44 +1,98 @@ -import React, { useState } from "react" +import React, { useMemo, useState } from "react" import { DataNavigation } from "@/components/Common/DataNavigation.tsx" -import { Card, Drawer, List } from "antd" +import { Card, Drawer, Skeleton } from "antd" +import { IodRegistryEntry } from "@/types/iod.ts" + +const defaultData: IodRegistryEntry[] = [ + { + name: "绿色化工工艺项目", + description: + "基于生物基原料,采用repeal2.0可降解材料技术,开发新型环保材料。", + doId: "CSTR:13552.11.01.61.2021.742" + }, + { + name: "智能农业解决方案", + description: "利用物联网技术,实现精准农业管理,提高农作物产量。", + doId: "CSTR:14542.11.01.61.2031.528" + }, + { + name: "新能源汽车电池技术", + description: "研发高能量密度、长寿命的新型电池材料,推动电动汽车发展。", + doId: "CSTR:147842.11.04.91.2031.680" + }, + { + name: "碳捕集与封存技术", + description: "开发高效的碳捕集技术,减少工业排放,助力碳中和目标。", + doId: "CSTR:14242.19.11.61.2131.428" + } +] + +type ShowCardProps = { + loading: boolean + record: IodRegistryEntry + truncate?: boolean +} + +const ShowCard: React.FC = ({ + loading, + record, + truncate = true +}) => ( + + {loading ? ( + + ) : ( +
+

+ {record.name} +

+

+ 数字对象标识:{record.doId} +

+

+ {record.description} +

+
+ )} +
+) export const PlaygroundScene = () => { - // 模拟数据 - const data = [ - { - title: "绿色化工工艺项目", - description: - "基于生物基原料,采用repeal2.0可降解材料技术,开发新型环保材料。", - demander: "奥赛康药业 供方:美国Propella公司" - }, - { - title: "智能农业解决方案", - description: "利用物联网技术,实现精准农业管理,提高农作物产量。", - demander: "奥赛康药业 供方:美国Propella公司" - }, - { - title: "新能源汽车电池技术", - description: "研发高能量密度、长寿命的新型电池材料,推动电动汽车发展。", - demander: "奥赛康药业 供方:美国Propella公司" - }, - { - title: "碳捕集与封存技术", - description: "开发高效的碳捕集技术,减少工业排放,助力碳中和目标。", - demander: "奥赛康药业 供方:美国Propella公司" - } - ] + const { messages, iodLoading, currentMessageId, iodSearch } = + useMessageOption() - for (let i = 0; i < 10; i++) { - data.push({ - title: "开发新型电池材料", - description: "研发高能量密度、长寿命的新型电池材料,推动电动汽车发展。", - demander: "奥赛康药业 供方:美国Propella公司" - }) - } + const data = useMemo(() => { + // 确保loading状态时数据大于3 + if (iodLoading) { + return defaultData + } + + if (messages.length && iodSearch) { + const currentMessage = messages?.find( + (message) => message.id === currentMessageId + ) + return currentMessage?.iodSources.scenario.data ?? [] + } + + return defaultData + }, [currentMessageId, messages, iodLoading]) + + const title = useMemo(() => { + return messages.length > 0 ? "推荐场景" : "热点场景" + }, [messages]) const [open, setOpen] = useState(false) const showDrawer = () => { + if (iodLoading) { + return + } setOpen(true) } @@ -54,7 +108,7 @@ export const PlaygroundScene = () => { {/* 数据导航 */} +
{ height="18"> - 相关场景 + {title}
} onClick={showDrawer} /> - {/* 场景列表 */} + {/* 数据列表 */}
- {data.slice(0, 3).map((item, index) => ( - -
-

- {item.title} -

- - {item.description} - -

- {item.demander} -

-

- - 技术应用 - - - 制造业 - -

-
-
- ))} + {data.slice(0, 3).map((item, index) => { + return ( + + ) + })}
- {/* 抽屉 */}
- {data.slice(0, 3).map((item, index) => ( - -
-

- {item.title} -

- - {item.description} - -

{item.demander}

-

- - 技术应用 - - - 制造业 - -

-
-
+ {data.map((item, index) => ( + ))}
diff --git a/src/components/Common/Playground/Team.tsx b/src/components/Common/Playground/Team.tsx index afe2710..8f937aa 100644 --- a/src/components/Common/Playground/Team.tsx +++ b/src/components/Common/Playground/Team.tsx @@ -1,40 +1,85 @@ -import React, { useState } from "react" +import React, { useMemo, useState } from "react" import { DataNavigation } from "@/components/Common/DataNavigation.tsx" -import { Card, Drawer, List } from "antd" +import { Card, Drawer, Skeleton } from "antd" +import { IodRegistryEntry } from "@/types/iod.ts" + +type ShowCardProps = { + loading: boolean + record: IodRegistryEntry + truncate?: boolean +} + +const ShowCard: React.FC = ({ + loading, + record, + truncate = true +}) => ( + + {loading ? ( + + ) : ( +
+

+ {record.name} +

+

+ 数字对象标识:{record.doId} +

+

+ {record.description} +

+
+ )} +
+) + +const defaultData:IodRegistryEntry[] = [ + { + name: "上海芯飞睿科技有限公司", + description: + "上海芯飞睿科技有限公司专业从事集成化激光材料与微型化激光器件的研发", + doId: "CSTR:15552.13.05.61.2022.783" + }, + { + name: "长三角先进材料研究院", + description: "由江苏省人民政府联合中国科学院、中国钢研科技集团和中国", + doId: "CSTR:15552.12.01.11.2021.528" + }, + { + name: "清华大学智能系统实验室", + description: "清华大学", + doId: "CSTR:15552.13.04.91.2021.614", + }, +] export const PlaygroundTeam = () => { - // 模拟数据 - const data = [ - { - title: "绿色化工工艺项目", - description: - "基于生物基原料,采用repeal2.0可降解材料技术,开发新型环保材料。", - demander: "奥赛康药业 供方:美国Propella公司" - }, - { - title: "智能农业解决方案", - description: "利用物联网技术,实现精准农业管理,提高农作物产量。", - demander: "奥赛康药业 供方:美国Propella公司" - }, - { - title: "新能源汽车电池技术", - description: "研发高能量密度、长寿命的新型电池材料,推动电动汽车发展。", - demander: "奥赛康药业 供方:美国Propella公司" - }, - { - title: "碳捕集与封存技术", - description: "开发高效的碳捕集技术,减少工业排放,助力碳中和目标。", - demander: "奥赛康药业 供方:美国Propella公司" - } - ] + const { messages, iodLoading, currentMessageId, iodSearch } = useMessageOption() - for (let i = 0; i < 10; i++) { - data.push({ - title: "开发新型电池材料", - description: "研发高能量密度、长寿命的新型电池材料,推动电动汽车发展。", - demander: "奥赛康药业 供方:美国Propella公司" - }) - } + const data = useMemo(() => { + // 确保loading状态时数据大于3 + if (iodLoading) { + return defaultData + } + + if (messages.length && iodSearch) { + const currentMessage = messages?.find( + (message) => message.id === currentMessageId + ) + return currentMessage?.iodSources.organization.data ?? [] + } + + return defaultData + }, [currentMessageId, messages, iodLoading]) + + const title = useMemo(() => { + return messages.length > 0 ? "推荐团队" : "热点团队" + }, [messages]) const [open, setOpen] = useState(false) @@ -72,7 +117,7 @@ export const PlaygroundTeam = () => { p-id="7274" fill="#BE0BAC"> - 相关团队 + {title}
} onClick={showDrawer} @@ -80,59 +125,27 @@ export const PlaygroundTeam = () => { {/* 场景列表 */}
- {data.slice(0, 5).map((item, index) => ( - -
-

- {item.title} -

-

- {item.description} -

-

- - 晶体材料 - - - 中国 - -

-
-
+ {data.slice(0, 3).map((item, index) => ( + ))}
{/* 抽屉 */}
- {data.slice(0, 5).map((item, index) => ( - -
-

- {item.title} -

-

{item.description}

-

- - 晶体材料 - - - 中国 - -

-
-
+ {data.map((item, index) => ( + ))}
diff --git a/src/components/Icons/Iod.tsx b/src/components/Icons/Iod.tsx new file mode 100644 index 0000000..f79fb6b --- /dev/null +++ b/src/components/Icons/Iod.tsx @@ -0,0 +1,33 @@ +import React from "react" + +export const IodIcon = React.forwardRef< + SVGSVGElement, + React.SVGProps +>((props, ref) => { + return ( + + + + + + + ) +}) diff --git a/src/components/Layouts/Header.tsx b/src/components/Layouts/Header.tsx index 27c5ef2..bef3968 100644 --- a/src/components/Layouts/Header.tsx +++ b/src/components/Layouts/Header.tsx @@ -1,22 +1,58 @@ -import React, { useContext } from "react" +import React, { useContext, useMemo } from "react" import { HistoryContext } from "@/components/Layouts/Layout.tsx" import { PanelLeftIcon } from "lucide-react" -import { Button } from "antd" +import { Button, Tooltip } from "antd" import { PlusOutlined } from "@ant-design/icons" import { useMessageOption } from "@/hooks/useMessageOption.tsx" import { useTranslation } from "react-i18next" +import { NavLink, useLocation } from "react-router-dom" + +interface SettingIconProps {} +const SettingIcon: React.FC = () => { + return ( + + + + ) +} + +type Props = { + setOpenModelSettings: (open: boolean) => void +} + +export const Header: React.FC = ({ setOpenModelSettings }) => { + const location = useLocation() -export const Header = () => { const { show, setShow } = useContext(HistoryContext) + const showLeft = useMemo(() => { + console.log(location.pathname) + if (location.pathname.includes("/settings")) { + return true + } + return show + }, [location.pathname, show]) + const { t } = useTranslation(["option", "common", "settings"]) const { clearChat } = useMessageOption() return (
+ className={`h-[60px] absolute inset-0 pl-5 z-10 flex items-center transition-all duration-300 ease-in-out ${show && !location.pathname.includes("/settings") ? "left-[300px]" : ""}`}> {/*控制侧边栏显示隐藏与新建对话*/} - {!show && ( + {!showLeft && (
)} + {location.pathname.includes("/settings") && ( +

+ + 数联网科创智能体 + +

+ )} {/* 项目标题 */}
-

+ + + +

数联网科创智能体

+ {/*设置框*/} +
+ + + + + +
) } diff --git a/src/components/Layouts/Layout.tsx b/src/components/Layouts/Layout.tsx index 3b45f72..93f2037 100644 --- a/src/components/Layouts/Layout.tsx +++ b/src/components/Layouts/Layout.tsx @@ -37,7 +37,7 @@ export default function OptionLayout({ {/*
*/} {/*
*/} -
+
{children} {/*
*/} diff --git a/src/components/Layouts/SettingsOptionLayout.tsx b/src/components/Layouts/SettingsOptionLayout.tsx index fa76cd6..4042830 100644 --- a/src/components/Layouts/SettingsOptionLayout.tsx +++ b/src/components/Layouts/SettingsOptionLayout.tsx @@ -1,17 +1,18 @@ import { + BlocksIcon, BookIcon, BrainCircuitIcon, - OrbitIcon, - ShareIcon, - BlocksIcon, - InfoIcon, - CombineIcon, ChromeIcon, - CpuIcon + CombineIcon, + CpuIcon, + InfoIcon, + OrbitIcon, + ShareIcon } from "lucide-react" import { useTranslation } from "react-i18next" import { Link, useLocation } from "react-router-dom" import { OllamaIcon } from "../Icons/Ollama" +import { IodIcon } from "../Icons/Iod.tsx" import { BetaTag } from "../Common/Beta" function classNames(...classes: string[]) { @@ -82,6 +83,12 @@ export const SettingsLayout = ({ children }: { children: React.ReactNode }) => { icon={OllamaIcon} current={location.pathname} /> + {import.meta.env.BROWSER === "chrome" && ( { const drop = React.useRef(null) const [dropedFile, setDropedFile] = React.useState() @@ -146,13 +145,14 @@ export const Playground = () => { dropState === "dragging" ? "bg-gray-100 dark:bg-gray-800" : "" } bg-white dark:bg-[#171717]`}> -
+
+ className="custom-scrollbar flex h-auto w-full flex-col items-center px-5">
-
+
{!isAtBottom && (
{/*auto_530px_165px*/} - {messages.length && ( -
-
- -
-
- - -
-
- -
+
+
+
- )} +
+ + +
+
+ +
+
) } diff --git a/src/components/Option/Playground/PlaygroundChat.tsx b/src/components/Option/Playground/PlaygroundChat.tsx index ac13a6b..9025350 100644 --- a/src/components/Option/Playground/PlaygroundChat.tsx +++ b/src/components/Option/Playground/PlaygroundChat.tsx @@ -52,7 +52,7 @@ export const PlaygroundChat = () => { /> ))}
- {/*
*/} + {messages.length !== 0 &&
} { }) function handleQuestion(message: string) { - void sendMessage({ message, image: "" }) + void sendMessage({ message, image: "", isRegenerate: true }) } return ( -
+
{/* 标题区域 */}

{ />

-
+
{ stopListening() @@ -304,33 +302,38 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
{!selectedKnowledge && (
- -
- - setWebSearch(e)} - checkedChildren={t("form.webSearch.on")} - unCheckedChildren={t("form.webSearch.off")} - /> -
-
- -
- - setIodSearch(e)} - checkedChildren={t("form.webSearch.on")} - unCheckedChildren={t("form.webSearch.off")} - /> -
-
-
+ {/* 展示隐藏深度搜索*/} + +
+ + setWebSearch(e)} + checkedChildren={t("form.webSearch.on")} + unCheckedChildren={t("form.webSearch.off")} + /> +
+
+ +
+ + setIodSearch(e)} + checkedChildren={t("form.webSearch.on")} + unCheckedChildren={t("form.webSearch.off")} + /> +
+
+
)}
@@ -357,7 +360,10 @@ export const PlaygroundForm = ({ dropedFile }: Props) => { if (isListening) { stopSpeechRecognition() } else { - console.log("开始语音识别,语言:", speechToTextLanguage); + console.log( + "开始语音识别,语言:", + speechToTextLanguage + ) resetTranscript() startListening({ continuous: true, diff --git a/src/components/Option/Settings/iod.tsx b/src/components/Option/Settings/iod.tsx new file mode 100644 index 0000000..70cf770 --- /dev/null +++ b/src/components/Option/Settings/iod.tsx @@ -0,0 +1,54 @@ +import { useTranslation } from "react-i18next" +import TextArea from "antd/es/input/TextArea" +import { useEffect, useState } from "react" + + +export const IodApp = () => { + const { t } = useTranslation("settings") + + + const [connectVal, setConnectVal] = useState('') + + const setConnectValWrap = (val: string) => { + localStorage.setItem("iod-connect", val) + setConnectVal(val) + } + useEffect(() => { + const val = localStorage.getItem("iod-connect") + const defaultVal = { + gatewayUrl: "tcp://reg01.public.internetofdata.cn:21037", + registry: "data/Registry", + localRepository: "data/Repository", + doBrowser: "http://021.node.internetapi.cn:21030/SCIDE/SCManager" + } + if (!val) { + localStorage.setItem( + "iod-connect", + JSON.stringify(defaultVal) + ) + setConnectVal(JSON.stringify(defaultVal, null, 2)) + return + } + try { + const val = localStorage.getItem("iod-connect") + setConnectVal(JSON.stringify(JSON.parse(val), null, 2)) + } catch (e) { + setConnectVal(JSON.stringify(defaultVal, null, 2)) + } + }, []) + + return ( +
+
+

+ {t("iodSettings.heading")} +

+
+
+
+ 连接配置 +