Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
490b11aa
authored
May 15, 2024
by
cherishsince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【增加】AI 角色使用
parent
e7643c03
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
src/views/ai/chat/role/RoleList.vue
+8
-2
src/views/ai/chat/role/index.vue
+15
-2
No files found.
src/views/ai/chat/role/RoleList.vue
View file @
490b11aa
...
...
@@ -33,7 +33,7 @@
</div>
<div
class=
"btn-container"
>
<el-button
type=
"primary"
size=
"small"
>
使用
</el-button>
<el-button
type=
"primary"
size=
"small"
@
click=
"handleUseClick(role)"
>
使用
</el-button>
</div>
</div>
</el-card>
...
...
@@ -53,7 +53,8 @@ const props = defineProps({
}
})
// 定义钩子
const
emits
=
defineEmits
([
'onDelete'
,
'onEdit'
])
const
emits
=
defineEmits
([
'onDelete'
,
'onEdit'
,
'onUse'
])
// more 点击
const
handleMoreClick
=
async
(
data
)
=>
{
const
type
=
data
[
0
]
...
...
@@ -65,6 +66,11 @@ const handleMoreClick = async (data) => {
}
}
// 使用
const
handleUseClick
=
(
role
)
=>
{
emits
(
'onUse'
,
role
)
}
onMounted
(()
=>
{
console
.
log
(
'props'
,
props
.
roleList
)
})
...
...
src/views/ai/chat/role/index.vue
View file @
490b11aa
...
...
@@ -23,7 +23,7 @@
<!-- tabs -->
<el-tabs
v-model=
"activeRole"
class=
"tabs"
@
tab-click=
"handleTabsClick"
>
<el-tab-pane
class=
"role-pane"
label=
"我的角色"
name=
"my-role"
>
<RoleList
:role-list=
"myRoleList"
@
onDelete=
"handlerCardDelete"
@
onEdit=
"handlerCardEdit"
style=
"margin-top: 20px;"
/>
<RoleList
:role-list=
"myRoleList"
@
onDelete=
"handlerCardDelete"
@
onEdit=
"handlerCardEdit"
@
onUse=
"handlerCardUse"
style=
"margin-top: 20px;"
/>
</el-tab-pane>
<el-tab-pane
label=
"公共角色"
name=
"public-role"
>
<RoleCategoryList
:category-list=
"categoryList"
:active=
"activeCategory"
@
onCategoryClick=
"handlerCategoryClick"
/>
...
...
@@ -43,9 +43,13 @@ import RoleList from './RoleList.vue'
import
ChatRoleForm
from
'@/views/ai/model/chatRole/ChatRoleForm.vue'
import
RoleCategoryList
from
'./RoleCategoryList.vue'
import
{
ChatRoleApi
,
ChatRolePageReqVO
,
ChatRoleVO
}
from
'@/api/ai/model/chatRole'
import
{
ChatConversationApi
,
ChatConversationVO
}
from
'@/api/ai/chat/conversation'
import
{
TabsPaneContext
}
from
"element-plus"
;
import
{
Search
,
User
}
from
"@element-plus/icons-vue"
;
// 获取路由
const
router
=
useRouter
()
// 属性定义
const
activeRole
=
ref
<
string
>
(
'my-role'
)
// 选中的角色
const
loadding
=
ref
<
boolean
>
(
true
)
// 加载中
...
...
@@ -136,6 +140,16 @@ const handlerCardEdit = async (role) => {
formRef
.
value
.
open
(
'my-update'
,
role
.
id
,
'编辑角色'
)
}
// card 使用
const
handlerCardUse
=
async
(
role
)
=>
{
const
data
:
ChatConversationVO
=
{
roleId
:
role
.
id
}
as
unknown
as
ChatConversationVO
// 创建对话
const
conversation
=
await
ChatConversationApi
.
createChatConversationMy
(
data
)
}
// 添加角色成功
const
handlerAddRoleSuccess
=
async
(
e
)
=>
{
console
.
log
(
e
)
...
...
@@ -143,7 +157,6 @@ const handlerAddRoleSuccess = async (e) => {
await
getActiveTabsRole
()
}
//
onMounted
(
async
()
=>
{
// 获取分类
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment