feat: 对话跳转
This commit is contained in:
@@ -3,8 +3,8 @@ import request from '@/utils/request'
|
|||||||
// 对话
|
// 对话
|
||||||
export interface AgentParamsType {
|
export interface AgentParamsType {
|
||||||
message: string // 消息
|
message: string // 消息
|
||||||
threadId: string // 对话ID
|
projectID: string //
|
||||||
checkpointId?: string // 检查点ID
|
versionID?: string //
|
||||||
imageUrlList?: string[] // 图片URL列表
|
imageUrlList?: string[] // 图片URL列表
|
||||||
configParams: Record<string, any> // 其他配置参数
|
configParams: Record<string, any> // 其他配置参数
|
||||||
token: string
|
token: string
|
||||||
|
|||||||
BIN
src/assets/images/checked.png
Normal file
BIN
src/assets/images/checked.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 796 B |
44
src/stores/agent.ts
Normal file
44
src/stores/agent.ts
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
// 每一个存储的模块,命名规则use开头,store结尾
|
||||||
|
import router from '@/router'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import { ref, computed } from 'vue'
|
||||||
|
import { removeLocal, setLocal } from '@/utils/local'
|
||||||
|
import MyEvent from '@/utils/myEvent'
|
||||||
|
|
||||||
|
|
||||||
|
// Agent 项目初始数据 store
|
||||||
|
export const useAgentStore = defineStore('agent', () => {
|
||||||
|
const initialProjectData = ref<{
|
||||||
|
text: string
|
||||||
|
images: Array<{ url: string; name: string }>
|
||||||
|
type: string
|
||||||
|
area: string
|
||||||
|
style: string
|
||||||
|
} | null>(null)
|
||||||
|
|
||||||
|
// 保存项目初始数据
|
||||||
|
const setInitialProjectData = (data: {
|
||||||
|
text: string
|
||||||
|
images: Array<{ url: string; name: string }>
|
||||||
|
type: string
|
||||||
|
area: string
|
||||||
|
style: string
|
||||||
|
}) => {
|
||||||
|
initialProjectData.value = data
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取项目初始数据
|
||||||
|
const getInitialProjectData = computed(() => initialProjectData.value)
|
||||||
|
|
||||||
|
// 清空项目初始数据
|
||||||
|
const clearInitialProjectData = () => {
|
||||||
|
initialProjectData.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
initialProjectData,
|
||||||
|
setInitialProjectData,
|
||||||
|
getInitialProjectData,
|
||||||
|
clearInitialProjectData
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -15,14 +15,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<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 List from './List.vue'
|
||||||
import Input from '../../components/Input.vue'
|
import Input from '../../components/Input.vue'
|
||||||
import { fetchAgentReply } from '@/api/agent'
|
import { fetchAgentReply } from '@/api/agent'
|
||||||
import type { AgentParamsType } from '@/api/agent'
|
import type { AgentParamsType } from '@/api/agent'
|
||||||
import { useUserInfoStore } from '@/stores'
|
import { useUserInfoStore } from '@/stores'
|
||||||
|
import { useAgentStore } from '@/stores/agent'
|
||||||
|
|
||||||
const userStore = useUserInfoStore()
|
const userStore = useUserInfoStore()
|
||||||
|
const agentStore = useAgentStore()
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
title: string
|
title: string
|
||||||
@@ -35,10 +38,10 @@
|
|||||||
const messageList = ref([])
|
const messageList = ref([])
|
||||||
const listRef = ref()
|
const listRef = ref()
|
||||||
const params = reactive<AgentParamsType>({
|
const params = reactive<AgentParamsType>({
|
||||||
threadId: '',
|
projectID: '',
|
||||||
message: '',
|
message: '',
|
||||||
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyIiwiaWF0IjoxNzcwNzkxMzEyLCJleHAiOjE3NzA4Nzc3MTJ9.xydPinm9l5Yq6GMkfaaVvdHjiINaYrp5VkRM7B9g83A',
|
token: userStore.state.token,
|
||||||
checkpointId: '',
|
versionID: '',
|
||||||
configParams: {
|
configParams: {
|
||||||
type: 'Chair',
|
type: 'Chair',
|
||||||
region: 'China',
|
region: 'China',
|
||||||
@@ -54,7 +57,32 @@
|
|||||||
abort.abort()
|
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)
|
console.log('Message sent:', message)
|
||||||
params.message = message.text
|
params.message = message.text
|
||||||
params.imageUrlList = message.images || []
|
params.imageUrlList = message.images || []
|
||||||
@@ -77,7 +105,6 @@
|
|||||||
})
|
})
|
||||||
messageList.value.push(aiMessage)
|
messageList.value.push(aiMessage)
|
||||||
|
|
||||||
// const threadId = '' //
|
|
||||||
// console.log('token---', params.token, '参数---', params)
|
// console.log('token---', params.token, '参数---', params)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -161,9 +188,9 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const jsonData = JSON.parse(jsonText)
|
const jsonData = JSON.parse(jsonText)
|
||||||
// 赋值 thread_id 和 checkpoint_id
|
// 赋值 project_id 和 version_id
|
||||||
if (jsonData.thread_id) params.threadId = jsonData.thread_id
|
if (jsonData.project_id) params.projectID = jsonData.project_id
|
||||||
if (jsonData.checkpoint_id) params.checkpointId = jsonData.checkpoint_id
|
if (jsonData.version_id) params.versionID = jsonData.version_id
|
||||||
if (
|
if (
|
||||||
jsonData.content &&
|
jsonData.content &&
|
||||||
jsonData.content.length > 0 &&
|
jsonData.content.length > 0 &&
|
||||||
@@ -243,7 +270,7 @@
|
|||||||
.agent-body {
|
.agent-body {
|
||||||
padding: 3.2rem;
|
padding: 3.2rem;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
row-gap: 2.4rem;
|
row-gap: 2.4rem;
|
||||||
.assist-input-wrapper {
|
.assist-input-wrapper {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 14.4rem;
|
height: 14.4rem;
|
||||||
|
|||||||
@@ -94,6 +94,11 @@
|
|||||||
@click="selectStyle(item.value)"
|
@click="selectStyle(item.value)"
|
||||||
>
|
>
|
||||||
<span class="fida-option-label">{{ $t(item.label) }}</span>
|
<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>
|
</div>
|
||||||
<div class="fida-style-popover-footer flex flex-center">
|
<div class="fida-style-popover-footer flex flex-center">
|
||||||
@@ -138,7 +143,11 @@
|
|||||||
</el-popover>
|
</el-popover>
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<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="" />
|
<img src="@/assets/images/shining.png" class="shining-icon" alt="" />
|
||||||
<span class="create-btn-text">{{ $t('Input.createProject') }}</span>
|
<span class="create-btn-text">{{ $t('Input.createProject') }}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -161,10 +170,15 @@
|
|||||||
import { computed, ref, watch, nextTick, onMounted } from 'vue'
|
import { computed, ref, watch, nextTick, onMounted } from 'vue'
|
||||||
import { areaList } from '@/utils/area'
|
import { areaList } from '@/utils/area'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
import { useAgentStore } from '@/stores/agent'
|
||||||
import lightIcon from '@/assets/images/light-icon.png'
|
import lightIcon from '@/assets/images/light-icon.png'
|
||||||
import closeIcon from '@/assets/images/close-icon.png'
|
import closeIcon from '@/assets/images/close-icon.png'
|
||||||
// import Tag from './Tag.vue'
|
// import Tag from './Tag.vue'
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
const agentStore = useAgentStore()
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
isAgentMode?: boolean
|
isAgentMode?: boolean
|
||||||
@@ -305,7 +319,11 @@
|
|||||||
if (reportTags.value.length > 0) {
|
if (reportTags.value.length > 0) {
|
||||||
// 移除所有标签及其关联的零宽空格
|
// 移除所有标签及其关联的零宽空格
|
||||||
reportTags.value.forEach((tag) => {
|
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.nextSibling.remove()
|
||||||
}
|
}
|
||||||
tag.remove()
|
tag.remove()
|
||||||
@@ -480,6 +498,27 @@
|
|||||||
value: key
|
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>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
@@ -502,7 +541,7 @@
|
|||||||
border-radius: 2.2rem;
|
border-radius: 2.2rem;
|
||||||
width: 20rem;
|
width: 20rem;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border: 1px solid #F6F4EF;
|
border: 1px solid #f6f4ef;
|
||||||
column-gap: 1.2rem;
|
column-gap: 1.2rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
.c-svg {
|
.c-svg {
|
||||||
@@ -727,14 +766,21 @@
|
|||||||
font-size: 1.6rem;
|
font-size: 1.6rem;
|
||||||
color: #000;
|
color: #000;
|
||||||
margin-bottom: 2rem;
|
margin-bottom: 2rem;
|
||||||
|
padding: 2rem 2.4rem !important;
|
||||||
// padding: 1.8rem 2rem 1.5rem;
|
// padding: 1.8rem 2rem 1.5rem;
|
||||||
// border-bottom: 0.1rem solid #f0f0f0;
|
// border-bottom: 0.1rem solid #f0f0f0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fida-style-popover-grid {
|
.fida-style-popover-grid {
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-template-columns: repeat(3, 1fr);
|
flex-wrap: wrap;
|
||||||
gap: 1rem;
|
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 {
|
.fida-style-popover-item {
|
||||||
@@ -747,6 +793,15 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.2s ease;
|
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 {
|
.fida-style-popover-item:hover {
|
||||||
@@ -772,6 +827,7 @@
|
|||||||
|
|
||||||
.fida-style-popover-footer {
|
.fida-style-popover-footer {
|
||||||
// border-top: 0.1rem solid #f0f0f0;
|
// border-top: 0.1rem solid #f0f0f0;
|
||||||
|
padding: 2.4rem 0 !important;
|
||||||
margin-top: 2.4rem;
|
margin-top: 2.4rem;
|
||||||
.fida-confirm-btn {
|
.fida-confirm-btn {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
|||||||
Reference in New Issue
Block a user