【增加】AI 角色使用

This commit is contained in:
cherishsince 2024-05-15 23:57:41 +08:00
parent e7643c0343
commit 490b11aa3a
2 changed files with 23 additions and 4 deletions

View File

@ -33,7 +33,7 @@
</div> </div>
<div class="btn-container"> <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>
</div> </div>
</el-card> </el-card>
@ -53,7 +53,8 @@ const props = defineProps({
} }
}) })
// //
const emits = defineEmits(['onDelete', 'onEdit']) const emits = defineEmits(['onDelete', 'onEdit', 'onUse'])
// more // more
const handleMoreClick = async (data) => { const handleMoreClick = async (data) => {
const type = data[0] const type = data[0]
@ -65,6 +66,11 @@ const handleMoreClick = async (data) => {
} }
} }
// 使
const handleUseClick = (role) => {
emits('onUse', role)
}
onMounted(() => { onMounted(() => {
console.log('props', props.roleList) console.log('props', props.roleList)
}) })

View File

@ -23,7 +23,7 @@
<!-- tabs --> <!-- tabs -->
<el-tabs v-model="activeRole" class="tabs" @tab-click="handleTabsClick"> <el-tabs v-model="activeRole" class="tabs" @tab-click="handleTabsClick">
<el-tab-pane class="role-pane" label="我的角色" name="my-role"> <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>
<el-tab-pane label="公共角色" name="public-role"> <el-tab-pane label="公共角色" name="public-role">
<RoleCategoryList :category-list="categoryList" :active="activeCategory" @onCategoryClick="handlerCategoryClick" /> <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 ChatRoleForm from '@/views/ai/model/chatRole/ChatRoleForm.vue'
import RoleCategoryList from './RoleCategoryList.vue' import RoleCategoryList from './RoleCategoryList.vue'
import {ChatRoleApi, ChatRolePageReqVO, ChatRoleVO} from '@/api/ai/model/chatRole' import {ChatRoleApi, ChatRolePageReqVO, ChatRoleVO} from '@/api/ai/model/chatRole'
import {ChatConversationApi, ChatConversationVO} from '@/api/ai/chat/conversation'
import {TabsPaneContext} from "element-plus"; import {TabsPaneContext} from "element-plus";
import {Search, User} from "@element-plus/icons-vue"; import {Search, User} from "@element-plus/icons-vue";
//
const router = useRouter()
// //
const activeRole = ref<string>('my-role') // const activeRole = ref<string>('my-role') //
const loadding = ref<boolean>(true) // const loadding = ref<boolean>(true) //
@ -136,6 +140,16 @@ const handlerCardEdit = async (role) => {
formRef.value.open('my-update', role.id, '编辑角色') 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) => { const handlerAddRoleSuccess = async (e) => {
console.log(e) console.log(e)
@ -143,7 +157,6 @@ const handlerAddRoleSuccess = async (e) => {
await getActiveTabsRole() await getActiveTabsRole()
} }
// //
onMounted( async () => { onMounted( async () => {
// //