From a08cb3f613ce2710c4e6422a71b5a86052746afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E6=B0=91=E5=BA=B7?= Date: Tue, 13 May 2025 17:59:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BF=A1=E4=BB=A3=E7=A0=81=E5=BA=93-A?= =?UTF-8?q?I=E5=A4=A7=E6=A8=A1=E5=9E=8B=E6=89=B9=E9=87=8F=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E6=8E=A5=E5=8F=A3=E5=AF=B9=E8=AF=9D=E5=8F=8A=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 3 + .env.loc | 3 + .env.pre | 3 + .env.production | 3 + .../ViewHistoryAside/ViewHistoryAside.vue | 109 ++++++ src/layouts/AILayout/index.vue | 37 +-- src/views/Jyh/AI/Home/components/AIList.vue | 311 ++++++++++++++++++ src/views/Jyh/AI/Home/components/Other.vue | 37 +++ src/views/Jyh/AI/Home/index.vue | 74 +++-- 9 files changed, 533 insertions(+), 47 deletions(-) create mode 100644 src/views/Jyh/AI/Home/components/AIList.vue create mode 100644 src/views/Jyh/AI/Home/components/Other.vue diff --git a/.env.development b/.env.development index 0252384..a3ff90d 100644 --- a/.env.development +++ b/.env.development @@ -36,3 +36,6 @@ VITE_USER_CENTER_HOST = 'https://test.gitcode.net/child/user-center/' VITE_COPILOT_HOST = 'https://test.gitcode.net/child/aichat-app/' VITE_BASE_URL=/ + +# AI大模型接口地址 +VITE_AI_API_HOST = ''http://222.20.126.208:8089' diff --git a/.env.loc b/.env.loc index dc60f36..09fd3ed 100644 --- a/.env.loc +++ b/.env.loc @@ -38,3 +38,6 @@ VITE_USER_CENTER_HOST = 'https://local.gitcode.net:8002' VITE_COPILOT_HOST = 'https://local.gitcode.net:8003/child/aichat-app' VITE_BASE_URL=/openRepoPortal/ + +# AI大模型接口地址 +VITE_AI_API_HOST = ''http://222.20.126.208:8089' diff --git a/.env.pre b/.env.pre index 2037785..cbefc44 100644 --- a/.env.pre +++ b/.env.pre @@ -38,3 +38,6 @@ VITE_USER_CENTER_HOST = 'https://pre-usercenter-app.gitcode.com' VITE_COPILOT_HOST = 'https://pre-copilot-app.gitcode.com' VITE_BASE_URL=/openRepoPortal/ + +# AI大模型接口地址 +VITE_AI_API_HOST = ''http://222.20.126.208:8089' diff --git a/.env.production b/.env.production index 08dc3a4..6727555 100644 --- a/.env.production +++ b/.env.production @@ -38,3 +38,6 @@ VITE_USER_CENTER_HOST = 'https://usercenter-app.gitcode.com' VITE_COPILOT_HOST = 'https://copilot-app.gitcode.com' VITE_BASE_URL=/openRepoPortal/ + +# AI大模型接口地址 +VITE_AI_API_HOST = ''http://222.20.126.208:8089' diff --git a/src/layouts/AILayout/ViewHistoryAside/ViewHistoryAside.vue b/src/layouts/AILayout/ViewHistoryAside/ViewHistoryAside.vue index 817f361..7553f64 100644 --- a/src/layouts/AILayout/ViewHistoryAside/ViewHistoryAside.vue +++ b/src/layouts/AILayout/ViewHistoryAside/ViewHistoryAside.vue @@ -113,6 +113,115 @@ + + +
+ + + +
+ +
+
+ +
+

{{ item.title }}

+ +
+ + + + + + + + + +
+
+ +
+
+ + {{ item.text }} +
+
+ {{ formatTime(item.time) }} +
+
+
+
+ +
+
+ + +
+
+ +
+

{{ item.title }}

+
+ +
+
+ + {{ item.text }} +
+
+ {{ formatTime(item.time) }} +
+
+
+
+
+
+
+ +
+
+ 历史对话保存条数 + + 10 + 20 + 30 + 0 + +
+
+ + + 批量管理 + + +
+
diff --git a/src/layouts/AILayout/index.vue b/src/layouts/AILayout/index.vue index 1bda097..77c5489 100644 --- a/src/layouts/AILayout/index.vue +++ b/src/layouts/AILayout/index.vue @@ -64,7 +64,7 @@
-
+
@@ -72,7 +72,7 @@
- + @@ -104,6 +104,9 @@ const refHeader: any = ref(null); const footerSize = useElementSize(refFooter); const isHome = computed(() => route.name === 'home'); +// 控制 ViewHistoryAside 组件的显示状态 +const isHistoryVisible = ref(false); + // aside 设置可见性 header有两层,有顶栏信息,两层sidebar 都不可见 const asideSetShow = computed(() => { if (route.meta.asideMenu === 'drawer') return false; @@ -160,26 +163,10 @@ const handleClickMenu = () => { } }; -const outOfSearch = ref(true); // 在search页面隐藏footer -router.afterEach((to, form) => { - outOfSearch.value = to.name !== 'search'; -}); -microApp.router.afterEach({ - 'micoro-app-homeweb-app': (to, from) => { - outOfSearch.value = to.pathname !== '/search'; - } -}); -const checkPage = (data: any) => { - if (data.type === 'checkPage') { - return 'ready'; - } +// 切换 ViewHistoryAside 组件的显示与隐藏 +const toggleHistory = () => { + isHistoryVisible.value =!isHistoryVisible.value; }; -onMounted(() => { - microApp.addDataListener('micoro-app-homeweb-app', checkPage, false); -}); -onUnmounted(() => { - microApp.removeDataListener('micoro-app-homeweb-app', checkPage); -}); diff --git a/src/views/Jyh/AI/Home/components/Other.vue b/src/views/Jyh/AI/Home/components/Other.vue new file mode 100644 index 0000000..f93ae25 --- /dev/null +++ b/src/views/Jyh/AI/Home/components/Other.vue @@ -0,0 +1,37 @@ + + + + + diff --git a/src/views/Jyh/AI/Home/index.vue b/src/views/Jyh/AI/Home/index.vue index c7e74a3..6cf2a02 100644 --- a/src/views/Jyh/AI/Home/index.vue +++ b/src/views/Jyh/AI/Home/index.vue @@ -22,27 +22,10 @@ - - - - + + + + @@ -56,6 +39,24 @@ +
@@ -142,6 +143,15 @@ import GuessYouWantToAsk from './GuessYouWantToAsk.vue'; import OssList from './components/OssList.vue'; import WarningList from './components/WarningList.vue'; import OssDetail from './components/OssDetail.vue'; +import Other from './components/Other.vue'; +import AIList from './components/AIList.vue'; +import { getChat } from '@/api/jyh'; +import axios from 'axios'; +import { useDiscussGetUserInfo } from '@/api/discussion/hook'; + +// 获取当前用户信息 & 是否登录 +const { isLogin = false, userInfo = {}} = useDiscussGetUserInfo(); +debugger const inputValue = ref(''); const startChat = ref(false); @@ -201,20 +211,32 @@ const onSubmit = (e, answer = undefined) => { }); }); // getAIAnswer(answer ?? e); - getAIAnswer(mockAnswer,1); + getAIAnswer(e,1); }; -const getAIAnswer = (content,type) => { +const getAIAnswer = async (content) => { messages.value.push({ from: 'ai-model', - type: type || 1, - content: content, + type: '', + content: '', avatarPosition: 'side-left', avatarConfig: { ...aiModelAvatar }, - loading: false, + loading: true, }); + const {data} = await axios.get('http://222.20.126.208:8089/api/v0/chat_use_sql?question='+content); + debugger + const {text,type} = data; + if(type==='text') { + messages.value[messages.value.length - 1].content = text; + messages.value[messages.value.length - 1].loading = false; + messages.value[messages.value.length - 1].type = 'text'; + } else if(type==='df') { + messages.value[messages.value.length - 1].content = data[type]; + messages.value[messages.value.length - 1].loading = false; + messages.value[messages.value.length - 1].type = 'df'; + } // messages.value.push({ // from: 'ai-model', // content: '',