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
3e0da37e
authored
May 15, 2024
by
cherishsince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【增加】增加仓库分类
parent
986f50c6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
13 deletions
+89
-13
src/api/ai/model/chatRole/index.ts
+6
-1
src/views/ai/chat/role/RoleCategoryList.vue
+46
-0
src/views/ai/chat/role/index.vue
+37
-12
No files found.
src/api/ai/model/chatRole/index.ts
View file @
3e0da37e
...
@@ -51,7 +51,12 @@ export const ChatRoleApi = {
...
@@ -51,7 +51,12 @@ export const ChatRoleApi = {
},
},
// 获取 my role
// 获取 my role
getMy
Rol
e
:
async
(
params
:
ChatRolePageReqVO
)
=>
{
getMy
Pag
e
:
async
(
params
:
ChatRolePageReqVO
)
=>
{
return
await
request
.
get
({
url
:
`/ai/chat-role/my-page`
,
params
})
return
await
request
.
get
({
url
:
`/ai/chat-role/my-page`
,
params
})
},
// 获取角色分类
getCategoryList
:
async
()
=>
{
return
await
request
.
get
({
url
:
`/ai/chat-role/category-list`
})
}
}
}
}
src/views/ai/chat/role/RoleCategoryList.vue
0 → 100644
View file @
3e0da37e
<
template
>
<div
class=
"category-list"
>
<div
class=
"category"
v-for=
"category in categoryList"
:key=
"category"
>
<el-button
plain
v-if=
"category !== active"
@
click=
"handleCategoryClick(category)"
>
{{
category
}}
</el-button>
<el-button
plain
type=
"primary"
v-else
@
click=
"handleCategoryClick(category)"
>
{{
category
}}
</el-button>
</div>
</div>
</
template
>
<
script
setup
lang=
"ts"
>
import
{
PropType
}
from
"vue"
;
// 定义属性
defineProps
({
categoryList
:
{
type
:
Array
as
PropType
<
string
[]
>
,
required
:
true
},
active
:
{
type
:
String
,
required
:
false
}
})
// 定义回调
const
emits
=
defineEmits
([
'onCategoryClick'
])
// 处理分类点击事件
const
handleCategoryClick
=
async
(
category
)
=>
{
emits
(
'onCategoryClick'
,
category
)
}
</
script
>
<
style
scoped
lang=
"scss"
>
.category-list
{
display
:
flex
;
flex-direction
:
row
;
flex-wrap
:
wrap
;
align-items
:
center
;
.category
{
display
:
flex
;
flex-direction
:
row
;
margin-right
:
20px
;
}
}
</
style
>
src/views/ai/chat/role/index.vue
View file @
3e0da37e
...
@@ -4,8 +4,9 @@
...
@@ -4,8 +4,9 @@
<Header
title=
"角色仓库"
/>
<Header
title=
"角色仓库"
/>
<el-main
class=
"role-main"
>
<el-main
class=
"role-main"
>
<el-tabs
v-model=
"activeRole"
class=
"demo-tabs"
@
tab-click=
"handleTabsClick"
>
<el-tabs
v-model=
"activeRole"
class=
"demo-tabs"
@
tab-click=
"handleTabsClick"
>
<el-tab-pane
label=
"我的角色"
name=
"my-role"
>
<el-tab-pane
class=
"role-pane"
label=
"我的角色"
name=
"my-role"
>
<RoleList
:role-list=
"myRoleList"
/>
<RoleCategoryList
:category-list=
"categoryList"
:active=
"activeCategory"
@
onCategoryClick=
"handlerCategoryClick"
/>
<RoleList
:role-list=
"myRoleList"
style=
"margin-top: 20px;"
/>
</el-tab-pane>
</el-tab-pane>
<el-tab-pane
label=
"公共角色"
name=
"public-role"
>
<el-tab-pane
label=
"公共角色"
name=
"public-role"
>
<RoleList
:role-list=
"publicRoleList"
/>
<RoleList
:role-list=
"publicRoleList"
/>
...
@@ -20,6 +21,7 @@
...
@@ -20,6 +21,7 @@
import
{
ref
}
from
"vue"
;
import
{
ref
}
from
"vue"
;
import
Header
from
'@/views/ai/chat/components/Header.vue'
import
Header
from
'@/views/ai/chat/components/Header.vue'
import
RoleList
from
'./RoleList.vue'
import
RoleList
from
'./RoleList.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
{
TabsPaneContext
}
from
"element-plus"
;
import
{
TabsPaneContext
}
from
"element-plus"
;
...
@@ -32,6 +34,8 @@ const myRoleList = ref<ChatRoleVO[]>([]) // my 分页大小
...
@@ -32,6 +34,8 @@ const myRoleList = ref<ChatRoleVO[]>([]) // my 分页大小
const
publicPageNo
=
ref
<
number
>
(
1
)
// public 分页下标
const
publicPageNo
=
ref
<
number
>
(
1
)
// public 分页下标
const
publicPageSize
=
ref
<
number
>
(
50
)
// public 分页大小
const
publicPageSize
=
ref
<
number
>
(
50
)
// public 分页大小
const
publicRoleList
=
ref
<
ChatRoleVO
[]
>
([])
// public 分页大小
const
publicRoleList
=
ref
<
ChatRoleVO
[]
>
([])
// public 分页大小
const
activeCategory
=
ref
<
string
>
(
'writing'
)
// 选择中的分类
const
categoryList
=
ref
<
string
[]
>
([])
// 角色分类类别
// tabs 点击
// tabs 点击
const
handleTabsClick
=
async
(
tab
:
TabsPaneContext
)
=>
{
const
handleTabsClick
=
async
(
tab
:
TabsPaneContext
)
=>
{
...
@@ -43,41 +47,57 @@ const handleTabsClick = async (tab: TabsPaneContext) => {
...
@@ -43,41 +47,57 @@ const handleTabsClick = async (tab: TabsPaneContext) => {
}
}
// 获取 my role
// 获取 my role
const
getMyRole
=
async
(
pageNo
:
number
,
pageSize
:
number
)
=>
{
const
getMyRole
=
async
(
pageNo
:
number
,
pageSize
:
number
,
category
?:
string
)
=>
{
const
params
:
ChatRolePageReqVO
=
{
const
params
:
ChatRolePageReqVO
=
{
pageNo
,
pageNo
,
pageSize
,
pageSize
,
category
,
publicStatus
:
false
publicStatus
:
false
}
}
const
{
total
,
list
}
=
await
ChatRoleApi
.
getMy
Rol
e
(
params
)
const
{
total
,
list
}
=
await
ChatRoleApi
.
getMy
Pag
e
(
params
)
myRoleList
.
value
=
list
myRoleList
.
value
=
list
console
.
log
(
'myRoleList 获取成功'
,
list
)
console
.
log
(
'myRoleList 获取成功'
,
myRoleList
.
value
)
}
}
// 获取 public role
// 获取 public role
const
getPublicRole
=
async
(
pageNo
:
number
,
pageSize
:
number
)
=>
{
const
getPublicRole
=
async
(
pageNo
:
number
,
pageSize
:
number
,
category
?:
string
)
=>
{
const
params
:
ChatRolePageReqVO
=
{
const
params
:
ChatRolePageReqVO
=
{
pageNo
,
pageNo
,
pageSize
,
pageSize
,
category
,
publicStatus
:
true
publicStatus
:
true
}
}
const
{
total
,
list
}
=
await
ChatRoleApi
.
getMyRole
(
params
)
const
{
total
,
list
}
=
await
ChatRoleApi
.
getMyPage
(
params
)
console
.
log
(
list
)
publicRoleList
.
value
=
list
publicRoleList
.
value
=
list
}
}
// 获取选中的 tabs 角色
// 获取选中的 tabs 角色
const
getActiveTabsRole
=
async
()
=>
{
const
getActiveTabsRole
=
async
(
category
?:
string
)
=>
{
if
(
activeRole
.
value
===
'my-role'
)
{
if
(
activeRole
.
value
===
'my-role'
)
{
await
getMyRole
(
myPageNo
.
value
,
myPageSize
.
value
)
await
getMyRole
(
myPageNo
.
value
,
myPageSize
.
value
,
category
)
}
else
{
}
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
()
=>
{
onMounted
(
async
()
=>
{
// 获取分类
await
getRoleCategoryList
()
// 获取 role 数据
// 获取 role 数据
await
getActiveTabsRole
()
await
getActiveTabsRole
()
})
})
...
@@ -103,6 +123,11 @@ onMounted( async () => {
...
@@ -103,6 +123,11 @@ onMounted( async () => {
.role-main
{
.role-main
{
.role-pane
{
display
:
flex
;
flex-direction
:
column
;
}
}
}
}
}
...
...
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