Explorar el Código

style: 调整样式等

liaojiaxing hace 1 mes
padre
commit
5f772c1b90

+ 5 - 2
src/components/ItemCard.tsx

@@ -9,7 +9,10 @@ export default function AppItem({
   onClick: (id: string) => void;
 }) {
   return (
-    <div className="relative overflow-hidden pb-2 group col-span-1 bg-white border-2 border-solid border-transparent rounded-lg shadow-sm flex flex-col transition-all duration-200 ease-in-out cursor-pointer hover:shadow-lg">
+    <div  
+      className="relative overflow-hidden pb-2 group col-span-1 bg-white border-2 border-solid border-transparent rounded-lg shadow-sm flex flex-col transition-all duration-200 ease-in-out cursor-pointer hover:shadow-lg"
+      onClick={() => onClick(data.id)}
+    >
       <div className="flex pt-[14px] px-[14px] pb-3 h-[66px] items-center gap-3 grow-0 shrink-0">
         <div className="relative shrink-0">
           <span
@@ -48,7 +51,7 @@ export default function AppItem({
             >
               <path d="M9 2V4H5L4.999 14H18.999L19 4H15V2H20C20.5523 2 21 2.44772 21 3V21C21 21.5523 20.5523 22 20 22H4C3.44772 22 3 21.5523 3 21V3C3 2.44772 3.44772 2 4 2H9ZM18.999 16H4.999L5 20H19L18.999 16ZM17 17V19H15V17H17ZM13 2V7H16L12 11L8 7H11V2H13Z"></path>
             </svg>
-            <div className="system-xs-regular">339</div>
+            <div className="system-xs-regular">{data?.viewCount || 0}</div>
           </div>
           <div className="mx-2 text-text-quaternary system-xs-regular">·</div>
           <div className="flex flex-wrap space-x-2 h-4 overflow-hidden">

+ 4 - 0
src/components/ai/index.less

@@ -39,4 +39,8 @@
     padding-left: 20px;
     border-left: solid 4px #ddd;
   }
+
+  img, video {
+    max-width: 100%;
+  }
 }

+ 6 - 1
src/hooks/useChat.ts

@@ -2,6 +2,7 @@ import { useXAgent, XStream } from "@ant-design/x";
 import { useEffect, useRef, useState } from "react";
 import { useSessionStorageState } from "ahooks";
 import { GetSessionList, GetSessionMessageList } from "@/api/ai";
+import { getDateGroupString } from "@/utils";
 
 import type { ConversationsProps } from "@ant-design/x";
 import type { ReactNode } from "react";
@@ -54,6 +55,7 @@ const defaultConversation = {
   // 会话id
   key: "1",
   label: "新的对话",
+  group: '今日'
 };
 
 export function useChat({ app_name, onSuccess, onUpdate, onError }: ChatProps) {
@@ -111,6 +113,7 @@ export function useChat({ app_name, onSuccess, onUpdate, onError }: ChatProps) {
               ...item,
               key: item.sessionId,
               label: item.name,
+              group: getDateGroupString(item.updateTime)
             })),
           ]);
         } else {
@@ -120,6 +123,7 @@ export function useChat({ app_name, onSuccess, onUpdate, onError }: ChatProps) {
               ...item,
               key: item.sessionId,
               label: item.name,
+              group: getDateGroupString(item.updateTime)
             })),
           ]);
         }
@@ -257,7 +261,7 @@ export function useChat({ app_name, onSuccess, onUpdate, onError }: ChatProps) {
    * @param chat_query 对话内容
    */
   const onRequest = (chat_query: string) => {
-    setConversationList((list) => {
+    activeConversation === '1' && setConversationList((list) => {
       return list?.map((item) => {
         return {
           ...item,
@@ -306,6 +310,7 @@ export function useChat({ app_name, onSuccess, onUpdate, onError }: ChatProps) {
    */
   const cancel = () => {
     abortController.current?.abort();
+    setLoading(false);
   };
 
   /**

+ 4 - 2
src/pages/ai/Assistant.tsx

@@ -44,6 +44,7 @@ import type { AgentItem } from "./data";
 import MarkdownViewer from "@/components/ai/MarkdownViewer";
 import { ChangeSessionName, DeleteSession } from "@/api/ai";
 import InfiniteScroll from "react-infinite-scroll-component";
+import "./assistant.less";
 
 type AssistantProps = {
   agent?: AgentItem;
@@ -55,7 +56,7 @@ const roles: GetProp<typeof Bubble.List, "roles"> = {
     placement: "start",
     avatar: {
       icon: <i className="iconfont icon-AI1" />,
-      style: { background: "#fde3cf" },
+      style: { background: "#3450ec" },
     },
     // typing: { step: 5, interval: 20 },
     loadingRender: () => (
@@ -425,6 +426,7 @@ export default (props: AssistantProps) => {
                 >
                   <Spin spinning={loadingSession} className="flex-col">
                     <Conversations
+                      groupable
                       style={{ width: 200 }}
                       activeKey={activeConversation}
                       onActiveChange={changeConversation}
@@ -473,7 +475,7 @@ export default (props: AssistantProps) => {
                   </>
                 ) : (
                   <Bubble.List
-                    style={{ maxHeight: contentHeight }}
+                    style={{ maxHeight: contentHeight, padding: '0 20px' }}
                     autoScroll
                     roles={roles}
                     items={messages}

+ 11 - 0
src/pages/ai/assistant.less

@@ -0,0 +1,11 @@
+li {
+  &::marker {
+    display: none;
+  }
+}
+.ant-conversations {
+  padding: 12px 0;
+  .ant-conversations-list {
+    padding: 0;
+  }
+}

+ 5 - 1
src/pages/ai/index.tsx

@@ -23,7 +23,7 @@ export default () => {
           </p>
           <div
             className="mt-3 space-y-2 overflow-y-auto overflow-x-hidden"
-            style={{ height: "calc(-140px + 100vh)" }}
+            style={{ height: "calc(-200px + 100vh)" }}
           >
             {assistantList.map((item, index) => (
               <div
@@ -55,6 +55,10 @@ export default () => {
               </div>
             ))}
           </div>
+          {/* 用户信息 */}
+          <div className="w-full h-60px bg-gray-200">
+
+          </div>
         </div>
       </div>
       <div className="grow w-0">

+ 13 - 9
src/pages/detail/index.tsx

@@ -9,6 +9,7 @@ import {
   Breadcrumb,
   message,
   notification,
+  Tooltip,
 } from "antd";
 import type { BreadcrumbProps } from "antd";
 import { useMemo, useState } from "react";
@@ -71,7 +72,7 @@ export default function detail() {
         //     <span className="m-l-4px">返回</span>
         //   </a>
         // ),
-        title: '全部'
+        title: "全部",
       },
       { key: "current", title: data?.result.name },
     ];
@@ -116,7 +117,7 @@ export default function detail() {
                     >
                       <path d="M9 2V4H5L4.999 14H18.999L19 4H15V2H20C20.5523 2 21 2.44772 21 3V21C21 21.5523 20.5523 22 20 22H4C3.44772 22 3 21.5523 3 21V3C3 2.44772 3.44772 2 4 2H9ZM18.999 16H4.999L5 20H19L18.999 16ZM17 17V19H15V17H17ZM13 2V7H16L12 11L8 7H11V2H13Z"></path>
                     </svg>
-                    <div className="system-xs-regular">使用量 339</div>
+                    <div className="system-xs-regular">浏览量 {data?.result?.viewCount || 0}</div>
                   </div>
                   <div className="mx-2 text-text-quaternary system-xs-regular">
                     ·
@@ -142,13 +143,16 @@ export default function detail() {
               </div>
             </div>
             <div className="head-right flex flex-col justify-center items-center">
-              <Button
-                type="primary"
-                className="w-full mb-24px"
-                onClick={handleToApp}
-              >
-                在线体验
-              </Button>
+              <Tooltip title={!data?.result?.isCanUseTrial ? "暂不支持体验~" : ""}>
+                <Button
+                  type="primary"
+                  className="w-full mb-24px"
+                  onClick={handleToApp}
+                  disabled={!data?.result?.isCanUseTrial}
+                >
+                  在线体验
+                </Button>
+              </Tooltip>
               <Button className="w-full" onClick={() => setShowAdvisory(true)}>
                 购买咨询
               </Button>

+ 33 - 2
src/utils/index.ts

@@ -4,9 +4,40 @@ export const customUploadRequest = async (options: any) => {
   try {
     const formData = new FormData();
     formData.append("file", options.file);
-    const res =await UploadFile(formData);
+    const res = await UploadFile(formData);
     options.onSuccess(res.result?.[0]);
   } catch (error) {
     options.onError(new Error("上传失败"));
   }
-};
+};
+
+/**
+ * 获取日期格式化分组
+ * @param dateVal 日期
+ * @returns 
+ */
+export function getDateGroupString(dateVal: Date | string): string {
+  const normalizeDate = (date: Date | string): Date => {
+    const d = new Date(date);
+    d.setHours(0, 0, 0, 0);
+    return d;
+  };
+
+  const now = normalizeDate(new Date()); // 当前日期归一化
+
+  const itemDate = normalizeDate(new Date(dateVal));
+  const diffTime = now.getTime() - itemDate.getTime();
+  const diffDays = Math.floor(diffTime / (1000 * 3600 * 24));
+
+  if (diffDays === 0) {
+    return "今日";
+  } else if (diffDays === 1) {
+    return "昨日";
+  } else if (diffDays <= 6) {
+    return "7日内";
+  } else if (diffDays <= 29) {
+    return "30日内";
+  } else {
+    return "更久~";
+  }
+}