Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
chatGLM
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘坚-丰林-DEV
chatGLM
Commits
6732a4f7
Commit
6732a4f7
authored
Apr 19, 2023
by
文旺-丰林-DEV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add prompt word type table
parent
655a0f28
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
375 additions
and
13 deletions
+375
-13
routes.ts
config/routes.ts
+12
-1
index.less
src/components/EditAndAddPromptTypeModal/index.less
+19
-0
index.tsx
src/components/EditAndAddPromptTypeModal/index.tsx
+106
-0
menu.ts
src/locales/zh-CN/menu.ts
+3
-1
index.tsx
src/pages/PromptWord/index.tsx
+6
-0
index.less
src/pages/PromptWordType/index.less
+0
-0
index.tsx
src/pages/PromptWordType/index.tsx
+188
-0
index.tsx
src/pages/UserManage/index.tsx
+1
-0
api.ts
src/services/chatGLM/api.ts
+40
-11
No files found.
config/routes.ts
View file @
6732a4f7
...
...
@@ -16,7 +16,18 @@
name
:
'prompt'
,
icon
:
'table'
,
path
:
'/prompt'
,
component
:
'./PromptWord'
,
routes
:
[
{
path
:
'/prompt/word'
,
name
:
'word'
,
component
:
'./PromptWord'
,
},
{
path
:
'/prompt/type'
,
name
:
'type'
,
component
:
'./PromptWordType'
,
},
],
},
{
name
:
'chat'
,
...
...
src/components/EditAndAddPromptTypeModal/index.less
0 → 100644
View file @
6732a4f7
.edit_type {
display: flex;
align-items: center;
span {
width: 70px;
margin-right: 10px;
}
}
.edit_prompt {
display: flex;
align-items: flex-start;
span {
width: 70px;
margin-right: 10px;
}
}
src/components/EditAndAddPromptTypeModal/index.tsx
0 → 100644
View file @
6732a4f7
import
{
Button
,
Col
,
Divider
,
Form
,
Modal
,
Row
,
Input
}
from
'antd'
;
import
{
useEffect
}
from
'react'
;
import
styles
from
'./index.less'
;
import
type
{
IFormValue
,
ITypeFormValue
}
from
'@/pages/PromptWord'
;
interface
IEditPromptModalProps
{
open
:
boolean
;
setOpen
:
(
value
:
boolean
)
=>
void
;
modalType
:
'create'
|
'edit'
|
''
;
handleEditPrompt
:
(
value
:
ITypeFormValue
)
=>
void
;
oldRow
:
IFormValue
;
loading
?:
boolean
;
handleCreatePrompt
:
(
value
:
ITypeFormValue
)
=>
void
;
}
const
EditPromptTypeModal
=
(
props
:
IEditPromptModalProps
)
=>
{
const
{
open
,
setOpen
,
modalType
,
handleEditPrompt
,
loading
,
oldRow
,
handleCreatePrompt
}
=
props
;
const
[
form
]
=
Form
.
useForm
();
useEffect
(()
=>
{
if
(
modalType
===
'create'
)
{
form
.
resetFields
();
}
if
(
modalType
===
'edit'
)
{
form
.
setFieldsValue
({
type
:
oldRow
.
type
,
});
}
},
[
open
]);
const
handleSavePrompt
=
async
()
=>
{
const
{
type
}
=
form
.
getFieldsValue
();
if
(
modalType
===
'create'
)
{
await
handleCreatePrompt
({
type
,
});
}
if
(
modalType
===
'edit'
)
{
await
handleEditPrompt
({
type
,
});
}
setOpen
(
false
);
};
const
layout
=
{
labelCol
:
{
span
:
4
},
wrapperCol
:
{
span
:
18
},
};
return
(
<
Modal
open=
{
open
}
centered
confirmLoading=
{
loading
}
wrapClassName=
{
styles
.
modal
}
title=
{
modalType
===
'create'
?
'新增提示类型'
:
'编辑提示类型'
}
okText=
"保存"
onOk=
{
()
=>
{
setOpen
(
false
);
}
}
onCancel=
{
()
=>
{
setOpen
(
false
);
}
}
width=
{
574
}
footer=
{
null
}
>
<
Form
form=
{
form
}
name=
"editAndCrateForm"
{
...
layout
}
onFinish=
{
handleSavePrompt
}
>
<
Form
.
Item
label=
"提示类型"
name=
{
'type'
}
rules=
{
[{
required
:
true
,
message
:
'请输入提示类型!'
}]
}
>
<
Input
/>
</
Form
.
Item
>
<
Divider
/>
<
Row
justify=
{
'end'
}
gutter=
{
8
}
>
<
Col
>
<
Form
.
Item
key=
{
'cancelButton'
}
noStyle=
{
true
}
>
<
Button
key=
"back"
onClick=
{
()
=>
{
setOpen
(
false
);
}
}
>
取消
</
Button
>
</
Form
.
Item
>
</
Col
>
<
Col
>
<
Form
.
Item
key=
{
'saveButton'
}
noStyle=
{
true
}
>
<
Button
key=
"submit"
type=
"primary"
loading=
{
loading
}
htmlType=
"submit"
>
保存
</
Button
>
</
Form
.
Item
>
</
Col
>
</
Row
>
</
Form
>
</
Modal
>
);
};
export
default
EditPromptTypeModal
;
src/locales/zh-CN/menu.ts
View file @
6732a4f7
export
default
{
'menu.chat'
:
'AI助手'
,
'menu.prompt.type'
:
'提示类型管理'
,
'menu.prompt.word'
:
'提示词管理'
,
'menu.prompt'
:
'提示词库'
,
'menu.welcome'
:
'欢迎'
,
'menu.user'
:
'用户管理'
,
'menu.more-blocks'
:
'更多区块'
,
'menu.home'
:
'首页'
,
'menu.admin'
:
'账号管理'
,
'menu.admin.user'
:
'用户管理'
,
'menu.prompt'
:
'提示词库'
,
'menu.admin.sub-page'
:
'二级管理页'
,
'menu.login'
:
'登录'
,
'menu.register'
:
'注册'
,
...
...
src/pages/PromptWord/index.tsx
View file @
6732a4f7
...
...
@@ -14,6 +14,7 @@ import {
deletePromptWords
,
typePromptWords
,
}
from
'@/services/chatGLM/api'
;
import
moment
from
'moment'
;
interface
IPromptList
{
id
:
string
;
...
...
@@ -29,6 +30,9 @@ export interface IFormValue {
content
:
string
;
}
export
interface
ITypeFormValue
{
type
:
string
|
null
;
}
interface
ILoading
{
editModalLoading
:
boolean
;
createModalLoading
:
boolean
;
...
...
@@ -139,6 +143,7 @@ const PromptWord = () => {
});
setAllLoading
({
...
allLoading
,
editModalLoading
:
false
});
actionRef
.
current
?.
reload
();
message
.
success
(
'操作成功'
);
}
catch
(
error
)
{
setAllLoading
({
...
allLoading
,
editModalLoading
:
false
});
message
.
error
(
'编辑提示用语失败,请重试'
);
...
...
@@ -154,6 +159,7 @@ const PromptWord = () => {
});
setAllLoading
({
...
allLoading
,
createModalLoading
:
false
});
actionRef
.
current
?.
reload
();
message
.
success
(
'操作成功'
);
}
catch
(
error
)
{
setAllLoading
({
...
allLoading
,
createModalLoading
:
false
});
message
.
error
(
'新增提示用语失败,请重试'
);
...
...
src/pages/PromptWordType/index.less
0 → 100644
View file @
6732a4f7
src/pages/PromptWordType/index.tsx
0 → 100644
View file @
6732a4f7
import
{
PlusOutlined
}
from
'@ant-design/icons'
;
import
{
ActionType
,
PageContainer
}
from
'@ant-design/pro-components'
;
import
{
ProTable
}
from
'@ant-design/pro-components'
;
import
{
Button
,
Space
,
message
}
from
'antd'
;
import
{
isEmpty
}
from
'lodash'
;
import
{
useRef
,
useState
}
from
'react'
;
import
styles
from
'./index.less'
;
import
{
pagePromptWordType
,
createPromptWordType
,
updatePromptWordType
,
}
from
'@/services/chatGLM/api'
;
import
EditPromptTypeModal
from
'@/components/EditAndAddPromptTypeModal'
;
import
{
ITypeFormValue
}
from
'../PromptWord'
;
interface
IPromptList
{
id
:
string
;
title
?:
string
;
content
:
string
;
type
:
string
;
creationTime
:
string
;
sequenceNumber
:
number
;
}
export
interface
IFormValue
{
type
:
string
|
null
;
content
:
string
;
}
interface
ILoading
{
editModalLoading
:
boolean
;
createModalLoading
:
boolean
;
deleteModalLoading
:
boolean
;
listLoading
:
boolean
;
}
const
PromptWordType
=
()
=>
{
const
actionRef
=
useRef
<
ActionType
>
();
const
[
allLoading
,
setAllLoading
]
=
useState
<
ILoading
>
({
editModalLoading
:
false
,
createModalLoading
:
false
,
deleteModalLoading
:
false
,
listLoading
:
false
,
});
const
[
editAndAddModalOpen
,
setEditAndDeleteModalOpen
]
=
useState
(
false
);
const
[
modalType
,
setModalType
]
=
useState
<
'create'
|
'edit'
|
''
>
(
''
);
const
[
currentRow
,
setCurrentRaw
]
=
useState
({}
as
IPromptList
);
const
columns
:
any
[]
=
[
{
title
:
'提示类型'
,
key
:
'type'
,
dataIndex
:
'type'
,
ellipsis
:
true
,
search
:
true
,
order
:
2
,
},
{
title
:
'创建时间'
,
width
:
'25%'
,
key
:
'creationTime'
,
dataIndex
:
'creationTime'
,
search
:
false
,
},
{
title
:
'操作'
,
valueType
:
'option'
,
width
:
'15%'
,
key
:
'option'
,
render
:
(
_
:
unknown
,
record
:
IPromptList
)
=>
(
<
div
className=
{
styles
.
table_action
}
>
<
div
className=
{
styles
.
table_action_edit
}
onClick=
{
()
=>
{
setCurrentRaw
(
record
);
setEditAndDeleteModalOpen
(
true
);
setModalType
(
'edit'
);
}
}
>
<
Button
size=
"small"
type=
"link"
>
编辑
</
Button
>
</
div
>
</
div
>
),
},
];
const
handleEditPrompt
=
async
(
editValue
:
ITypeFormValue
)
=>
{
setAllLoading
({
...
allLoading
,
editModalLoading
:
true
});
try
{
await
updatePromptWordType
({
id
:
currentRow
.
id
,
type
:
editValue
.
type
,
});
setAllLoading
({
...
allLoading
,
editModalLoading
:
false
});
actionRef
.
current
?.
reload
();
message
.
success
(
'操作成功'
);
}
catch
(
error
)
{
setAllLoading
({
...
allLoading
,
editModalLoading
:
false
});
message
.
error
(
'编辑提示类型失败,请重试'
);
}
};
const
handleCreatePrompt
=
async
(
createValue
:
ITypeFormValue
)
=>
{
setAllLoading
({
...
allLoading
,
createModalLoading
:
true
});
try
{
await
createPromptWordType
({
type
:
createValue
.
type
,
});
setAllLoading
({
...
allLoading
,
createModalLoading
:
false
});
actionRef
.
current
?.
reload
();
message
.
success
(
'操作成功'
);
}
catch
(
error
)
{
setAllLoading
({
...
allLoading
,
createModalLoading
:
false
});
message
.
error
(
'新增提示类型失败,请重试'
);
}
};
return
(
<
PageContainer
>
<
EditPromptTypeModal
open=
{
editAndAddModalOpen
}
setOpen=
{
setEditAndDeleteModalOpen
}
modalType=
{
modalType
}
handleEditPrompt=
{
handleEditPrompt
}
oldRow=
{
currentRow
}
handleCreatePrompt=
{
handleCreatePrompt
}
loading=
{
modalType
===
'create'
?
allLoading
.
createModalLoading
:
allLoading
.
editModalLoading
}
/>
<
ProTable
request=
{
async
(
params
=
{
pageSize
:
10
,
current
:
0
})
=>
{
setAllLoading
({
...
allLoading
,
listLoading
:
true
});
const
promptListParams
=
{
filter
:
params
[
'type'
]
||
''
,
pageIndex
:
(
params
?.
current
as
number
)
-
1
,
pageSize
:
params
?.
pageSize
,
};
try
{
const
response
=
await
pagePromptWordType
(
promptListParams
);
setAllLoading
({
...
allLoading
,
listLoading
:
false
});
return
{
data
:
response
.
items
,
total
:
response
.
totalCount
,
success
:
!
isEmpty
(
response
),
};
}
catch
(
error
)
{
setAllLoading
({
...
allLoading
,
listLoading
:
false
});
message
.
error
(
'请求列表失败,请重试'
);
return
{
data
:
[],
total
:
0
,
success
:
false
,
};
}
}
}
actionRef=
{
actionRef
}
columns=
{
columns
}
cardBordered
rowKey=
"id"
pagination=
{
{
pageSize
:
10
,
}
}
options=
{
false
}
headerTitle=
"账号列表"
toolBarRender=
{
()
=>
[
<
Button
key=
"button"
icon=
{
<
PlusOutlined
/>
}
onClick=
{
()
=>
{
setEditAndDeleteModalOpen
(
true
);
setModalType
(
'create'
);
}
}
type=
"primary"
>
添加提示类型
</
Button
>,
]
}
loading=
{
allLoading
.
listLoading
}
/>
</
PageContainer
>
);
};
export
default
PromptWordType
;
src/pages/UserManage/index.tsx
View file @
6732a4f7
...
...
@@ -111,6 +111,7 @@ const UserManage = () => {
title
:
'创建时间'
,
dataIndex
:
'creationTime'
,
hideInSearch
:
true
,
valueType
:
'datetime'
,
},
{
title
:
'操作'
,
...
...
src/services/chatGLM/api.ts
View file @
6732a4f7
...
...
@@ -69,77 +69,106 @@ interface ITalkParams {
temperature
?:
number
;
}
const
host
=
'https://glm-mangement-api.baibaomen.com'
;
export
const
CreatedAccount
=
(
params
:
any
):
Promise
<
string
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com
/User/create'
,
{
return
request
(
host
+
'
/User/create'
,
{
method
:
'POST'
,
body
:
JSON
.
stringify
(
params
),
});
};
export
const
getRole
=
(
params
?:
any
):
Promise
<
string
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com
/User/roles'
,
{
return
request
(
host
+
'
/User/roles'
,
{
method
:
'POST'
,
body
:
JSON
.
stringify
(
params
),
});
};
export
const
getUserMessage
=
(
params
?:
any
):
Promise
<
string
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com
/User/page'
,
{
return
request
(
host
+
'
/User/page'
,
{
method
:
'POST'
,
body
:
JSON
.
stringify
(
params
),
});
};
export
const
createPromptWords
=
(
params
:
any
):
Promise
<
any
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com
/PromptWords/create'
,
{
return
request
(
host
+
'
/PromptWords/create'
,
{
method
:
'POST'
,
data
:
params
,
});
};
export
const
updatePromptWords
=
(
params
:
any
):
Promise
<
any
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com
/PromptWords/update'
,
{
return
request
(
host
+
'
/PromptWords/update'
,
{
method
:
'POST'
,
data
:
params
,
});
};
export
const
deletePromptWords
=
(
params
:
any
):
Promise
<
any
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com
/PromptWords/delete'
,
{
return
request
(
host
+
'
/PromptWords/delete'
,
{
method
:
'POST'
,
data
:
params
,
});
};
export
const
pagePromptWords
=
(
params
:
any
):
Promise
<
any
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com/PromptWords/page'
,
{
return
request
(
host
+
'/PromptWords/page'
,
{
method
:
'POST'
,
data
:
params
,
});
};
export
const
createPromptWordType
=
(
params
:
any
):
Promise
<
any
>
=>
{
return
request
(
host
+
'/PromptWordTypes/create'
,
{
method
:
'POST'
,
data
:
params
,
});
};
export
const
updatePromptWordType
=
(
params
:
any
):
Promise
<
any
>
=>
{
return
request
(
host
+
'/PromptWordTypes/update'
,
{
method
:
'POST'
,
data
:
params
,
});
};
export
const
deletePromptWordType
=
(
params
:
any
):
Promise
<
any
>
=>
{
return
request
(
host
+
'/PromptWordTypes/delete'
,
{
method
:
'POST'
,
data
:
params
,
});
};
export
const
pagePromptWordType
=
(
params
:
any
):
Promise
<
any
>
=>
{
return
request
(
host
+
'/PromptWordTypes/page'
,
{
method
:
'POST'
,
data
:
params
,
});
};
export
const
typePromptWords
=
():
Promise
<
any
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com/PromptWord
s/type'
,
{
return
request
(
host
+
'/PromptWordType
s/type'
,
{
method
:
'POST'
,
});
};
export
const
postDeleteUser
=
(
params
?:
any
):
Promise
<
string
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com
/User/delete'
,
{
return
request
(
host
+
'
/User/delete'
,
{
method
:
'POST'
,
data
:
params
,
});
};
export
const
postResetUser
=
(
params
?:
any
):
Promise
<
string
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com
/User/reset'
,
{
return
request
(
host
+
'
/User/reset'
,
{
method
:
'POST'
,
body
:
JSON
.
stringify
(
params
),
});
};
export
const
postEditUser
=
(
params
?:
any
):
Promise
<
string
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com
/User/update'
,
{
return
request
(
host
+
'
/User/update'
,
{
method
:
'POST'
,
body
:
JSON
.
stringify
(
params
),
});
...
...
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