Merge branch 'main' of ssh://18.167.251.121:10002/aidlab/FiDA_Front
This commit is contained in:
@@ -3,8 +3,8 @@ import request from '@/utils/request'
|
||||
// 对话
|
||||
export interface AgentParamsType {
|
||||
message: string // 消息
|
||||
threadId: string // 对话ID
|
||||
checkpointId?: string // 检查点ID
|
||||
projectID: string //
|
||||
versionID?: string //
|
||||
imageUrlList?: string[] // 图片URL列表
|
||||
configParams: Record<string, any> // 其他配置参数
|
||||
token: string
|
||||
|
||||
2
src/api/upload.ts
Normal file
2
src/api/upload.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
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
|
||||
}
|
||||
})
|
||||
@@ -13,8 +13,13 @@ export const useProjectStore = defineStore('project', () => {
|
||||
}
|
||||
}
|
||||
|
||||
const setId = id=>{
|
||||
state.value.id = id
|
||||
}
|
||||
|
||||
return {
|
||||
state,
|
||||
setProject,
|
||||
setId
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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 { useUserInfoStore,useProjectStore } from '@/stores'
|
||||
import { useAgentStore } from '@/stores/agent'
|
||||
|
||||
const userStore = useUserInfoStore()
|
||||
const agentStore = useAgentStore()
|
||||
const projectStore = useProjectStore()
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
title: string
|
||||
@@ -35,10 +38,10 @@
|
||||
const messageList = ref([])
|
||||
const listRef = ref()
|
||||
const params = reactive<AgentParamsType>({
|
||||
threadId: '',
|
||||
projectID: '1',
|
||||
message: '',
|
||||
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyIiwiaWF0IjoxNzcwNzkxMzEyLCJleHAiOjE3NzA4Nzc3MTJ9.xydPinm9l5Yq6GMkfaaVvdHjiINaYrp5VkRM7B9g83A',
|
||||
checkpointId: '',
|
||||
token: userStore.state.token,
|
||||
versionID: '',
|
||||
configParams: {
|
||||
type: 'Chair',
|
||||
region: 'China',
|
||||
@@ -54,7 +57,33 @@
|
||||
abort.abort()
|
||||
})
|
||||
|
||||
const handleSendMessage = async (message: string) => {
|
||||
onMounted(() => {
|
||||
// 检查 store 中是否有初始项目数据
|
||||
projectStore.setId('1') // 临时设置项目ID为1,实际应用中应根据上下文动态设置
|
||||
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 +106,6 @@
|
||||
})
|
||||
messageList.value.push(aiMessage)
|
||||
|
||||
// const threadId = '' //
|
||||
// console.log('token---', params.token, '参数---', params)
|
||||
|
||||
try {
|
||||
@@ -151,19 +179,31 @@
|
||||
if (!event.trim()) continue
|
||||
|
||||
// 过滤掉 id: 等字段,只取 data:
|
||||
const dataLines = event
|
||||
.split(/\n/)
|
||||
.filter((line) => line.startsWith('data:'))
|
||||
.map((line) => line.replace(/^data:\s*/, '').trim())
|
||||
|
||||
let isNodeIdEvent = false
|
||||
if(event.startsWith('event:')){
|
||||
isNodeIdEvent = true
|
||||
// continue
|
||||
}
|
||||
|
||||
const dataLines = event
|
||||
.split(/\n/)
|
||||
.filter((line) => line.startsWith('data:'))
|
||||
.map((line) => line.replace(/^data:\s*/, '').trim())
|
||||
console.log('dataLInes',dataLines);
|
||||
if(isNodeIdEvent){
|
||||
params.versionID = dataLines[0]
|
||||
}
|
||||
|
||||
if (dataLines.length === 0) continue
|
||||
const jsonText = dataLines.join('\n')
|
||||
|
||||
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 +283,7 @@
|
||||
.agent-body {
|
||||
padding: 3.2rem;
|
||||
overflow: hidden;
|
||||
row-gap: 2.4rem;
|
||||
row-gap: 2.4rem;
|
||||
.assist-input-wrapper {
|
||||
width: 100%;
|
||||
height: 14.4rem;
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
// return self.renderToken(tokens, idx, options, env, self)
|
||||
// }
|
||||
const str = md.render(props.content.text)
|
||||
console.log('str',str)
|
||||
// console.log('str',str)
|
||||
return str
|
||||
})
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user