Merge branch 'main' of ssh://18.167.251.121:10002/aidlab/FiDA_Front
This commit is contained in:
@@ -8,15 +8,10 @@ export interface AgentParamsType {
|
|||||||
imageUrlList?: string[] // 图片URL列表
|
imageUrlList?: string[] // 图片URL列表
|
||||||
configParams: Record<string, any> // 其他配置参数
|
configParams: Record<string, any> // 其他配置参数
|
||||||
token: string
|
token: string
|
||||||
|
needSuggestion?: boolean
|
||||||
|
useReport: bolean
|
||||||
}
|
}
|
||||||
export const fetchAgentReply = (data: AgentParamsType): Promise<AgentResponse> => {
|
export const chatUrl = '/api/ai-design/chat'
|
||||||
return request({
|
|
||||||
url: '/api/ai-design/chat',
|
|
||||||
method: 'get',
|
|
||||||
data,
|
|
||||||
meta: { responseAll: true }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CreateProjectParamsType {
|
export interface CreateProjectParamsType {
|
||||||
type: string
|
type: string
|
||||||
@@ -33,11 +28,11 @@ export const createProject = (data: CreateProjectParamsType): Promise<any> => {
|
|||||||
* @param data 获取项目信息参数
|
* @param data 获取项目信息参数
|
||||||
* @param data.id 项目id
|
* @param data.id 项目id
|
||||||
* @returns 获取项目信息
|
* @returns 获取项目信息
|
||||||
*/
|
*/
|
||||||
export const getProjectInfo = (data) => {
|
export const getProjectInfo = (data) => {
|
||||||
return request({
|
return request({
|
||||||
url: `/api/project/${data.id}`,
|
url: `/api/project/${data.id}`,
|
||||||
method: 'get',
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +42,7 @@ export const getProjectInfo = (data) => {
|
|||||||
* @param params.page 页码
|
* @param params.page 页码
|
||||||
* @param params.size 每页数量
|
* @param params.size 每页数量
|
||||||
* @returns 获取项目版本列表
|
* @returns 获取项目版本列表
|
||||||
*/
|
*/
|
||||||
export const getProjectList = (params) => {
|
export const getProjectList = (params) => {
|
||||||
return request({
|
return request({
|
||||||
url: `/api/project/list`,
|
url: `/api/project/list`,
|
||||||
@@ -66,7 +61,7 @@ export const getProjectList = (params) => {
|
|||||||
* @param data.style 项目风格
|
* @param data.style 项目风格
|
||||||
* @param data.temperature 项目温度
|
* @param data.temperature 项目温度
|
||||||
* @returns 修改项目信息
|
* @returns 修改项目信息
|
||||||
*/
|
*/
|
||||||
export const updateProject = (id: string, data: Object) => {
|
export const updateProject = (id: string, data: Object) => {
|
||||||
return request({
|
return request({
|
||||||
url: `/api/project/${id}`,
|
url: `/api/project/${id}`,
|
||||||
@@ -78,10 +73,10 @@ export const updateProject = (id: string, data: Object) => {
|
|||||||
* 删除项目
|
* 删除项目
|
||||||
* @param id 项目id
|
* @param id 项目id
|
||||||
* @returns 删除项目
|
* @returns 删除项目
|
||||||
*/
|
*/
|
||||||
export const deleteProject = (id: string) => {
|
export const deleteProject = (id: string) => {
|
||||||
return request({
|
return request({
|
||||||
url: `/api/project/${id}`,
|
url: `/api/project/${id}`,
|
||||||
method: 'delete',
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,23 +7,20 @@ import MyEvent from '@/utils/myEvent'
|
|||||||
|
|
||||||
|
|
||||||
// Agent 项目初始数据 store
|
// Agent 项目初始数据 store
|
||||||
export const useAgentStore = defineStore('agent', () => {
|
type InitialProjectData = {
|
||||||
const initialProjectData = ref<{
|
|
||||||
text: string
|
text: string
|
||||||
images: Array<{ url: string; name: string }>
|
images: Array<{ url: string; name: string }>
|
||||||
type: string
|
type: string
|
||||||
area: string
|
area: string
|
||||||
style: string
|
style: string
|
||||||
} | null>(null)
|
useReport:boolean
|
||||||
|
needSuggestion:boolean
|
||||||
|
}
|
||||||
|
export const useAgentStore = defineStore('agent', () => {
|
||||||
|
const initialProjectData = ref<InitialProjectData | null>(null)
|
||||||
|
|
||||||
// 保存项目初始数据
|
// 保存项目初始数据
|
||||||
const setInitialProjectData = (data: {
|
const setInitialProjectData = (data: InitialProjectData) => {
|
||||||
text: string
|
|
||||||
images: Array<{ url: string; name: string }>
|
|
||||||
type: string
|
|
||||||
area: string
|
|
||||||
style: string
|
|
||||||
}) => {
|
|
||||||
initialProjectData.value = data
|
initialProjectData.value = data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,9 @@
|
|||||||
import { ref, reactive, computed, onUnmounted, onMounted, nextTick, watch } from 'vue'
|
import { ref, reactive, computed, onUnmounted, onMounted, nextTick, watch } 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 { chatUrl } from '@/api/agent'
|
||||||
import type { AgentParamsType } from '@/api/agent'
|
import type { AgentParamsType } from '@/api/agent'
|
||||||
import { useUserInfoStore, useProjectStore } from '@/stores'
|
import { useUserInfoStore, useProjectStore, useAgentStore } from '@/stores'
|
||||||
import { useAgentStore } from '@/stores/agent'
|
|
||||||
|
|
||||||
const userStore = useUserInfoStore()
|
const userStore = useUserInfoStore()
|
||||||
const agentStore = useAgentStore()
|
const agentStore = useAgentStore()
|
||||||
@@ -54,6 +53,8 @@
|
|||||||
message: '',
|
message: '',
|
||||||
token: userStore.state.token,
|
token: userStore.state.token,
|
||||||
versionID: '',
|
versionID: '',
|
||||||
|
needSuggestion: false,
|
||||||
|
useReport: false,
|
||||||
configParams: {
|
configParams: {
|
||||||
type: '',
|
type: '',
|
||||||
region: '',
|
region: '',
|
||||||
@@ -99,6 +100,8 @@
|
|||||||
style: initialData.style,
|
style: initialData.style,
|
||||||
temperature: 0.7
|
temperature: 0.7
|
||||||
}
|
}
|
||||||
|
params.needSuggestion = initialData.needSuggestion || false
|
||||||
|
params.useReport = initialData.useReport
|
||||||
handleSendMessage({
|
handleSendMessage({
|
||||||
text: initialData.text,
|
text: initialData.text,
|
||||||
images: initialData.images,
|
images: initialData.images,
|
||||||
@@ -158,7 +161,7 @@
|
|||||||
configParams: JSON.stringify(params.configParams)
|
configParams: JSON.stringify(params.configParams)
|
||||||
})
|
})
|
||||||
const BASEURL = import.meta.env.VITE_APP_URL
|
const BASEURL = import.meta.env.VITE_APP_URL
|
||||||
const response = await fetch(`${BASEURL}/api/ai-design/chat?${urlParams.toString()}`, {
|
const response = await fetch(`${BASEURL}${chatUrl}?${urlParams.toString()}`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
signal: abortController.signal
|
signal: abortController.signal
|
||||||
})
|
})
|
||||||
@@ -371,9 +374,9 @@
|
|||||||
while (i < dialogue.length) {
|
while (i < dialogue.length) {
|
||||||
const item = dialogue[i]
|
const item = dialogue[i]
|
||||||
|
|
||||||
if (item.image_url) {
|
// if (item.image_url) {
|
||||||
existingImgList.push(item.image_url)
|
// existingImgList.push(item.image_url)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (item.role === 'user') {
|
if (item.role === 'user') {
|
||||||
// user 角色直接添加
|
// user 角色直接添加
|
||||||
@@ -391,9 +394,9 @@
|
|||||||
// 继续往后找连续的 assistant 消息
|
// 继续往后找连续的 assistant 消息
|
||||||
let j = i + 1
|
let j = i + 1
|
||||||
while (j < dialogue.length && dialogue[j].role === 'assistant') {
|
while (j < dialogue.length && dialogue[j].role === 'assistant') {
|
||||||
if (dialogue[j].image_url) {
|
// if (dialogue[j].image_url) {
|
||||||
existingImgList.push(dialogue[j].image_url)
|
// existingImgList.push(dialogue[j].image_url)
|
||||||
}
|
// }
|
||||||
combinedContent += dialogue[j].content || ''
|
combinedContent += dialogue[j].content || ''
|
||||||
j++
|
j++
|
||||||
}
|
}
|
||||||
@@ -425,6 +428,7 @@
|
|||||||
const setChatInfo = (info) => {
|
const setChatInfo = (info) => {
|
||||||
const initialData = agentStore.getInitialProjectData
|
const initialData = agentStore.getInitialProjectData
|
||||||
if (isGenerating.value || initialData) return
|
if (isGenerating.value || initialData) return
|
||||||
|
console.log('info0----', info)
|
||||||
|
|
||||||
const data = info.conversation
|
const data = info.conversation
|
||||||
let project = info.project
|
let project = info.project
|
||||||
@@ -448,11 +452,12 @@
|
|||||||
|
|
||||||
const { ancestors, current } = data
|
const { ancestors, current } = data
|
||||||
|
|
||||||
const imgList = []
|
let imgList = []
|
||||||
const ancestorsList = []
|
const ancestorsList = []
|
||||||
let ancestorsIdCounter = 1
|
let ancestorsIdCounter = 1
|
||||||
if (ancestors) {
|
if (ancestors) {
|
||||||
ancestors.forEach((item) => {
|
ancestors.forEach((item) => {
|
||||||
|
imgList = imgList.concat(current.sketchIDAndUrl)
|
||||||
const list = processDialogue(item.dialogue, 0, imgList)
|
const list = processDialogue(item.dialogue, 0, imgList)
|
||||||
// 重新设置 id
|
// 重新设置 id
|
||||||
list.forEach((el) => {
|
list.forEach((el) => {
|
||||||
@@ -462,18 +467,16 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
const currentList = processDialogue(current?.dialogue, 0, imgList)
|
const currentList = processDialogue(current?.dialogue, 0, imgList)
|
||||||
// 重新设置 id
|
imgList = imgList.concat(current.sketchIDAndUrl)
|
||||||
currentList.forEach((el, index) => {
|
currentList.forEach((el, index) => {
|
||||||
el.id = index + 1 + ancestorsList.length
|
el.id = index + 1 + ancestorsList.length
|
||||||
})
|
})
|
||||||
|
|
||||||
// 延迟设置新数据,确保 UI 有时间响应清空操作
|
// 延迟设置新数据,确保 UI 有时间响应清空操作
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
|
|
||||||
messageList.value = [...ancestorsList, ...currentList]
|
messageList.value = [...ancestorsList, ...currentList]
|
||||||
params.versionID = current?.id
|
params.versionID = current?.id
|
||||||
sketchList.value = imgList
|
sketchList.value = imgList
|
||||||
console.log('11111111111111',params.versionID);
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,10 @@
|
|||||||
:key="'sketch-item-' + index"
|
:key="'sketch-item-' + index"
|
||||||
>
|
>
|
||||||
<Menu class="menu-btn" @click="handleClickMenu" />
|
<Menu class="menu-btn" @click="handleClickMenu" />
|
||||||
<div class="edit-btn flex align-center space-between" @click="handleClickEdit">
|
<div
|
||||||
|
class="edit-btn flex align-center space-between"
|
||||||
|
@click="handleClickEdit(item)"
|
||||||
|
>
|
||||||
<div>Edit</div>
|
<div>Edit</div>
|
||||||
<img src="@/assets/images/arrow-top-right.png" />
|
<img src="@/assets/images/arrow-top-right.png" />
|
||||||
</div>
|
</div>
|
||||||
@@ -124,6 +127,9 @@
|
|||||||
import Menu from './Menu.vue'
|
import Menu from './Menu.vue'
|
||||||
import LoadingImg from '@/assets/images/sketch-loading.gif'
|
import LoadingImg from '@/assets/images/sketch-loading.gif'
|
||||||
import reportNull from '@/assets/images/reportNull.png'
|
import reportNull from '@/assets/images/reportNull.png'
|
||||||
|
import myEvent from '@/utils/myEvent'
|
||||||
|
import { useProjectStore } from '@/stores'
|
||||||
|
const projectStore = useProjectStore()
|
||||||
|
|
||||||
// 存储每个图片的加载状态
|
// 存储每个图片的加载状态
|
||||||
const loadedStatus = reactive<Record<number, boolean>>({})
|
const loadedStatus = reactive<Record<number, boolean>>({})
|
||||||
@@ -146,12 +152,19 @@
|
|||||||
|
|
||||||
// 获取当前显示的图片源
|
// 获取当前显示的图片源
|
||||||
const getImageSrc = (item: string, index: number) => {
|
const getImageSrc = (item: string, index: number) => {
|
||||||
|
if (typeof item === 'string') {
|
||||||
return loadedStatus[index] ? item : LoadingImg
|
return loadedStatus[index] ? item : LoadingImg
|
||||||
}
|
}
|
||||||
|
if (typeof item === 'object') {
|
||||||
|
return Object.values(item)[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handleClickEdit = () => {
|
const handleClickEdit = (item: string) => {
|
||||||
// 编辑按钮点击逻辑
|
const url = Object.values(item)[0]
|
||||||
console.log('Edit button clicked')
|
const imgId = Object.keys(item)[0]
|
||||||
|
const nodeId = projectStore.state.nodeId
|
||||||
|
myEvent.emit('openFlowCanvas', { url, imgId, nodeId })
|
||||||
}
|
}
|
||||||
const handleClickMenu = () => {
|
const handleClickMenu = () => {
|
||||||
// 菜单按钮点击逻辑
|
// 菜单按钮点击逻辑
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="editor-wrapper">
|
<div class="editor-wrapper">
|
||||||
<!-- 静态占位符 - 当编辑器为空时显示 -->
|
|
||||||
<div v-if="showPlaceholder" class="editor-placeholder">
|
<div v-if="showPlaceholder" class="editor-placeholder">
|
||||||
{{ $t('Input.placeholder') }}
|
{{ $t('Input.placeholder') }}
|
||||||
</div>
|
</div>
|
||||||
@@ -506,8 +505,9 @@
|
|||||||
|
|
||||||
let node: Node | null
|
let node: Node | null
|
||||||
while ((node = walker.nextNode())) {
|
while ((node = walker.nextNode())) {
|
||||||
if (node.parentElement?.classList.contains('custom-placeholder')) continue
|
// 使用 closest() 检查当前节点的祖先元素是否包含需要排除的 class
|
||||||
if (node.parentElement?.classList.contains('editor-tag')) continue
|
if (node.parentElement?.closest('.custom-placeholder')) continue
|
||||||
|
if (node.parentElement?.closest('.editor-tag')) continue
|
||||||
text += node.textContent
|
text += node.textContent
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -732,14 +732,15 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
const handleCreateProject = async () => {
|
const handleCreateProject = async () => {
|
||||||
// 这里可以添加创建项目的逻辑
|
|
||||||
if (!inputValue.value.trim()) {
|
if (!inputValue.value.trim()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
type: typeValue.value,
|
type: typeValue.value,
|
||||||
area: areaValue.value,
|
area: areaValue.value,
|
||||||
style: styleValue.value,
|
style: styleValue.value,
|
||||||
|
useReport: reportTags.value.length > 0,
|
||||||
temperature: 0.7
|
temperature: 0.7
|
||||||
}
|
}
|
||||||
const projectres = await createProject(params)
|
const projectres = await createProject(params)
|
||||||
@@ -1035,7 +1036,7 @@
|
|||||||
min-height: 5rem;
|
min-height: 5rem;
|
||||||
line-height: 1.4rem;
|
line-height: 1.4rem;
|
||||||
}
|
}
|
||||||
.editor-placeholder{
|
.editor-placeholder {
|
||||||
font-family: 'Regular';
|
font-family: 'Regular';
|
||||||
font-size: 1.4rem;
|
font-size: 1.4rem;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user