李富豪 1 рік тому
батько
коміт
d163239016

+ 2 - 4
app/components/chat.module.scss

@@ -296,7 +296,7 @@
   cursor: pointer;
 
   &:hover {
-    text-decoration: underline;
+    text-decoration: none;
   }
 }
 
@@ -458,7 +458,7 @@
     width: $calc-image-width;
     height: $calc-image-width;
   }
-  
+
   .chat-message-item-image {
     max-width: calc(100vw/3*2);
   }
@@ -605,8 +605,6 @@
   min-height: 68px;
 }
 
-.chat-input:focus {}
-
 .chat-input-send {
   background-color: var(--primary);
   color: white;

+ 48 - 25
app/components/chat.tsx

@@ -37,6 +37,7 @@ import AutoIcon from "../icons/auto.svg";
 import BottomIcon from "../icons/bottom.svg";
 import StopIcon from "../icons/pause.svg";
 import RobotIcon from "../icons/robot.svg";
+import AddIcon from "../icons/add.svg";
 import SizeIcon from "../icons/size.svg";
 import PluginIcon from "../icons/plugin.svg";
 
@@ -174,7 +175,8 @@ export function SessionConfigModel(props: { onClose: () => void }) {
 }
 
 // 提示词
-const CallWord: React.FC = () => {
+const CallWord = (props: { setUserInput: (value: string) => void }) => {
+  const { setUserInput } = props
   const list = [
     {
       title: '信息公布',
@@ -222,7 +224,7 @@ const CallWord: React.FC = () => {
               fontSize: 12
             }}
             onClick={() => {
-
+              setUserInput(item.text)
             }}
           >
             {item.title}
@@ -485,6 +487,7 @@ function useScrollToBottom(
 }
 
 export function ChatActions(props: {
+  setUserInput: (value: string) => void;
   uploadImage: () => void;
   setAttachImages: (images: string[]) => void;
   setUploading: (uploading: boolean) => void;
@@ -578,13 +581,13 @@ export function ChatActions(props: {
 
   return (
     <div className={styles["chat-input-actions"]}>
-      {couldStop && (
+      {/* {couldStop && (
         <ChatAction
           onClick={stopAll}
           text={Locale.Chat.InputActions.Stop}
           icon={<StopIcon />}
         />
-      )}
+      )} */}
 
       {!props.hitBottom && (
         <ChatAction
@@ -594,12 +597,6 @@ export function ChatActions(props: {
         />
       )}
 
-      <ChatAction
-        onClick={() => { }}
-        text='新建对话'
-        icon={<RobotIcon />}
-      />
-
       {/* {props.hitBottom && (
         <ChatAction
           onClick={props.showPromptModal}
@@ -632,13 +629,13 @@ export function ChatActions(props: {
         }
       /> */}
 
-      <CallWord />
+      <CallWord setUserInput={props.setUserInput} />
 
-      <ChatAction
+      {/* <ChatAction
         onClick={props.showPromptHints}
         text={Locale.Chat.InputActions.Prompt}
         icon={<PromptIcon />}
-      />
+      /> */}
 
       {/* <ChatAction
         onClick={() => {
@@ -1003,7 +1000,6 @@ function _Chat() {
 
   // check if should send message
   const onInputKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
-    // if ArrowUp and no userInput, fill with last input
     if (
       e.key === "ArrowUp" &&
       userInput.length <= 0 &&
@@ -1018,6 +1014,7 @@ function _Chat() {
       e.preventDefault();
     }
   };
+
   const onRightClick = (e: any, message: ChatMessage) => {
     // copy to clipboard
     if (selectOrCopy(e.currentTarget, getMessageTextContent(message))) {
@@ -1378,7 +1375,7 @@ function _Chat() {
   return (
     <div className={styles.chat} key={session.id}>
       <div className="window-header" data-tauri-drag-region>
-        {isMobileScreen && (
+        {/* {isMobileScreen && (
           <div className="window-actions">
             <div className={"window-action-button"}>
               <IconButton
@@ -1389,12 +1386,12 @@ function _Chat() {
               />
             </div>
           </div>
-        )}
+        )} */}
 
         <div className={`window-header-title ${styles["chat-body-title"]}`}>
           <div
             className={`window-header-main-title ${styles["chat-body-main-title"]}`}
-            onClickCapture={() => setIsEditingMessage(true)}
+          // onClickCapture={() => setIsEditingMessage(true)}
           >
             建科招聘智能助理
           </div>
@@ -1403,6 +1400,16 @@ function _Chat() {
           </div>
         </div>
         <div className="window-actions">
+          <IconButton
+            icon={<AddIcon />}
+            bordered
+            title='新建对话'
+            aria='新建对话'
+            onClick={() => {
+              localStorage.clear()
+              location.reload()
+            }}
+          />
           {/* {!isMobileScreen && (
             <div className="window-action-button">
               <IconButton
@@ -1424,7 +1431,7 @@ function _Chat() {
               }}
             />
           </div> */}
-          {showMaxIcon && (
+          {/* {showMaxIcon && (
             <div className="window-action-button">
               <IconButton
                 icon={config.tightBorder ? <MinIcon /> : <MaxIcon />}
@@ -1438,7 +1445,7 @@ function _Chat() {
                 }}
               />
             </div>
-          )}
+          )} */}
         </div>
 
         {/* <PromptToast
@@ -1516,7 +1523,22 @@ function _Chat() {
                       </div> */}
                       {isUser ? (
                         // 在这里换头像
-                        <Avatar avatar={config.avatar} />
+                        <div style={{ position: 'relative' }}>
+                          <MaskAvatar
+                            avatar={session.mask.avatar}
+                          />
+                          <div
+                            style={{
+                              position: 'absolute',
+                              zIndex: 2,
+                              top: '50%',
+                              left: '50%',
+                              transform: ' translate(-50%, -50%)',
+                              fontSize: 14
+                            }}>
+                            我
+                          </div>
+                        </div>
                       ) : (
                         <>
                           {["system"].includes(message.role) ? (
@@ -1532,7 +1554,7 @@ function _Chat() {
                         </>
                       )}
                     </div>
-                    {showActions && (
+                    {/* {showActions && (
                       <div className={styles["chat-message-actions"]}>
                         <div className={styles["chat-input-actions"]}>
                           {message.streaming ? (
@@ -1573,7 +1595,7 @@ function _Chat() {
                           )}
                         </div>
                       </div>
-                    )}
+                    )} */}
                   </div>
                   {showTyping && (
                     <div className={styles["chat-message-status"]}>
@@ -1589,7 +1611,7 @@ function _Chat() {
                         message.content.length === 0 &&
                         !isUser
                       }
-                      onContextMenu={(e) => onRightClick(e, message)}
+                      // onContextMenu={(e) => onRightClick(e, message)}
                       onDoubleClickCapture={() => {
                         if (!isMobileScreen) return;
                         setUserInput(getMessageTextContent(message));
@@ -1644,9 +1666,10 @@ function _Chat() {
       </div>
 
       <div className={styles["chat-input-panel"]}>
-        <PromptHints prompts={promptHints} onPromptSelect={onPromptSelect} />
+        {/* <PromptHints prompts={promptHints} onPromptSelect={onPromptSelect} /> */}
 
         <ChatActions
+          setUserInput={setUserInput}
           uploadImage={uploadImage}
           setAttachImages={setAttachImages}
           setUploading={setUploading}
@@ -1743,4 +1766,4 @@ export function Chat() {
   const chatStore = useChatStore();
   const sessionIndex = chatStore.currentSessionIndex;
   return <_Chat key={sessionIndex}></_Chat>;
-}
+}

+ 4 - 5
app/components/exporter.tsx

@@ -118,9 +118,8 @@ function Steps<
           return (
             <div
               key={i}
-              className={`${styles["step"]} ${
-                styles[i <= props.index ? "step-finished" : ""]
-              } ${i === props.index && styles["step-current"]} clickable`}
+              className={`${styles["step"]} ${styles[i <= props.index ? "step-finished" : ""]
+                } ${i === props.index && styles["step-current"]} clickable`}
               onClick={() => {
                 props.onStepChange?.(i);
               }}
@@ -633,8 +632,8 @@ export function MarkdownPreviewer(props: {
         return m.role === "user"
           ? `## ${Locale.Export.MessageFromYou}:\n${getMessageTextContent(m)}`
           : `## ${Locale.Export.MessageFromChatGPT}:\n${getMessageTextContent(
-              m,
-            ).trim()}`;
+            m,
+          ).trim()}`;
       })
       .join("\n\n");
 

+ 2 - 3
app/components/home.tsx

@@ -7,7 +7,7 @@ import { useState, useEffect } from "react";
 import styles from "./home.module.scss";
 
 import BotIcon from "../icons/bot.svg";
-import LoadingIcon from "../icons/three-dots.svg";
+import loadingIcon from "../icons/loading.gif";
 
 import { getCSSVar, useMobileScreen } from "../utils";
 
@@ -33,8 +33,7 @@ import { useAccessStore } from "../store";
 export function Loading(props: { noLogo?: boolean }) {
   return (
     <div className={styles["loading-content"] + " no-dark"}>
-      {!props.noLogo && <BotIcon />}
-      <LoadingIcon />
+      {!props.noLogo && <img src={loadingIcon.src} />}
     </div>
   );
 }

+ 1 - 19
app/global.d.ts

@@ -1,5 +1,6 @@
 declare module "*.jpg";
 declare module "*.png";
+declare module '*.gif';
 declare module "*.woff2";
 declare module "*.woff";
 declare module "*.ttf";
@@ -9,22 +10,3 @@ declare module "*.scss" {
 }
 
 declare module "*.svg";
-
-declare interface Window {
-  __TAURI__?: {
-    writeText(text: string): Promise<void>;
-    invoke(command: string, payload?: Record<string, unknown>): Promise<any>;
-    dialog: {
-      save(options?: Record<string, unknown>): Promise<string | null>;
-    };
-    fs: {
-      writeBinaryFile(path: string, data: Uint8Array): Promise<void>;
-      writeTextFile(path: string, data: string): Promise<void>;
-    };
-    notification:{
-      requestPermission(): Promise<Permission>;
-      isPermissionGranted(): Promise<boolean>;
-      sendNotification(options: string | Options): void;
-    };
-  };
-}

BIN
app/icons/loading.gif


+ 2 - 4
app/locales/cn.ts

@@ -6,9 +6,7 @@ const isApp = !!getClientConfig()?.isApp;
 const cn = {
   WIP: "该功能仍在开发中……",
   Error: {
-    Unauthorized: isApp
-      ? "检测到无效 API Key,请前往[设置](/#/settings)页检查 API Key 是否配置正确。"
-      : "访问密码不正确或为空,请前往[登录](/#/auth)页输入正确的访问密码,或者在[设置](/#/settings)页填入你自己的 OpenAI API Key。",
+    Unauthorized: "检测到无效 API Key,请联系管理员重新配置",
   },
   Auth: {
     Title: "需要密码",
@@ -73,7 +71,7 @@ const cn = {
       if (submitKey === String(SubmitKey.Enter)) {
         inputHints += ",Shift + Enter 换行";
       }
-      return inputHints + ",/ 触发补全,: 触发命令";
+      return inputHints;
     },
     Send: "发送",
     Config: {

+ 2 - 1
app/store/chat.ts

@@ -548,7 +548,8 @@ export const useChatStore = createPersistStore(
           return;
         }
 
-        const providerName = modelConfig.providerName;
+        // 固定使用大模型
+        const providerName = 'BigModel' as ServiceProvider;
         const api: ClientApi = getClientApi(providerName);
 
         // remove error messages if any

+ 1 - 1
app/store/config.ts

@@ -36,7 +36,7 @@ export const DEFAULT_CONFIG = {
   fontSize: 14,
   fontFamily: "",
   theme: Theme.Auto as Theme,
-  tightBorder: !!config?.isApp,
+  tightBorder: true,
   sendPreviewBubble: true,
   enableAutoGenerateTitle: true,
   sidebarWidth: DEFAULT_SIDEBAR_WIDTH,

+ 2 - 2
app/store/update.ts

@@ -94,14 +94,14 @@ export const useUpdateStore = createPersistStore(
           // Check if notification permission is granted
           await window.__TAURI__?.notification
             .isPermissionGranted()
-            .then((granted) => {
+            .then((granted: any) => {
               if (!granted) {
                 return;
               } else {
                 // Request permission to show notifications
                 window.__TAURI__?.notification
                   .requestPermission()
-                  .then((permission) => {
+                  .then((permission: any) => {
                     if (permission === "granted") {
                       if (version === remoteId) {
                         // Show a notification using Tauri

+ 2 - 1
app/styles/window.scss

@@ -24,6 +24,7 @@
 
   .window-header-sub-title {
     font-size: 14px;
+    text-align: left;
   }
 }
 
@@ -33,4 +34,4 @@
 
 .window-action-button:not(:first-child) {
   margin-left: 10px;
-}
+}