2025-05-06 18:07:15 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="home-container">
|
|
|
|
|
|
<div class="home-content">
|
|
|
|
|
|
<div v-if="startChat" ref="conversationRef" class="conversation-area">
|
|
|
|
|
|
<template v-for="(msg, idx) in messages" :key="idx">
|
2025-05-15 15:29:01 +08:00
|
|
|
|
<McBubble v-if="msg.role === 'user'" :content="msg.content" :align="'right'" ></McBubble>
|
2025-05-08 11:25:57 +08:00
|
|
|
|
<McBubble v-else :loading="msg.loading ?? false" >
|
|
|
|
|
|
<div class="think-toggle-btn" @click="toggleThink(idx)">
|
|
|
|
|
|
<div class="flex align-middle">
|
|
|
|
|
|
<img style="height: 15px;margin-right: 8px" width="16" src="@/assets/imgs/jyh/ai/icon_skgc.png" />
|
|
|
|
|
|
<span class="span1">思考过程:</span>
|
|
|
|
|
|
<i style="margin-left: auto" :class="btnIcon"></i>
|
2025-05-06 18:07:15 +08:00
|
|
|
|
</div>
|
2025-05-08 11:25:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="flex align-middle" style="margin-top: 6px">
|
|
|
|
|
|
<i style="font-size: 16px;height: 15px;margin-right: 8px" class="icon icon-right"></i>
|
|
|
|
|
|
<span class="span1">完成回答:</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!--开源软件列表-->
|
2025-05-08 15:27:41 +08:00
|
|
|
|
<OssList v-if="msg.type===1"/>
|
2025-05-09 14:13:08 +08:00
|
|
|
|
<!--预警列表-->
|
2025-05-08 15:27:41 +08:00
|
|
|
|
<WarningList v-else-if="msg.type===2"/>
|
2025-05-09 14:13:08 +08:00
|
|
|
|
<!--软件详情-->
|
|
|
|
|
|
<OssDetail v-else-if="msg.type===3"/>
|
2025-05-13 17:59:24 +08:00
|
|
|
|
<!--软件详情-->
|
|
|
|
|
|
<AIList v-else-if="msg.type==='df'" :content="msg.content"/>
|
|
|
|
|
|
<!--text或者富文本展示-->
|
|
|
|
|
|
<Other v-else :content="msg.content"></Other>
|
2025-05-06 18:07:15 +08:00
|
|
|
|
</McBubble>
|
2025-05-08 11:25:57 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- <McBubble v-else :loading="msg.loading ?? false" :avatarConfig="msg.avatarConfig">-->
|
|
|
|
|
|
<!-- <McMarkdownCard :content="msg.content" :theme="theme"></McMarkdownCard>-->
|
|
|
|
|
|
<!-- <template #bottom>-->
|
|
|
|
|
|
<!-- <div class="bubble-bottom-operations">-->
|
|
|
|
|
|
<!-- <i class="icon-copy-new"></i>-->
|
|
|
|
|
|
<!-- <i class="icon-like"></i>-->
|
|
|
|
|
|
<!-- <i class="icon-dislike"></i>-->
|
|
|
|
|
|
<!-- </div>-->
|
|
|
|
|
|
<!-- </template>-->
|
|
|
|
|
|
<!-- </McBubble>-->
|
2025-05-06 18:07:15 +08:00
|
|
|
|
</template>
|
2025-05-13 17:59:24 +08:00
|
|
|
|
<div class="conversation-cnxw">
|
|
|
|
|
|
<a class="flex conversation-cnxw-item">
|
|
|
|
|
|
<span class="span2">猜你想问</span>
|
|
|
|
|
|
<img style="height: 15px;margin-right: 8px" width="16" src="@/assets/imgs/jyh/ai/icon_generate.png" />
|
|
|
|
|
|
</a>
|
|
|
|
|
|
<div class="flex conversation-cnxw-item">
|
|
|
|
|
|
<a class="g-header-copilot" @click="onSubmit('我想看Redis的详情')">
|
|
|
|
|
|
<img style="height: 15px;" width="16" src="@/assets/imgs/jyh/ai/icon_cnxw.png" />
|
|
|
|
|
|
<span class="ml-xs">我想看Redis的详情</span>
|
|
|
|
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="flex conversation-cnxw-item">
|
|
|
|
|
|
<a class="g-header-copilot" @click="onSubmit('Redis的可信评分是多少')">
|
|
|
|
|
|
<img style="height: 15px;" width="16" src="@/assets/imgs/jyh/ai/icon_cnxw.png" />
|
|
|
|
|
|
<span class="ml-xs">Redis的可信评分是多少</span>
|
|
|
|
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-05-06 18:07:15 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div v-else class="welcome-page">
|
|
|
|
|
|
<div class="home-title">
|
|
|
|
|
|
<img src="@/assets/imgs/jyh/ai/aiLogo2.png" alt="logo" />
|
|
|
|
|
|
<h1>可信开源代码库AI助手</h1>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="home-detail">
|
|
|
|
|
|
<div class="home-detail-1">Hi,欢迎使用可信开源代码库AI助手</div>
|
|
|
|
|
|
<div class="home-detail-2">可信开源代码库AI助手 可以辅助研发人员进行软件查询、批量校验、查看软件详情等。</div>
|
|
|
|
|
|
<div class="home-detail-2">作为AI模型,可信开源代码库AI助手 提供的答案可能不总是确定或准确的,但您的反馈可以帮助 可信开源代码库AI助手 做得更好。</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style="width: 100%;margin-top: -20px">
|
|
|
|
|
|
<SwiperComponent />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!--猜你想问-->
|
|
|
|
|
|
<div style="width: 100%;margin-top: -20px">
|
2025-05-08 11:25:57 +08:00
|
|
|
|
<GuessYouWantToAsk @submit="onSubmit"/>
|
2025-05-06 18:07:15 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!--操作按钮-->
|
|
|
|
|
|
<div class="new-convo-button">
|
2025-05-08 11:25:57 +08:00
|
|
|
|
<!-- <McPrompt-->
|
|
|
|
|
|
<!-- v-if="startChat"-->
|
|
|
|
|
|
<!-- class="simple-prompt"-->
|
|
|
|
|
|
<!-- style="flex: 1"-->
|
|
|
|
|
|
<!-- :list="simplePrompt"-->
|
|
|
|
|
|
<!-- :direction="'horizontal'"-->
|
|
|
|
|
|
<!-- @itemClick="onItemClick($event)"-->
|
|
|
|
|
|
<!-- ></McPrompt>-->
|
|
|
|
|
|
<div class="agent-knowledge">
|
2025-05-06 18:07:15 +08:00
|
|
|
|
<d-dropdown :position="['top']" @toggle="(val) => (isAgentOpen = val)">
|
|
|
|
|
|
<div class="agent-wrapper">
|
|
|
|
|
|
<img src="@/assets/imgs/jyh/ai/aiLogo2.png" />
|
|
|
|
|
|
<span>{{ selectedAgent.label }}</span>
|
|
|
|
|
|
<i class="icon-infrastructure"></i>
|
|
|
|
|
|
<i :class="['icon-chevron-down-2', { 'is-open': isAgentOpen }]"></i>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<template #menu>
|
|
|
|
|
|
<McList :data="agentList" @select="(val) => (selectedAgent = val)"></McList>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</d-dropdown>
|
|
|
|
|
|
<span class="agent-knowledge-dividing-line"></span>
|
|
|
|
|
|
<div class="knowledge-wrapper">
|
|
|
|
|
|
<i class="icon-operation-log"></i>
|
|
|
|
|
|
<span>添加知识</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<d-button icon="add" shape="circle" title="新建对话" size="sm" @click="onNewConvo" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!--输入框-->
|
|
|
|
|
|
<div style="padding: 0 12px 12px 12px;width: 100%">
|
|
|
|
|
|
<McInput :placeholder="placeholder" :value="inputValue" :maxLength="maxLength" @change="(e) => (inputValue = e)" @submit="onSubmit">
|
|
|
|
|
|
<template #extra>
|
|
|
|
|
|
<div class="input-foot-wrapper">
|
|
|
|
|
|
<div class="input-foot-left">
|
|
|
|
|
|
<span v-for="(item, index) in inputFootIcons" :key="index" @click="() => onInputIconClick(item)">
|
|
|
|
|
|
<i :class="item.icon"></i>
|
|
|
|
|
|
{{ item.text }}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span class="input-foot-dividing-line"></span>
|
|
|
|
|
|
<span class="input-foot-maxlength">{{ inputValue.length }}/{{maxLength}}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="input-foot-right">
|
|
|
|
|
|
<d-button icon="op-clearup" shape="round" :disabled="!inputValue" @click="inputValue = ''">清空输入</d-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</McInput>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 添加使用条款部分 -->
|
|
|
|
|
|
<div class="usage-terms">
|
|
|
|
|
|
<p>内容由AI生成,无法确保准确性和完整性,仅供参考:使用条款 隐私声明</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-05-15 15:29:01 +08:00
|
|
|
|
<div class="back-in-btn">
|
|
|
|
|
|
<div class="back-in-time-btn" @click="toggleHistory" :class="{ 'active': isHistoryVisible }">
|
|
|
|
|
|
<i class="icon icon-history" title="查看历史"></i>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="back-in-time-btn" @click="handleBackInTime">
|
|
|
|
|
|
<i class="icon icon-operation-log" title="查看文档"></i>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<ViewHistoryAside ref="viewHistoryRef" :CONV_ID="CONV_ID" :username="username" v-show="isHistoryVisible" @select-conv="handleSelectConv"/>
|
2025-05-06 18:07:15 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import { ref, defineComponent, nextTick, onMounted } from 'vue';
|
|
|
|
|
|
import { introPrompt, simplePrompt, mockAnswer, guessQuestions } from './mock.constants';
|
|
|
|
|
|
import SwiperComponent from './SwiperComponent.vue';
|
|
|
|
|
|
import GuessYouWantToAsk from './GuessYouWantToAsk.vue';
|
2025-05-08 11:25:57 +08:00
|
|
|
|
import OssList from './components/OssList.vue';
|
2025-05-08 15:27:41 +08:00
|
|
|
|
import WarningList from './components/WarningList.vue';
|
2025-05-09 14:13:08 +08:00
|
|
|
|
import OssDetail from './components/OssDetail.vue';
|
2025-05-13 17:59:24 +08:00
|
|
|
|
import Other from './components/Other.vue';
|
|
|
|
|
|
import AIList from './components/AIList.vue';
|
2025-05-15 15:29:01 +08:00
|
|
|
|
import ViewHistoryAside from './components/ViewHistoryAside/ViewHistoryAside.vue';
|
2025-05-13 17:59:24 +08:00
|
|
|
|
import axios from 'axios';
|
|
|
|
|
|
import { useDiscussGetUserInfo } from '@/api/discussion/hook';
|
2025-05-15 15:29:01 +08:00
|
|
|
|
import { Message } from 'vue-devui/message';
|
2025-05-13 17:59:24 +08:00
|
|
|
|
|
|
|
|
|
|
// 获取当前用户信息 & 是否登录
|
|
|
|
|
|
const { isLogin = false, userInfo = {}} = useDiscussGetUserInfo();
|
2025-05-15 15:29:01 +08:00
|
|
|
|
const {username=''} = userInfo
|
2025-05-06 18:07:15 +08:00
|
|
|
|
|
|
|
|
|
|
const inputValue = ref('');
|
|
|
|
|
|
const startChat = ref(false);
|
|
|
|
|
|
const conversationRef = ref();
|
|
|
|
|
|
const isAgentOpen = ref(false);
|
|
|
|
|
|
const theme = ref('light');
|
|
|
|
|
|
const maxLength = ref(8000);
|
|
|
|
|
|
const placeholder = ref('请输入问题描述,描述越详细 DevMate 回复越准确( Enter发送,Shift+Enter 换行,↑ 查看最近发出的消息 )');
|
|
|
|
|
|
let themeService;
|
|
|
|
|
|
const agentList = ref([
|
|
|
|
|
|
{ label: 'MateChat', value: 'matechat', active: true },
|
|
|
|
|
|
{ label: 'InsCode', value: 'inscode' },
|
|
|
|
|
|
]);
|
|
|
|
|
|
const selectedAgent = ref(agentList.value[0]);
|
2025-05-15 15:29:01 +08:00
|
|
|
|
|
2025-05-06 18:07:15 +08:00
|
|
|
|
const aiModelAvatar = {
|
|
|
|
|
|
imgSrc: 'https://matechat.gitcode.com/logo.svg',
|
|
|
|
|
|
width: 32,
|
|
|
|
|
|
height: 32,
|
|
|
|
|
|
};
|
|
|
|
|
|
const customerAvatar = {
|
|
|
|
|
|
imgSrc: 'https://matechat.gitcode.com/png/demo/userAvatar.svg',
|
|
|
|
|
|
width: 32,
|
|
|
|
|
|
height: 32,
|
|
|
|
|
|
};
|
|
|
|
|
|
const inputFootIcons = [
|
|
|
|
|
|
{ icon: 'icon-at', text: '智能体' },
|
|
|
|
|
|
{ icon: 'icon-standard', text: '词库' },
|
|
|
|
|
|
{ icon: 'icon-add', text: '附件' },
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
const messages = ref([]);
|
|
|
|
|
|
|
2025-05-15 15:29:01 +08:00
|
|
|
|
// 控制 ViewHistoryAside 组件的显示状态
|
|
|
|
|
|
const isHistoryVisible = ref(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 切换 ViewHistoryAside 组件的显示与隐藏
|
|
|
|
|
|
const toggleHistory = () => {
|
|
|
|
|
|
isHistoryVisible.value =!isHistoryVisible.value;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-05-06 18:07:15 +08:00
|
|
|
|
const onInputIconClick = (e) => {
|
|
|
|
|
|
if (e.icon === 'icon-at') {
|
|
|
|
|
|
inputValue.value += `@${selectedAgent.value.label}`;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-05-15 15:29:01 +08:00
|
|
|
|
const onSubmit = async (e, answer = undefined) => {
|
2025-05-06 18:07:15 +08:00
|
|
|
|
if(e === '') {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
inputValue.value = '';
|
|
|
|
|
|
if (!messages.value.length) {
|
|
|
|
|
|
startChat.value = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
messages.value.push({
|
2025-05-15 15:29:01 +08:00
|
|
|
|
role: 'user',
|
2025-05-06 18:07:15 +08:00
|
|
|
|
content: e,
|
|
|
|
|
|
avatarPosition: 'side-right',
|
|
|
|
|
|
avatarConfig: { ...customerAvatar },
|
|
|
|
|
|
});
|
2025-05-15 15:29:01 +08:00
|
|
|
|
// getAIAnswer(answer ?? e);
|
|
|
|
|
|
// 判断是否有会话id
|
|
|
|
|
|
if(!CONV_ID.value) {
|
|
|
|
|
|
// 调用创建会话接口
|
|
|
|
|
|
await createConversation()
|
|
|
|
|
|
}
|
|
|
|
|
|
await getAIAnswer(e,1);
|
2025-05-06 18:07:15 +08:00
|
|
|
|
nextTick(() => {
|
|
|
|
|
|
conversationRef.value?.scrollTo({
|
|
|
|
|
|
top: conversationRef.value.scrollHeight,
|
|
|
|
|
|
behavior: 'smooth',
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-05-13 18:06:07 +08:00
|
|
|
|
const VITE_AI_API_HOST = (import.meta as any).env.VITE_AI_API_HOST;
|
2025-05-15 15:29:01 +08:00
|
|
|
|
|
|
|
|
|
|
// AI对话接口对接
|
2025-05-13 17:59:24 +08:00
|
|
|
|
const getAIAnswer = async (content) => {
|
2025-05-15 15:29:01 +08:00
|
|
|
|
debugger
|
|
|
|
|
|
if(CONV_ID.value) {
|
|
|
|
|
|
messages.value.push({
|
|
|
|
|
|
role: 'ai-model',
|
|
|
|
|
|
type: '',
|
|
|
|
|
|
content: '',
|
|
|
|
|
|
avatarPosition: 'side-left',
|
|
|
|
|
|
avatarConfig: { ...aiModelAvatar },
|
|
|
|
|
|
loading: true,
|
|
|
|
|
|
});
|
2025-05-06 18:07:15 +08:00
|
|
|
|
|
2025-05-15 15:29:01 +08:00
|
|
|
|
const response = await axios.post(`${VITE_AI_API_HOST}/api/v0/chat_use_sql`, {
|
|
|
|
|
|
userId: username, // 使用 username 作为 userId
|
|
|
|
|
|
conversationId: CONV_ID.value,
|
|
|
|
|
|
question: content,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if(response.data.type) {
|
|
|
|
|
|
const {text,type} = response.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 = response.data[type];
|
|
|
|
|
|
messages.value[messages.value.length - 1].loading = false;
|
|
|
|
|
|
messages.value[messages.value.length - 1].type = 'df';
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Message.warning('接口异常!')
|
|
|
|
|
|
}
|
|
|
|
|
|
// messages.value.push({
|
|
|
|
|
|
// from: 'ai-model',
|
|
|
|
|
|
// content: '',
|
|
|
|
|
|
// avatarPosition: 'side-left',
|
|
|
|
|
|
// avatarConfig: { ...aiModelAvatar },
|
|
|
|
|
|
// loading: true,
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// /* 模拟流式数据返回 */
|
|
|
|
|
|
// setTimeout(async () => {
|
|
|
|
|
|
// messages.value.at(-1).loading = false;
|
|
|
|
|
|
// for (let i = 0; i < content.length;) {
|
|
|
|
|
|
// await new Promise(r => setTimeout(r, 300 * Math.random()));
|
|
|
|
|
|
// messages.value[messages.value.length - 1].content = content.slice(0, i += Math.random() * 10);
|
|
|
|
|
|
// nextTick(() => {
|
|
|
|
|
|
// conversationRef.value?.scrollTo({
|
|
|
|
|
|
// top: conversationRef.value.scrollHeight
|
|
|
|
|
|
// });
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }, 1000);
|
|
|
|
|
|
} else {
|
2025-05-15 17:02:39 +08:00
|
|
|
|
// Message.error('请先创建会话!');
|
2025-05-15 15:29:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const viewHistoryRef = ref(null);
|
|
|
|
|
|
// 当前会话id
|
|
|
|
|
|
const CONV_ID = ref('');
|
|
|
|
|
|
// 创建对话接口
|
|
|
|
|
|
const createConversation = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (!username) {
|
|
|
|
|
|
Message.error('请先登录!');
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
const response = await axios.post(`${VITE_AI_API_HOST}/api/createConversation`, {
|
|
|
|
|
|
userId: username,
|
|
|
|
|
|
});
|
|
|
|
|
|
const createRes = response.data;
|
|
|
|
|
|
|
|
|
|
|
|
if (createRes&&createRes.conversationId) {
|
|
|
|
|
|
CONV_ID.value = createRes.conversationId;
|
|
|
|
|
|
console.log('创建会话成功,会话ID:', CONV_ID.value);
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
|
// 刷新会话列表
|
|
|
|
|
|
if (viewHistoryRef.value) {
|
|
|
|
|
|
viewHistoryRef.value.getQuestionHistory(); // 调用子组件方法
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Message.error('创建会话失败,未获取到会话ID');
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('创建会话失败:', error);
|
|
|
|
|
|
Message.error('创建会话失败,请重试');
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleSelectConv = (convId: string) => {
|
|
|
|
|
|
CONV_ID.value = convId; // 更新为选中的会话 ID
|
|
|
|
|
|
getConversationDetail(convId); // 调用详情接口
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 定义获取会话详情的接口(根据实际接口调整)
|
|
|
|
|
|
const getConversationDetail = async (convId: string) => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const response = await axios.get(`${VITE_AI_API_HOST}/api/conversationDetail`, {
|
|
|
|
|
|
params: {
|
|
|
|
|
|
userId: username,
|
|
|
|
|
|
conversationId: convId,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
const detail = response.data;
|
|
|
|
|
|
// 处理详情数据(如回显消息列表)
|
|
|
|
|
|
handleDetailResponse(detail);
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取会话详情失败:', error);
|
|
|
|
|
|
Message.error('获取会话详情失败,请重试');
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 处理详情数据(示例:更新消息列表)
|
|
|
|
|
|
const handleDetailResponse = (detail: any) => {
|
|
|
|
|
|
// 假设接口返回消息列表为 messagesList
|
|
|
|
|
|
messages.value = detail.messages || [];
|
|
|
|
|
|
startChat.value = true; // 显示聊天界面
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
|
conversationRef.value?.scrollTo({
|
|
|
|
|
|
top: conversationRef.value.scrollHeight,
|
|
|
|
|
|
behavior: 'smooth',
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
2025-05-06 18:07:15 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const onNewConvo = () => {
|
|
|
|
|
|
startChat.value = false;
|
|
|
|
|
|
messages.value = [];
|
2025-05-15 15:29:01 +08:00
|
|
|
|
createConversation()
|
2025-05-06 18:07:15 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const onItemClick = (item) => {
|
|
|
|
|
|
if (mockAnswer[item.value]) {
|
|
|
|
|
|
// 使用 mock 数据
|
|
|
|
|
|
onSubmit(item.label, mockAnswer[item.value]);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const themeChange = () => {
|
|
|
|
|
|
if (themeService) {
|
|
|
|
|
|
theme.value = themeService.currentTheme.id === 'infinity-theme' ? 'light' : 'dark';
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-08 11:25:57 +08:00
|
|
|
|
const isLoading = ref(false);
|
|
|
|
|
|
let interval = null;
|
|
|
|
|
|
const thinkBtnText = ref('思考过程');
|
|
|
|
|
|
const btnIcon = ref('icon-chevron-down-2');
|
|
|
|
|
|
|
|
|
|
|
|
const toggleThink = (idx) => {
|
|
|
|
|
|
if (isLoading.value) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
const targetNode = document.querySelectorAll('.mc-bubble-content-container')[idx];
|
|
|
|
|
|
if (targetNode) {
|
|
|
|
|
|
const thinkBlock = targetNode.querySelector('.mc-think-block');
|
|
|
|
|
|
if (thinkBlock) {
|
|
|
|
|
|
const currentDisplay = getComputedStyle(thinkBlock).display;
|
|
|
|
|
|
thinkBlock.style.display = currentDisplay === 'none' ? 'block' : 'none';
|
|
|
|
|
|
btnIcon.value = currentDisplay === 'none' ? 'icon-chevron-up-2' :'icon-chevron-down-2'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-06 18:07:15 +08:00
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
if(typeof window !== 'undefined'){
|
|
|
|
|
|
themeService = window['devuiThemeService'];
|
|
|
|
|
|
}
|
|
|
|
|
|
themeChange();
|
|
|
|
|
|
if (themeService && themeService.eventBus) {
|
|
|
|
|
|
themeService.eventBus.add('themeChanged', themeChange);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
.home-container {
|
|
|
|
|
|
width: 100%;
|
2025-05-08 11:25:57 +08:00
|
|
|
|
height: calc(100vh - 56px);
|
2025-05-06 18:07:15 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
|
|
|
|
.home-content {
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
padding-top: 3%;
|
|
|
|
|
|
padding-bottom: 1%;
|
|
|
|
|
|
height: 100%;
|
2025-05-08 11:25:57 +08:00
|
|
|
|
width: 60%;
|
2025-05-06 18:07:15 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
justify-self: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.home-title {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 20px;
|
|
|
|
|
|
h1 {
|
|
|
|
|
|
color: #191919;
|
|
|
|
|
|
font-family: Huawei Sans;
|
|
|
|
|
|
font-weight: bold;
|
2025-05-12 10:23:52 +08:00
|
|
|
|
font-size: 32px;
|
2025-05-06 18:07:15 +08:00
|
|
|
|
line-height: 48px;
|
|
|
|
|
|
letter-spacing: 0px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
img {
|
2025-05-12 10:23:52 +08:00
|
|
|
|
width: 64px;
|
2025-05-06 18:07:15 +08:00
|
|
|
|
//filter: brightness(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.home-detail {
|
|
|
|
|
|
.home-detail-1 {
|
|
|
|
|
|
color: #191919;
|
|
|
|
|
|
font-family: HarmonyOS Sans SC;
|
|
|
|
|
|
font-weight: medium;
|
|
|
|
|
|
font-size: 24px;
|
|
|
|
|
|
line-height: 32px;
|
|
|
|
|
|
letter-spacing: 0px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
margin-bottom: 24px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.home-detail-2 {
|
|
|
|
|
|
color: #777777;
|
|
|
|
|
|
font-family: HarmonyOS Sans SC;
|
|
|
|
|
|
font-weight: regular;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
line-height: 22px;
|
|
|
|
|
|
letter-spacing: 0px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.conversation-area,
|
|
|
|
|
|
.welcome-page {
|
2025-05-08 11:25:57 +08:00
|
|
|
|
//height: 90%;
|
2025-05-06 18:07:15 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
2025-05-08 11:25:57 +08:00
|
|
|
|
overflow: auto;
|
2025-05-06 18:07:15 +08:00
|
|
|
|
padding: 0 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.conversation-area {
|
|
|
|
|
|
gap: 8px;
|
2025-05-08 11:25:57 +08:00
|
|
|
|
:deep(.mc-bubble-right) {
|
|
|
|
|
|
.mc-bubble-content {
|
|
|
|
|
|
background: #DFDFDF;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
:deep(.mc-bubble-left) {
|
|
|
|
|
|
.mc-bubble-content-container {
|
|
|
|
|
|
background: transparent;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
.span1{
|
|
|
|
|
|
color: #777777;
|
|
|
|
|
|
font-family: HarmonyOS Sans SC;
|
|
|
|
|
|
font-weight: regular;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
line-height: 22px;
|
|
|
|
|
|
letter-spacing: 0px;
|
|
|
|
|
|
text-align: left;
|
|
|
|
|
|
}
|
|
|
|
|
|
.mc-bubble-content.filled {
|
|
|
|
|
|
background: transparent;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.conversation-cnxw {
|
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
|
.conversation-cnxw-item {
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: end;
|
|
|
|
|
|
margin-right: 12px;
|
|
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.span2{
|
|
|
|
|
|
color: black;
|
|
|
|
|
|
font-family: HarmonyOS Sans SC;
|
|
|
|
|
|
font-weight: regular;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
line-height: 22px;
|
|
|
|
|
|
letter-spacing: 0px;
|
|
|
|
|
|
text-align: left;
|
|
|
|
|
|
margin-right: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.g-header-copilot {
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
color: black;
|
|
|
|
|
|
//width: 120px;
|
|
|
|
|
|
padding: 0 12px;
|
|
|
|
|
|
border-radius: 48px;
|
|
|
|
|
|
height: 32px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
background: rgba(41, 81, 224, 0.8);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.g-header-copilot:hover {
|
|
|
|
|
|
background: #f0f0f0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-05-06 18:07:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.welcome-page {
|
2025-05-12 10:23:52 +08:00
|
|
|
|
gap: 16px;
|
2025-05-06 18:07:15 +08:00
|
|
|
|
justify-content: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.guess-question {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
padding: 16px 12px;
|
|
|
|
|
|
border-radius: var(--devui-border-radius-card);
|
|
|
|
|
|
background-color: var(--devui-gray-form-control-bg);
|
|
|
|
|
|
|
|
|
|
|
|
.guess-title {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
color: var(--devui-text);
|
|
|
|
|
|
margin-bottom: 12px;
|
|
|
|
|
|
|
|
|
|
|
|
& > div:first-child {
|
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
|
font-size: var(--devui-font-size);
|
|
|
|
|
|
}
|
|
|
|
|
|
& > div:last-child {
|
|
|
|
|
|
font-size: var(--devui-font-size-sm);
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
span {
|
|
|
|
|
|
margin-left: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.guess-content {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
span {
|
|
|
|
|
|
font-size: var(--devui-font-size-sm);
|
|
|
|
|
|
color: var(--devui-text);
|
|
|
|
|
|
padding: 4px 12px;
|
|
|
|
|
|
border-radius: var(--devui-border-radius-full);
|
|
|
|
|
|
background-color: var(--devui-gray-form-control-hover-bg);
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.bubble-bottom-operations {
|
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
|
i {
|
|
|
|
|
|
padding: 4px;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
background-color: var(--devui-icon-hover-bg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.new-convo-button {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
padding: 0 12px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
height: 39px;
|
|
|
|
|
|
gap: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.simple-prompt .mc-list) {
|
|
|
|
|
|
justify-content: unset;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.intro-prompt .mc-list) {
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.operations {
|
|
|
|
|
|
i {
|
|
|
|
|
|
padding: 4px;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
background: var(--devui-global-bg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.agent-knowledge {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
|
|
.agent-wrapper {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
padding: 4px 8px;
|
|
|
|
|
|
border-radius: var(--devui-border-radius-full);
|
|
|
|
|
|
background-color: var(--devui-area);
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
|
|
img {
|
|
|
|
|
|
width: 16px;
|
|
|
|
|
|
height: 16px;
|
|
|
|
|
|
margin-right: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
span {
|
|
|
|
|
|
font-size: var(--devui-font-size);
|
|
|
|
|
|
color: var(--devui-text);
|
|
|
|
|
|
margin-right: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
i {
|
|
|
|
|
|
font-size: var(--devui-font-size);
|
|
|
|
|
|
color: var(--devui-text);
|
|
|
|
|
|
transition: transform 0.3s ease-in-out;
|
|
|
|
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
|
|
margin-left: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.is-open {
|
|
|
|
|
|
transform: rotate(180deg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.agent-knowledge-dividing-line {
|
|
|
|
|
|
width: 1px;
|
|
|
|
|
|
height: 14px;
|
|
|
|
|
|
margin: 0 12px;
|
|
|
|
|
|
background-color: var(--devui-line);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.knowledge-wrapper {
|
|
|
|
|
|
font-size: var(--devui-font-size);
|
|
|
|
|
|
color: var(--devui-text);
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
|
|
span {
|
|
|
|
|
|
margin-left: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.input-foot-wrapper {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
margin-right: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
.input-foot-left {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
span {
|
|
|
|
|
|
font-size: var(--devui-font-size-sm);
|
|
|
|
|
|
color: var(--devui-text);
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.input-foot-dividing-line {
|
|
|
|
|
|
width: 1px;
|
|
|
|
|
|
height: 14px;
|
|
|
|
|
|
background-color: var(--devui-line);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.input-foot-maxlength {
|
|
|
|
|
|
font-size: var(--devui-font-size-sm);
|
|
|
|
|
|
color: var(--devui-aide-text);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.input-foot-right {
|
|
|
|
|
|
& > *:not(:first-child) {
|
|
|
|
|
|
margin-left: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.mc-input) {
|
|
|
|
|
|
background: #ffffff;
|
|
|
|
|
|
.mc-textarea {
|
|
|
|
|
|
height: 100px;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.usage-terms {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
color: #AEAEAE;
|
|
|
|
|
|
font-family: HarmonyOS Sans SC;
|
|
|
|
|
|
font-weight: regular;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
line-height: 20px;
|
|
|
|
|
|
letter-spacing: 0px;
|
|
|
|
|
|
text-align: left;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-05-15 15:29:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.back-in-btn {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
left: 20px;
|
|
|
|
|
|
bottom: 20px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
gap: 12px;
|
|
|
|
|
|
|
|
|
|
|
|
.active {
|
|
|
|
|
|
background-color: #f0f0f0; /* 灰色背景 */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.active .icon {
|
|
|
|
|
|
transform: translateY(-4px); /* 图标上移4px */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.back-in-time-btn {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
padding: 8px;
|
|
|
|
|
|
background-color: var(--el-color-primary);
|
|
|
|
|
|
//color: white;
|
|
|
|
|
|
border-radius: 20px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
|
|
|
|
z-index: 999;
|
|
|
|
|
|
transition: all 0.3s;
|
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.back-in-time-btn:hover {
|
|
|
|
|
|
background-color: var(--el-color-primary-light-3);
|
|
|
|
|
|
transform: translateY(-2px);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 响应式调整 - 移动端隐藏或调整位置 */
|
|
|
|
|
|
@media (max-width: 768px) {
|
|
|
|
|
|
.back-in-time-btn {
|
|
|
|
|
|
left: 10px;
|
|
|
|
|
|
bottom: 10px;
|
|
|
|
|
|
padding: 6px 12px;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-05-06 18:07:15 +08:00
|
|
|
|
</style>
|