feat: 对话跳转

This commit is contained in:
2026-02-24 13:53:01 +08:00
parent 332097df4f
commit 13d10885b7
5 changed files with 144 additions and 17 deletions

View File

@@ -15,14 +15,17 @@
</template>
<script setup lang="ts">
import { ref, reactive, computed, onUnmounted } from 'vue'
import { ref, reactive, computed, onUnmounted, onMounted, nextTick } from 'vue'
import List from './List.vue'
import Input from '../../components/Input.vue'
import { fetchAgentReply } from '@/api/agent'
import type { AgentParamsType } from '@/api/agent'
import { useUserInfoStore } from '@/stores'
import { useAgentStore } from '@/stores/agent'
const userStore = useUserInfoStore()
const agentStore = useAgentStore()
const props = withDefaults(
defineProps<{
title: string
@@ -35,10 +38,10 @@
const messageList = ref([])
const listRef = ref()
const params = reactive<AgentParamsType>({
threadId: '',
projectID: '',
message: '',
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyIiwiaWF0IjoxNzcwNzkxMzEyLCJleHAiOjE3NzA4Nzc3MTJ9.xydPinm9l5Yq6GMkfaaVvdHjiINaYrp5VkRM7B9g83A',
checkpointId: '',
token: userStore.state.token,
versionID: '',
configParams: {
type: 'Chair',
region: 'China',
@@ -54,7 +57,32 @@
abort.abort()
})
const handleSendMessage = async (message: string) => {
onMounted(() => {
// 检查 store 中是否有初始项目数据
const initialData = agentStore.getInitialProjectData
if (initialData) {
// 等待页面渲染完成后自动发送初始消息
params.configParams = {
type: initialData.type || 'Chair',
region: initialData.area || 'China',
style: initialData.style || 'Transitional',
temperature: 0.7
}
handleSendMessage({
text: initialData.text,
images: initialData.images
})
// 更新 configParams
// 清空初始数据
agentStore.clearInitialProjectData()
}
})
const handleSendMessage = async (message: {
text: string
images: Array<{ url: string; name: string }>
}) => {
console.log('Message sent:', message)
params.message = message.text
params.imageUrlList = message.images || []
@@ -77,7 +105,6 @@
})
messageList.value.push(aiMessage)
// const threadId = '' //
// console.log('token---', params.token, '参数---', params)
try {
@@ -161,9 +188,9 @@
try {
const jsonData = JSON.parse(jsonText)
// 赋值 thread_id 和 checkpoint_id
if (jsonData.thread_id) params.threadId = jsonData.thread_id
if (jsonData.checkpoint_id) params.checkpointId = jsonData.checkpoint_id
// 赋值 project_id 和 version_id
if (jsonData.project_id) params.projectID = jsonData.project_id
if (jsonData.version_id) params.versionID = jsonData.version_id
if (
jsonData.content &&
jsonData.content.length > 0 &&
@@ -243,7 +270,7 @@
.agent-body {
padding: 3.2rem;
overflow: hidden;
row-gap: 2.4rem;
row-gap: 2.4rem;
.assist-input-wrapper {
width: 100%;
height: 14.4rem;