ai agent 列表页点击记录或查看进入ai chat 对话界面时,用新标签打开
This commit is contained in:
parent
dc9f9d23dc
commit
90fb24e556
@ -29,22 +29,24 @@ onMounted(() => {
|
||||
) {
|
||||
const agentName = to.params.id as string
|
||||
if (agentName && agentName !== 'new' && !agentName.startsWith('new-')) {
|
||||
// 先同步打开空白窗口(浏览器不会拦截同步 window.open),再异步创建对话
|
||||
const newTab = window.open('', '_blank')!
|
||||
try {
|
||||
const result = await createChat(
|
||||
undefined, undefined, undefined, 'Ai Agent', agentName, agentName,
|
||||
)
|
||||
if (result.success && result.name) {
|
||||
// 重定向到 Ai Chat 列表页(左列表右对话布局),自动选中新对话
|
||||
return {
|
||||
newTab.location.href = router.resolve({
|
||||
name: 'PageTypeList',
|
||||
params: { entity: AI_CHAT_SLUG },
|
||||
query: { selectChat: result.name, agent: agentName },
|
||||
}
|
||||
}).href
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to create agent chat:', e)
|
||||
newTab.close()
|
||||
}
|
||||
return false // 创建失败,取消导航
|
||||
return false // 取消原始导航(到 ai-agent 详情页)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user