Browse Source

添加antd组件库

李富豪 1 year ago
parent
commit
b9fb19d18a
3 changed files with 20 additions and 9 deletions
  1. 2 2
      app/client/platforms/bigmodel.ts
  2. 14 3
      app/components/markdown.tsx
  3. 4 4
      app/page.tsx

+ 2 - 2
app/client/platforms/bigmodel.ts

@@ -18,7 +18,7 @@ export class BigModelApi implements LLMApi {
   public apiPath: string;
 
   constructor() {
-    this.apiPath = 'http://192.168.3.42:8091/bigmodel/api/model-api/1833684324797624321/sse-invoke';
+    this.apiPath = 'http://192.168.3.42:8091/bigmodel/api/model-api/1833110111435071488/sse-invoke';
   }
 
   async chat(options: ChatOptions) {
@@ -42,7 +42,7 @@ export class BigModelApi implements LLMApi {
     const params: any = {
       prompt: userMessages,
       // 进阶配置
-      request_id: 'jkec2024',
+      request_id: 'jkec2024-knowledge-base',
       returnType: undefined,
       knowledge_ids: undefined,
       document_ids: undefined,

+ 14 - 3
app/components/markdown.tsx

@@ -1,5 +1,5 @@
 import ReactMarkdown from "react-markdown";
-import "katex/dist/katex.min.css";
+import { Image } from "antd";
 import RemarkMath from "remark-math";
 import RemarkBreaks from "remark-breaks";
 import RehypeKatex from "rehype-katex";
@@ -8,7 +8,6 @@ import RehypeHighlight from "rehype-highlight";
 import { useRef, useState, RefObject, useEffect, useMemo } from "react";
 import { copyToClipboard, useWindowSize } from "../utils";
 import mermaid from "mermaid";
-
 import LoadingIcon from "../icons/three-dots.svg";
 import React from "react";
 import { useDebouncedCallback } from "use-debounce";
@@ -16,6 +15,8 @@ import { showImageModal, FullScreen } from "./ui-lib";
 import { ArtifactsShareButton, HTMLPreview } from "./artifacts";
 import { Plugin } from "../constant";
 import { useChatStore } from "../store";
+import "katex/dist/katex.min.css";
+
 export function Mermaid(props: { code: string }) {
   const ref = useRef<HTMLDivElement>(null);
   const [hasError, setHasError] = useState(false);
@@ -209,6 +210,7 @@ function _MarkDownContent(props: { content: string }) {
           },
         ],
       ]}
+      // 控制不同标签的显示样式
       components={{
         pre: PreCode,
         p: (pProps) => <p {...pProps} dir="auto" />,
@@ -218,10 +220,19 @@ function _MarkDownContent(props: { content: string }) {
           const target = isInternal ? "_self" : aProps.target ?? "_blank";
           return <a {...aProps} target={target} />;
         },
+        img: ({ src, alt }) => (
+          <Image
+            src={src}
+            alt={alt}
+            preview={{
+              mask: null
+            }}
+          />
+        ),
       }}
     >
       {escapedContent}
-    </ReactMarkdown>
+    </ReactMarkdown >
   );
 }
 

+ 4 - 4
app/page.tsx

@@ -1,20 +1,20 @@
+import { ConfigProvider } from "antd";
 import { Analytics } from "@vercel/analytics/react";
-
 import { Home } from "./components/home";
-
 import { getServerSideConfig } from "./config/server";
+import zhCN from 'antd/locale/zh_CN';
 
 const serverConfig = getServerSideConfig();
 
 export default async function App() {
   return (
-    <>
+    <ConfigProvider locale={zhCN}>
       <Home />
       {serverConfig?.isVercel && (
         <>
           <Analytics />
         </>
       )}
-    </>
+    </ConfigProvider>
   );
 }