diff --git a/src/api/ai/model/chatRole/index.ts b/src/api/ai/model/chatRole/index.ts index 1f962cb9..35aba833 100644 --- a/src/api/ai/model/chatRole/index.ts +++ b/src/api/ai/model/chatRole/index.ts @@ -51,7 +51,12 @@ export const ChatRoleApi = { }, // 获取 my role - getMyRole: async (params: ChatRolePageReqVO) => { + getMyPage: async (params: ChatRolePageReqVO) => { return await request.get({ url: `/ai/chat-role/my-page`, params}) + }, + + // 获取角色分类 + getCategoryList: async () => { + return await request.get({ url: `/ai/chat-role/category-list`}) } } diff --git a/src/views/ai/chat/role/RoleCategoryList.vue b/src/views/ai/chat/role/RoleCategoryList.vue new file mode 100644 index 00000000..549a4416 --- /dev/null +++ b/src/views/ai/chat/role/RoleCategoryList.vue @@ -0,0 +1,46 @@ + + + + {{ category }} + {{ category }} + + + + + diff --git a/src/views/ai/chat/role/index.vue b/src/views/ai/chat/role/index.vue index 0daa3d52..9afc685a 100644 --- a/src/views/ai/chat/role/index.vue +++ b/src/views/ai/chat/role/index.vue @@ -4,8 +4,9 @@ - - + + + @@ -20,6 +21,7 @@ import {ref} from "vue"; import Header from '@/views/ai/chat/components/Header.vue' import RoleList from './RoleList.vue' +import RoleCategoryList from './RoleCategoryList.vue' import {ChatRoleApi, ChatRolePageReqVO, ChatRoleVO} from '@/api/ai/model/chatRole' import {TabsPaneContext} from "element-plus"; @@ -32,6 +34,8 @@ const myRoleList = ref([]) // my 分页大小 const publicPageNo = ref(1) // public 分页下标 const publicPageSize = ref(50) // public 分页大小 const publicRoleList = ref([]) // public 分页大小 +const activeCategory = ref('writing') // 选择中的分类 +const categoryList = ref([]) // 角色分类类别 // tabs 点击 const handleTabsClick = async (tab: TabsPaneContext) => { @@ -43,41 +47,57 @@ const handleTabsClick = async (tab: TabsPaneContext) => { } // 获取 my role -const getMyRole = async (pageNo: number, pageSize: number) => { +const getMyRole = async (pageNo: number, pageSize: number, category?: string) => { const params:ChatRolePageReqVO = { pageNo, pageSize, + category, publicStatus: false } - const { total, list } = await ChatRoleApi.getMyRole(params) + const { total, list } = await ChatRoleApi.getMyPage(params) myRoleList.value = list - console.log('myRoleList 获取成功', list) - console.log('myRoleList 获取成功', myRoleList.value) } // 获取 public role -const getPublicRole = async (pageNo: number, pageSize: number) => { +const getPublicRole = async (pageNo: number, pageSize: number, category?: string) => { const params:ChatRolePageReqVO = { pageNo, pageSize, + category, publicStatus: true } - const { total, list } = await ChatRoleApi.getMyRole(params) - console.log(list) + const { total, list } = await ChatRoleApi.getMyPage(params) publicRoleList.value = list } // 获取选中的 tabs 角色 -const getActiveTabsRole = async () => { +const getActiveTabsRole = async (category?: string) => { if (activeRole.value === 'my-role') { - await getMyRole(myPageNo.value, myPageSize.value) + await getMyRole(myPageNo.value, myPageSize.value, category) } else { - await getPublicRole(myPageNo.value, myPageSize.value) + await getPublicRole(publicPageNo.value, publicPageSize.value, category) } } +// 获取角色分类列表 +const getRoleCategoryList = async () => { + categoryList.value = await ChatRoleApi.getCategoryList() +} + +// 处理分类点击 +const handlerCategoryClick = async (category: string) => { + if (activeCategory.value === category) { + activeCategory.value = '' + } else { + activeCategory.value = category + } + await getActiveTabsRole(activeCategory.value) +} + // onMounted( async () => { + // 获取分类 + await getRoleCategoryList() // 获取 role 数据 await getActiveTabsRole() }) @@ -103,6 +123,11 @@ onMounted( async () => { .role-main { + + .role-pane { + display: flex; + flex-direction: column; + } } }