Преглед на файлове

更改下拉框数据,样式。

S0025136190 преди 7 месеца
родител
ревизия
a3e433ce77
променени са 4 файла, в които са добавени 75 реда и са изтрити 68 реда
  1. 4 4
      app/client/platforms/bigModel.ts
  2. 51 48
      app/components/chat.tsx
  3. 19 16
      app/components/sidebar.tsx
  4. 1 0
      app/styles/window.scss

+ 4 - 4
app/client/platforms/bigModel.ts

@@ -23,9 +23,9 @@ export class BigModelApi implements LLMApi {
     const chatMode = useChatStore.getState().chatMode;
     this.baseURL = '/bigmodel-api';
     if (chatMode === 'LOCAL') {
-      this.apiPath = this.baseURL + '/bigmodel/api/model-api/sse-invoke';
-    } else {
       this.apiPath = this.baseURL + '/takai/api/chat';
+    } else {
+      this.apiPath = this.baseURL + '/bigmodel/api/model-api/sse-invoke';
     }
   }
 
@@ -184,9 +184,9 @@ export class BigModelApi implements LLMApi {
           }
           const chatMode = useChatStore.getState().chatMode;
           if (chatMode === 'LOCAL') {
-            await api.post('bigmodel/api/dialog/save', data);
-          } else {
             await api.post('takai/api/dialog/save', data);
+          } else {
+            await api.post('bigmodel/api/dialog/save', data);
           }
         },
         onerror(e) {

+ 51 - 48
app/components/chat.tsx

@@ -622,9 +622,9 @@ export function ChatActions(props: {
       }
       let url = '';
       if (chatStore.chatMode === 'LOCAL') {
-        url = '/bigmodel/api/async/completions';
-      } else {
         url = '/takai/api/async/completions';
+      } else {
+        url = '/bigmodel/api/async/completions';
       }
       const res = await api.post(url, data);
       setGuessList(res.data);
@@ -999,8 +999,8 @@ function _Chat() {
 
   const [selectedFruit, setSelectedFruit] = React.useState(chatStore.chatMode);
 
-  useEffect(() => {
-  }, []);
+  // useEffect(() => {
+  // }, []);
 
   // 获取应用列表
   const fetchApplicationList = async () => {
@@ -1009,9 +1009,9 @@ function _Chat() {
       let url = null;
       console.log('selectedFruit', selectedFruit);
       if (selectedFruit === 'LOCAL') {
-        url = '/bigmodel/api/application/list';
-      } else {
         url = '/takai/api/application/list';
+      } else {
+        url = '/bigmodel/api/application/list';
       }
       const res = await api.get(url);
       const list = res.data.filter((item: any) => item.appId !== '1234567890123456789').map((item: any) => {
@@ -1051,9 +1051,9 @@ function _Chat() {
     try {
       let url = null;
       if (selectedFruit === 'LOCAL') {
-        url = '/bigmodel/api/presets';
-      } else {
         url = '/takai/api/presets';
+      } else {
+        url = '/bigmodel/api/presets';
       }
       const res = await api.get(url + `/${appId}`);
       setQuestionList(res.data);
@@ -1606,51 +1606,54 @@ function _Chat() {
           <div>
             {
               appList.length > 1 ?
-                <Select
-                  style={{ width: '100%', height: 38, marginRight: 5 }}
-                  placeholder='请选择'
-                  options={appList}
-                  value={appValue}
-                  onChange={(value) => {
-                    setAppValue(value);
-                    globalStore.setSelectedAppId(value);
-                    chatStore.clearSessions();
-                    chatStore.updateCurrentSession((values) => {
-                      values.appId = value;
-                    });
-                    useChatStore.setState({
-                      message: {
-                        content: '',
-                        role: 'assistant',
-                      }
-                    });
-                    setSendStatus(false);
-                  }}
-                />
+                <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
+                  <Select
+                    style={{ width: '50%', height: 38, marginRight: 5 }}
+                    value={selectedFruit}
+                    onChange={(value: "ONLINE" | "LOCAL") => {
+                      chatStore.clearSessions();
+                      chatStore.updateCurrentSession((values) => {
+                        values.appId = globalStore.selectedAppId;
+                      });
+                      navigate({ pathname: '/newChat' });
+                      setSelectedFruit(value);
+                      chatStore.setChatMode(value);
+                    }}
+                  >
+                    {fruits.map(fruit => (
+                      <Select.Option key={fruit.id} value={fruit.id}>
+                        {fruit.name}
+                      </Select.Option>
+                    ))}
+                  </Select>
+                  <Select
+                    style={{ width: '100%', height: 38, marginRight: 5 }}
+                    placeholder='请选择'
+                    options={appList}
+                    value={appValue}
+                    onChange={(value) => {
+                      setAppValue(value);
+                      globalStore.setSelectedAppId(value);
+                      chatStore.clearSessions();
+                      chatStore.updateCurrentSession((values) => {
+                        values.appId = value;
+                      });
+                      useChatStore.setState({
+                        message: {
+                          content: '',
+                          role: 'assistant',
+                        }
+                      });
+                      setSendStatus(false);
+                    }}
+                  />
+                </div>
                 :
                 null
             }
           </div>
-
-
-
-        </div>
-        <div>
-          <Select
-            style={{ width: '200', height: 38, marginRight: 5 }}
-            value={selectedFruit}
-            onChange={(value: "ONLINE" | "LOCAL") => {
-              setSelectedFruit(value);
-              chatStore.setChatMode(value);
-            }}
-          >
-            {fruits.map(fruit => (
-              <Select.Option key={fruit.id} value={fruit.id}>
-                {fruit.name}
-              </Select.Option>
-            ))}
-          </Select>
         </div>
+
         <div className="window-actions">
           <div className="window-action-button">
             <Popover

+ 19 - 16
app/components/sidebar.tsx

@@ -218,13 +218,14 @@ export const SideBar = (props: { className?: string }) => {
   // 获取聊天列表
   const fetchChatList = async (chatMode?: 'ONLINE' | 'LOCAL') => {
     try {
+      console.log('fetchChatList', chatMode);
       let url = '';
       if (getType() === 'bigModel') {
         const appId = globalStore.selectedAppId;
         if (chatMode === 'LOCAL') {
-          url = `/bigmodel/api/dialog/list/${appId}`;
-        } else {
           url = `/takai/api/dialog/list/${appId}`;
+        } else {
+          url = `/bigmodel/api/dialog/list/${appId}`;
         }
       } else {
         const appId = '1881269958412521255';
@@ -259,9 +260,9 @@ export const SideBar = (props: { className?: string }) => {
                       let blob = null;
                       if (getType() === 'bigModel') {
                         if (chatMode === 'LOCAL') {
-                          blob = await api.post(`/bigmodel/api/dialog/export/${child.key}`, {}, { responseType: 'blob' });
-                        } else {
                           blob = await api.post(`/takai/api/dialog/export/${child.key}`, {}, { responseType: 'blob' });
+                        } else {
+                          blob = await api.post(`/bigmodel/api/dialog/export/${child.key}`, {}, { responseType: 'blob' });
                         }
                       } else {
                         blob = await api.post(`/bigmodel/api/dialog/export/${child.key}`, {}, { responseType: 'blob' });
@@ -283,11 +284,11 @@ export const SideBar = (props: { className?: string }) => {
                     try {
                       if (getType() === 'bigModel') {
                         if (chatMode === 'LOCAL') {
-                          await api.delete(`/bigmodel/api/dialog/del/${child.key}`);
-                          await fetchChatList();
-                        } else {
                           await api.delete(`/takai/api/dialog/del/${child.key}`);
                           await fetchChatList(chatMode);
+                        } else {
+                          await api.delete(`/bigmodel/api/dialog/del/${child.key}`);
+                          await fetchChatList();
                         }
                       } else {
                         await api.delete(`/bigmodel/api/dialog/del/${child.key}`);
@@ -332,7 +333,9 @@ export const SideBar = (props: { className?: string }) => {
   }
 
   useEffect(() => {
-    fetchChatList();
+    if (globalStore.selectedAppId) {
+      fetchChatList(chatStore.chatMode);
+    }
   }, [globalStore.selectedAppId]);
 
   useEffect(() => {
@@ -389,9 +392,9 @@ export const SideBar = (props: { className?: string }) => {
               }
               if (getType() === 'bigModel') {
                 if (chatStore.chatMode === 'LOCAL') {
-                  await fetchChatList();
-                } else {
                   await fetchChatList(chatStore.chatMode);
+                } else {
+                  await fetchChatList();
                 }
               } else {
                 await fetchChatList();
@@ -408,9 +411,9 @@ export const SideBar = (props: { className?: string }) => {
           let url = ``;
           if (getType() === 'bigModel') {
             if (chatStore.chatMode === 'LOCAL') {
-              url = `/bigmodel/api/dialog/detail/${key}`;
-            } else {
               url = `/takai/api/dialog/detail/${key}`;
+            } else {
+              url = `/bigmodel/api/dialog/detail/${key}`;
             }
           } else {
             url = `/bigmodel/api/dialog/detail/${key}`;
@@ -458,17 +461,17 @@ export const SideBar = (props: { className?: string }) => {
             try {
               if (getType() === 'bigModel') {
                 if (chatStore.chatMode === 'LOCAL') {
-                  await api.put(`/bigmodel/api/dialog/update`, {
+                  await api.put(`/takai/api/dialog/update`, {
                     id: values.dialogId,
                     dialogName: values.dialogName
                   });
-                  await fetchChatList();
+                  await fetchChatList(chatStore.chatMode);
                 } else {
-                  await api.put(`/takai/api/dialog/update`, {
+                  await api.put(`/bigmodel/api/dialog/update`, {
                     id: values.dialogId,
                     dialogName: values.dialogName
                   });
-                  await fetchChatList(chatStore.chatMode);
+                  await fetchChatList();
                 }
               } else {
                 await api.put(`/bigmodel/api/dialog/update`, {

+ 1 - 0
app/styles/window.scss

@@ -18,6 +18,7 @@
 .window-header-title {
   color: #FFFFFF;
   max-width: calc(100% - 100px);
+  width: 100%;
   overflow: hidden;
 
   .window-header-main-title {