Explorar o código

fix: 调整AI配置

liaojiaxing hai 2 semanas
pai
achega
8a520c80d3
Modificáronse 5 ficheiros con 124 adicións e 20 borrados
  1. 1 1
      .umirc.ts
  2. 0 2
      src/hooks/useChat.ts
  3. 36 9
      src/layouts/index.tsx
  4. 18 0
      src/pages/ai/data.tsx
  5. 69 8
      src/pages/ai/index.tsx

+ 1 - 1
.umirc.ts

@@ -6,7 +6,7 @@ export default defineConfig({
   outputPath: "marketplace",
   esbuildMinifyIIFE: true,
   favicons: [],
-  styles: ["//at.alicdn.com/t/c/font_4840729_yq3mj2py5j.css"],
+  styles: ["//at.alicdn.com/t/c/font_4840729_qt3oesd105.css"],
   scripts: ["//at.alicdn.com/t/c/font_4840729_qpwqs1eruu.js"],
   model: {},
   title: "易码工坊",

+ 0 - 2
src/hooks/useChat.ts

@@ -238,10 +238,8 @@ export function useChat({ app_name, onSuccess, onUpdate, onError }: ChatProps) {
         } else {
           // 接口异常处理
           response.json().then(res => {
-            if(res.code === 0 ) {
               onError?.(Error(res?.error || '请求失败'));
               cancel();
-            }
           });
         }
       } catch (error) {

+ 36 - 9
src/layouts/index.tsx

@@ -27,10 +27,26 @@ export default function Layout() {
   };
 
   const handleToSchool = () => {
-    const  url  =  'https://college.shalu.com/Views/Account/SSOIndex.html?system=design&token=' + localStorage.getItem('token_a');
+    const url =
+      "https://college.shalu.com/Views/Account/SSOIndex.html?system=design&token=" +
+      localStorage.getItem("token_a");
     window.open(url);
   };
 
+  const handleToGenerate = () => {
+    window.open(
+      `https://design.shalu.com/App/SysPages/views/system/appgenerate/index.html`,
+      "_blank"
+    );
+  };
+
+  const handleToTool = () => {
+    window.open(
+      `https://design.shalu.com/Views/Tools/Index.html?t=${new Date().getTime()}`,
+      "_blank"
+    );
+  };
+
   return (
     <ConfigProvider locale={zhCN}>
       <div>
@@ -58,12 +74,20 @@ export default function Layout() {
               <i className="iconfont icon-shuben-book3 text-12px mr-4px" />
               沙鲁学院
             </li>
+            <li className={`nav-button`} onClick={handleToTool}>
+              <i className="iconfont icon-gongju1 text-12px mr-4px" />
+              工具下载
+            </li>
             <Link to="/ai" target="_blank" className="decoration-none">
               <li className={`nav-button`}>
                 <i className="iconfont icon-AI1 text-12px mr-4px" />
                 AI助手
               </li>
             </Link>
+            <li className={`nav-button`} onClick={handleToGenerate}>
+              <i className="iconfont icon-AIyingyongguangchang-biaoti-AIshengtai text-12px mr-4px" />
+              AI生成应用
+            </li>
           </ul>
 
           <div className="right w-170px text-right">
@@ -96,14 +120,17 @@ export default function Layout() {
                 </span>
               </Dropdown>
             ) : (
-              <Button
-                className="ml-4px"
-                size="small"
-                onClick={handleLogin}
-                shape="round"
-              >
-                登录
-              </Button>
+              <div className="flex items-center gap-12px">
+                <Avatar size={32} icon={<UserOutlined />} />
+                <Button
+                  className="ml-4px"
+                  size="small"
+                  onClick={handleLogin}
+                  shape="round"
+                >
+                  登录
+                </Button>
+              </div>
             )}
           </div>
         </div>

+ 18 - 0
src/pages/ai/data.tsx

@@ -166,4 +166,22 @@ export const assistantList: AgentItem[] = [
       },
     ]
   },
+  {
+    key: "app_generate",
+    name: "指令生成",
+    icon: icon1,
+    description: "我可以帮你快速创建应用~",
+    promptsItems: [
+      {
+        key: "1",
+        icon: <SmileOutlined style={{ color: "#52C41A" }} />,
+        description: "创建一个用户管理系统",
+      },
+      {
+        key: "2",
+        icon: <SmileOutlined style={{ color: "#52C41A" }} />,
+        description: "创建一个订单管理系统",
+      },
+    ]
+  },
 ];

+ 69 - 8
src/pages/ai/index.tsx

@@ -1,4 +1,4 @@
-import React, { useState } from "react";
+import { useState, useEffect } from "react";
 import Assistant from "./Assistant";
 import data from "@emoji-mart/data";
 import { init } from "emoji-mart";
@@ -6,11 +6,31 @@ import styles from "./index.less";
 import "./index.less";
 import logo from "@/assets/shalu-new1.png";
 import { assistantList } from "./data";
+import { useModel } from "umi";
+import { Avatar, Button, Dropdown } from "antd";
+import { DownOutlined, UserOutlined } from "@ant-design/icons";
 
 init({ data });
 
 export default () => {
   const [active, setActive] = useState(assistantList[0].key);
+  const { userInfo, handleLogout, checkUserInfo } = useModel("userModel");
+
+  const handleLogin = () => {
+    window.open(
+      `/Views/Account/Index.html?ReturnUrl=${window.location.href}`,
+      "_self"
+    );
+  };
+
+  useEffect(() => {
+    checkUserInfo();
+  }, []);
+
+  const handleToManagement = () => {
+    window.open(`/Views/Home/Index.html`);
+  };
+
   return (
     <div className="flex h-full bg-gray-100 border-t border-gray-200 overflow-hidden">
       <div className="w-fit sm:w-[216px] shrink-0 pt-6 px-4 border-gray-200 cursor-pointer">
@@ -28,9 +48,7 @@ export default () => {
             {assistantList.map((item, index) => (
               <div
                 key={index}
-                className={
-                  `flex h-8 items-center justify-between mobile:justify-center px-2 mobile:px-1 rounded-lg text-sm font-normal ${active === item.key ? styles.active : " hover:bg-gray-200"}`
-                }
+                className={`flex h-8 items-center justify-between mobile:justify-center px-2 mobile:px-1 rounded-lg text-sm font-normal ${active === item.key ? styles.active : " hover:bg-gray-200"}`}
                 onClick={() => setActive(item.key)}
               >
                 <div className="flex items-center space-x-2 w-0 grow">
@@ -38,7 +56,7 @@ export default () => {
                     className="flex items-center justify-center relative rounded-lg grow-0 shrink-0 overflow-hidden w-6 h-6 text-base"
                     style={{ background: "rgb(213, 245, 246)" }}
                   >
-                    <img className="w-full h-full" src={item.icon}/>
+                    <img className="w-full h-full" src={item.icon} />
                   </span>
                   <div
                     className="overflow-hidden text-ellipsis whitespace-nowrap"
@@ -56,15 +74,58 @@ export default () => {
             ))}
           </div>
           {/* 用户信息 */}
-          <div className="w-full h-60px bg-gray-200">
-
+          <div className="w-full h-30px">
+            {userInfo ? (
+              <Dropdown
+                menu={{
+                  items: [
+                    {
+                      key: "1",
+                      label: <span>管理后台</span>,
+                      onClick: handleToManagement,
+                    },
+                    {
+                      key: "2",
+                      label: <span>退出</span>,
+                      onClick: handleLogout,
+                    },
+                  ],
+                }}
+                trigger={["click"]}
+                placement="bottomRight"
+                arrow
+              >
+                <span>
+                  <Avatar size={32} icon={<UserOutlined />} />
+                  <span className="ml-4px text-12px text-text-secondary cursor-pointer truncate">
+                    {userInfo.account}
+                  </span>
+                  <DownOutlined className="ml-4px text-12px text-text-secondary" />
+                </span>
+              </Dropdown>
+            ) : (
+              <div className="flex items-center gap-12px">
+                <Avatar size={32} icon={<UserOutlined />} />
+                <Button
+                  className="ml-4px"
+                  size="small"
+                  onClick={handleLogin}
+                  shape="round"
+                >
+                  登录
+                </Button>
+              </div>
+            )}
           </div>
         </div>
       </div>
       <div className="grow w-0">
         <div className="h-full py-2 pl-0 pr-2 sm:p-2">
           <div className="h-full flex bg-white rounded-2xl shadow-md overflow-hidden false">
-            <Assistant key={active} agent={assistantList.find(item => item.key === active)}/>
+            <Assistant
+              key={active}
+              agent={assistantList.find((item) => item.key === active)}
+            />
           </div>
         </div>
       </div>