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;

View File

@@ -94,6 +94,11 @@
@click="selectStyle(item.value)"
>
<span class="fida-option-label">{{ $t(item.label) }}</span>
<img
v-show="tempSelectedValue === item.value"
src="@/assets/images/checked.png"
class="checked-item-icon"
/>
</div>
</div>
<div class="fida-style-popover-footer flex flex-center">
@@ -138,7 +143,11 @@
</el-popover>
</div>
<div class="right">
<div class="create-btn flex flex-center" v-if="!isAgentMode">
<div
class="create-btn flex flex-center"
v-if="!isAgentMode"
@click="handleCreateProject"
>
<img src="@/assets/images/shining.png" class="shining-icon" alt="" />
<span class="create-btn-text">{{ $t('Input.createProject') }}</span>
</div>
@@ -161,10 +170,15 @@
import { computed, ref, watch, nextTick, onMounted } from 'vue'
import { areaList } from '@/utils/area'
import { useI18n } from 'vue-i18n'
import { useRouter } from 'vue-router'
import { useAgentStore } from '@/stores/agent'
import lightIcon from '@/assets/images/light-icon.png'
import closeIcon from '@/assets/images/close-icon.png'
// import Tag from './Tag.vue'
const router = useRouter()
const agentStore = useAgentStore()
const props = withDefaults(
defineProps<{
isAgentMode?: boolean
@@ -305,7 +319,11 @@
if (reportTags.value.length > 0) {
// 移除所有标签及其关联的零宽空格
reportTags.value.forEach((tag) => {
if (tag.nextSibling && tag.nextSibling.nodeType === Node.TEXT_NODE && tag.nextSibling.textContent === '\u200B') {
if (
tag.nextSibling &&
tag.nextSibling.nodeType === Node.TEXT_NODE &&
tag.nextSibling.textContent === '\u200B'
) {
tag.nextSibling.remove()
}
tag.remove()
@@ -480,6 +498,27 @@
value: key
}))
)
const handleCreateProject = () => {
// 这里可以添加创建项目的逻辑
const params = {
type: typeValue.value,
area: areaValue.value,
style: styleValue.value
}
// 保存初始数据到 store
agentStore.setInitialProjectData({
text: inputValue.value.trim(),
images: uploadedImages.value,
type: typeValue.value,
area: areaValue.value,
style: styleValue.value
})
console.log('Create project with:', params)
router.push('/home/agent', { query: params })
}
</script>
<style lang="less" scoped>
@@ -502,7 +541,7 @@
border-radius: 2.2rem;
width: 20rem;
background-color: #fff;
border: 1px solid #F6F4EF;
border: 1px solid #f6f4ef;
column-gap: 1.2rem;
cursor: pointer;
.c-svg {
@@ -727,14 +766,21 @@
font-size: 1.6rem;
color: #000;
margin-bottom: 2rem;
padding: 2rem 2.4rem !important;
// padding: 1.8rem 2rem 1.5rem;
// border-bottom: 0.1rem solid #f0f0f0;
}
.fida-style-popover-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
display: flex;
flex-wrap: wrap;
gap: 1rem;
justify-content: center;
height: 28.5rem;
overflow-y: auto;
// display: grid;
// grid-template-columns: repeat(3, 1fr);
// gap: 1rem;
}
.fida-style-popover-item {
@@ -747,6 +793,15 @@
justify-content: center;
cursor: pointer;
transition: all 0.2s ease;
position: relative;
.checked-item-icon {
position: absolute;
bottom: 0;
right: 0;
transform: translate(50%, 50%);
width: 2.4rem;
height: 2.4rem;
}
}
.fida-style-popover-item:hover {
@@ -772,6 +827,7 @@
.fida-style-popover-footer {
// border-top: 0.1rem solid #f0f0f0;
padding: 2.4rem 0 !important;
margin-top: 2.4rem;
.fida-confirm-btn {
margin: 0 auto;