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
977dae7f
Commit
977dae7f
authored
Apr 17, 2023
by
Ylg
Browse files
Options
Browse Files
Download
Plain Diff
resove file conflict
parents
3ee09474
f0a4671b
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
55 additions
and
69 deletions
+55
-69
defaultSettings.ts
config/defaultSettings.ts
+2
-2
routes.ts
config/routes.ts
+11
-19
app.tsx
src/app.tsx
+2
-3
index.tsx
src/components/RightContent/index.tsx
+2
-2
global.less
src/global.less
+6
-0
menu.ts
src/locales/zh-CN/menu.ts
+2
-1
404.tsx
src/pages/404.tsx
+2
-2
content.tsx
src/pages/Chat/components/content.tsx
+3
-5
productionCard.tsx
src/pages/Chat/components/productionCard.tsx
+2
-3
index.tsx
src/pages/Chat/index.tsx
+5
-6
index.tsx
src/pages/UserManage/index.tsx
+16
-22
Welcome.tsx
src/pages/Welcome.tsx
+0
-2
api.ts
src/services/chatGLM/api.ts
+2
-2
No files found.
config/defaultSettings.ts
View file @
977dae7f
...
@@ -12,8 +12,8 @@ const Settings: LayoutSettings & {
...
@@ -12,8 +12,8 @@ const Settings: LayoutSettings & {
fixSiderbar
:
true
,
fixSiderbar
:
true
,
colorWeak
:
false
,
colorWeak
:
false
,
pwa
:
false
,
pwa
:
false
,
logo
:
'
/l
ogo.png'
,
logo
:
'
https://baibaomen.oss-cn-hangzhou.aliyuncs.com/zhensheng/L
ogo.png'
,
title
:
''
,
title
:
'
长沙振升集团后台系统
'
,
iconfontUrl
:
''
,
iconfontUrl
:
''
,
};
};
...
...
config/routes.ts
View file @
977dae7f
export
default
[
export
default
[
{
name
:
'chat'
,
path
:
'/chat'
,
component
:
'./Chat'
,
layout
:
false
,
},
{
{
path
:
'/welcome'
,
path
:
'/welcome'
,
name
:
'welcome'
,
name
:
'welcome'
,
...
@@ -12,20 +6,11 @@
...
@@ -12,20 +6,11 @@
component
:
'./Welcome'
,
component
:
'./Welcome'
,
},
},
{
{
path
:
'/admin'
,
name
:
'user'
,
name
:
'admin'
,
path
:
'/user'
,
icon
:
'crown'
,
icon
:
'UserOutlined'
,
component
:
'./UserManage'
,
access
:
'canAdmin'
,
access
:
'canAdmin'
,
routes
:
[
{
name
:
'user'
,
path
:
'/admin/user'
,
component
:
'./UserManage'
,
},
{
component
:
'./404'
,
},
],
},
},
{
{
name
:
'prompt'
,
name
:
'prompt'
,
...
@@ -33,6 +18,13 @@
...
@@ -33,6 +18,13 @@
path
:
'/prompt'
,
path
:
'/prompt'
,
component
:
'./PromptWord'
,
component
:
'./PromptWord'
,
},
},
{
name
:
'chat'
,
path
:
'/chat'
,
component
:
'./Chat'
,
icon
:
'RobotOutlined'
,
layout
:
false
,
},
{
{
path
:
'/'
,
path
:
'/'
,
redirect
:
'/welcome'
,
redirect
:
'/welcome'
,
...
...
src/app.tsx
View file @
977dae7f
...
@@ -14,7 +14,6 @@ export const initialStateConfig = {
...
@@ -14,7 +14,6 @@ export const initialStateConfig = {
* @see https://umijs.org/zh-CN/plugins/plugin-initial-state
* @see https://umijs.org/zh-CN/plugins/plugin-initial-state
* */
* */
export
async
function
getInitialState
()
{
export
async
function
getInitialState
()
{
const
userInfo
=
JSON
.
parse
(
localStorage
.
getItem
(
'user'
)
||
'{}'
);
const
userInfo
=
JSON
.
parse
(
localStorage
.
getItem
(
'user'
)
||
'{}'
);
...
@@ -48,8 +47,8 @@ export const layout = ({ initialState, setInitialState }) => {
...
@@ -48,8 +47,8 @@ export const layout = ({ initialState, setInitialState }) => {
enableDarkTheme
enableDarkTheme
settings=
{
initialState
?.
settings
}
settings=
{
initialState
?.
settings
}
onSettingChange=
{
(
settings
)
=>
{
onSettingChange=
{
(
settings
)
=>
{
setInitialState
((
preInitialState
)
=>
({
setInitialState
(()
=>
({
...
preI
nitialState
,
...
i
nitialState
,
settings
,
settings
,
}));
}));
}
}
}
}
...
...
src/components/RightContent/index.tsx
View file @
977dae7f
...
@@ -21,8 +21,8 @@ const GlobalHeaderRight: React.FC = () => {
...
@@ -21,8 +21,8 @@ const GlobalHeaderRight: React.FC = () => {
}
}
return
(
return
(
<
Space
className=
{
className
}
>
<
Space
className=
{
className
}
>
<
Avatar
/>
{
/* <Avatar /> */
}
<
SelectLang
className=
{
styles
.
action
}
/>
{
/* <SelectLang className={styles.action} /> */
}
</
Space
>
</
Space
>
);
);
};
};
...
...
src/global.less
View file @
977dae7f
...
@@ -91,3 +91,9 @@ ol {
...
@@ -91,3 +91,9 @@ ol {
background-color: #009b95 !important;
background-color: #009b95 !important;
border-radius: 4px;
border-radius: 4px;
}
}
.ant-pro-sider-logo {
a h1 {
font-size: 12px !important;
}
}
src/locales/zh-CN/menu.ts
View file @
977dae7f
export
default
{
export
default
{
'menu.chat'
:
'
ChatGLM
'
,
'menu.chat'
:
'
AI助手
'
,
'menu.welcome'
:
'欢迎'
,
'menu.welcome'
:
'欢迎'
,
'menu.user'
:
'用户管理'
,
'menu.more-blocks'
:
'更多区块'
,
'menu.more-blocks'
:
'更多区块'
,
'menu.home'
:
'首页'
,
'menu.home'
:
'首页'
,
'menu.admin'
:
'账号管理'
,
'menu.admin'
:
'账号管理'
,
...
...
src/pages/404.tsx
View file @
977dae7f
...
@@ -6,10 +6,10 @@ const NoFoundPage: React.FC = () => (
...
@@ -6,10 +6,10 @@ const NoFoundPage: React.FC = () => (
<
Result
<
Result
status=
"404"
status=
"404"
title=
"404"
title=
"404"
subTitle=
"
Sorry, the page you visited does not exist.
"
subTitle=
"
很抱歉,您访问的页面不存在。
"
extra=
{
extra=
{
<
Button
type=
"primary"
onClick=
{
()
=>
history
.
push
(
'/'
)
}
>
<
Button
type=
"primary"
onClick=
{
()
=>
history
.
push
(
'/'
)
}
>
Back Home
返回
</
Button
>
</
Button
>
}
}
/>
/>
...
...
src/pages/Chat/components/content.tsx
View file @
977dae7f
import
{
Row
,
Col
,
Grid
}
from
'antd'
;
import
{
Row
,
Col
}
from
'antd'
;
import
type
{
FC
}
from
'react'
;
import
type
{
FC
}
from
'react'
;
import
styles
from
'./content.less'
;
import
styles
from
'./content.less'
;
import
ProductionCard
from
'./productionCard'
;
import
ProductionCard
from
'./productionCard'
;
import
{
IPromptWord
}
from
'@/services/chatGLM/api'
;
import
{
IPromptWord
}
from
'@/services/chatGLM/api'
;
const
{
useBreakpoint
}
=
Grid
;
interface
ChatFirstContentProps
{
interface
ChatFirstContentProps
{
list
:
IPromptWord
[];
list
:
IPromptWord
[];
onChange
?:
(
text
:
string
)
=>
void
;
onChange
?:
(
text
:
string
)
=>
void
;
...
@@ -27,12 +25,12 @@ const ChatFirstContent: FC<ChatFirstContentProps> = (props) => {
...
@@ -27,12 +25,12 @@ const ChatFirstContent: FC<ChatFirstContentProps> = (props) => {
sm=
{
12
}
sm=
{
12
}
xl=
{
8
}
xl=
{
8
}
xxl=
{
8
}
xxl=
{
8
}
key=
{
`${item.t
itl
e}-card-${index}`
}
key=
{
`${item.t
yp
e}-card-${index}`
}
>
>
<
Row
justify=
{
'start'
}
style=
{
{
marginBottom
:
16
,
minWidth
:
306
}
}
>
<
Row
justify=
{
'start'
}
style=
{
{
marginBottom
:
16
,
minWidth
:
306
}
}
>
<
ProductionCard
<
ProductionCard
index=
{
index
}
index=
{
index
}
title=
{
item
.
t
itl
e
}
title=
{
item
.
t
yp
e
}
content=
{
item
.
content
}
content=
{
item
.
content
}
onChange=
{
()
=>
{
onChange=
{
()
=>
{
onChange
&&
onChange
(
item
.
content
);
onChange
&&
onChange
(
item
.
content
);
...
...
src/pages/Chat/components/productionCard.tsx
View file @
977dae7f
import
type
{
ReactNode
}
from
'react'
;
import
styles
from
'./productionCard.less'
;
import
styles
from
'./productionCard.less'
;
import
classnames
from
'classnames'
;
import
classnames
from
'classnames'
;
interface
ProductionCardProps
{
interface
ProductionCardProps
{
index
:
number
;
index
:
number
;
title
?:
string
;
title
?:
string
;
content
:
ReactNode
;
content
:
string
;
onChange
:
(
content
:
string
)
=>
void
;
onChange
:
(
content
:
string
)
=>
void
;
}
}
const
ProductionCard
=
(
props
:
ProductionCardProps
)
=>
{
const
ProductionCard
=
(
props
:
ProductionCardProps
)
=>
{
const
{
index
,
title
,
content
,
onChange
}
=
props
;
const
{
title
,
content
,
onChange
}
=
props
;
const
handleClick
=
()
=>
{
const
handleClick
=
()
=>
{
onChange
&&
onChange
(
content
);
onChange
&&
onChange
(
content
);
...
...
src/pages/Chat/index.tsx
View file @
977dae7f
...
@@ -4,13 +4,11 @@ import React, { useState, useEffect, useRef, useMemo } from 'react';
...
@@ -4,13 +4,11 @@ import React, { useState, useEffect, useRef, useMemo } from 'react';
import
styles
from
'./index.less'
;
import
styles
from
'./index.less'
;
import
ChatFirstContent
from
'./components/content'
;
import
ChatFirstContent
from
'./components/content'
;
import
{
import
{
FieldTimeOutlined
,
LoadingOutlined
,
LoadingOutlined
,
MenuOutlined
,
MenuOutlined
,
PlusOutlined
,
PlusOutlined
,
SettingOutlined
,
SettingOutlined
,
UserOutlined
,
UserOutlined
,
WechatOutlined
,
}
from
'@ant-design/icons'
;
}
from
'@ant-design/icons'
;
import
classNames
from
'classnames'
;
import
classNames
from
'classnames'
;
import
{
history
}
from
'umi'
;
import
{
history
}
from
'umi'
;
...
@@ -81,6 +79,7 @@ const Chat: React.FC = () => {
...
@@ -81,6 +79,7 @@ const Chat: React.FC = () => {
messageHistory
.
current
.
push
({
prompt
:
chat
,
answer
:
''
});
messageHistory
.
current
.
push
({
prompt
:
chat
,
answer
:
''
});
setLoading
(
true
);
setLoading
(
true
);
sendMessage
&&
sendMessage
&&
glmToken
&&
sendMessage
(
sendMessage
(
JSON
.
stringify
({
JSON
.
stringify
({
prompt
:
chat
,
prompt
:
chat
,
...
@@ -131,7 +130,7 @@ const Chat: React.FC = () => {
...
@@ -131,7 +130,7 @@ const Chat: React.FC = () => {
/>
/>
</
Col
>
</
Col
>
<
Col
>
AI改变世界
</
Col
>
<
Col
>
AI改变世界
</
Col
>
<
Col
pull=
{
1
}
>
{
/* <FieldTimeOutlined /> */
}
</
Col
>
<
Col
pull=
{
1
}
></
Col
>
</
Row
>
</
Row
>
);
);
};
};
...
@@ -164,7 +163,7 @@ const Chat: React.FC = () => {
...
@@ -164,7 +163,7 @@ const Chat: React.FC = () => {
<
Space
<
Space
wrap
wrap
onClick=
{
()
=>
{
onClick=
{
()
=>
{
history
.
push
(
'/
admin/user
'
);
history
.
push
(
'/'
);
}
}
}
}
>
>
<
SettingOutlined
/>
<
SettingOutlined
/>
...
@@ -203,12 +202,12 @@ const Chat: React.FC = () => {
...
@@ -203,12 +202,12 @@ const Chat: React.FC = () => {
<
Row
>
<
Row
>
<
Col
span=
{
24
}
>
<
Col
span=
{
24
}
>
<
Title
level=
{
2
}
style=
{
{
marginBottom
:
8
,
fontSize
:
32
}
}
>
<
Title
level=
{
2
}
style=
{
{
marginBottom
:
8
,
fontSize
:
32
}
}
>
产品名称
长沙振升集团
</
Title
>
</
Title
>
</
Col
>
</
Col
>
<
Col
span=
{
24
}
>
<
Col
span=
{
24
}
>
<
Title
level=
{
5
}
className=
{
styles
.
subTitle
}
>
<
Title
level=
{
5
}
className=
{
styles
.
subTitle
}
>
AI
改变世界
AI
智能小助手
</
Title
>
</
Title
>
</
Col
>
</
Col
>
</
Row
>
</
Row
>
...
...
src/pages/UserManage/index.tsx
View file @
977dae7f
...
@@ -10,19 +10,7 @@ import { PlusOutlined } from '@ant-design/icons';
...
@@ -10,19 +10,7 @@ import { PlusOutlined } from '@ant-design/icons';
import
type
{
ActionType
}
from
'@ant-design/pro-components'
;
import
type
{
ActionType
}
from
'@ant-design/pro-components'
;
import
{
PageContainer
}
from
'@ant-design/pro-components'
;
import
{
PageContainer
}
from
'@ant-design/pro-components'
;
import
{
ProTable
}
from
'@ant-design/pro-components'
;
import
{
ProTable
}
from
'@ant-design/pro-components'
;
import
{
import
{
Button
,
Col
,
Divider
,
Form
,
Input
,
Modal
,
Radio
,
Row
,
Switch
,
message
}
from
'antd'
;
Button
,
Col
,
Divider
,
Form
,
Input
,
Modal
,
Radio
,
Row
,
Select
,
Switch
,
message
,
}
from
'antd'
;
import
classNames
from
'classnames'
;
import
classNames
from
'classnames'
;
import
{
isEmpty
}
from
'lodash'
;
import
{
isEmpty
}
from
'lodash'
;
import
{
useRef
,
useState
}
from
'react'
;
import
{
useRef
,
useState
}
from
'react'
;
...
@@ -30,6 +18,8 @@ import styles from './index.less';
...
@@ -30,6 +18,8 @@ import styles from './index.less';
import
{
Exclamtion
}
from
'@/components/Icons/Icons'
;
import
{
Exclamtion
}
from
'@/components/Icons/Icons'
;
const
{
Item
}
=
Form
;
const
{
Item
}
=
Form
;
const
{
Password
}
=
Input
;
const
layout
=
{
const
layout
=
{
labelCol
:
{
span
:
4
},
labelCol
:
{
span
:
4
},
wrapperCol
:
{
span
:
18
},
wrapperCol
:
{
span
:
18
},
...
@@ -59,11 +49,7 @@ const UserManage = () => {
...
@@ -59,11 +49,7 @@ const UserManage = () => {
const
[
ressetLoading
,
setResetLoading
]
=
useState
(
false
);
const
[
ressetLoading
,
setResetLoading
]
=
useState
(
false
);
const
[
accountModalName
,
setAccountModalName
]
=
useState
(
'新建账号'
);
const
[
accountModalName
,
setAccountModalName
]
=
useState
(
'新建账号'
);
const
[
accountForm
]
=
Form
.
useForm
();
const
[
accountForm
]
=
Form
.
useForm
();
const
[
resetPasswordForm
]
=
Form
.
useForm
();
const
isActiveSelectOption
=
[
{
label
:
'启用'
,
value
:
true
},
{
label
:
'禁用'
,
value
:
false
},
];
const
showModal
=
()
=>
{
const
showModal
=
()
=>
{
getRole
().
then
((
res
)
=>
{
getRole
().
then
((
res
)
=>
{
...
@@ -131,7 +117,7 @@ const UserManage = () => {
...
@@ -131,7 +117,7 @@ const UserManage = () => {
title
:
'操作'
,
title
:
'操作'
,
valueType
:
'option'
,
valueType
:
'option'
,
key
:
'option'
,
key
:
'option'
,
render
:
(
text
,
record
,
_
,
action
)
=>
[
render
:
(
_text
,
record
,
_
,
_
action
)
=>
[
<
a
<
a
key=
"editable"
key=
"editable"
onClick=
{
()
=>
{
onClick=
{
()
=>
{
...
@@ -194,6 +180,7 @@ const UserManage = () => {
...
@@ -194,6 +180,7 @@ const UserManage = () => {
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
setLoading
(
false
);
setLoading
(
false
);
setIsModalAccountOpen
(
false
);
setIsModalAccountOpen
(
false
);
accountForm
.
resetFields
();
actionRef
.
current
?.
reload
();
actionRef
.
current
?.
reload
();
})
})
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
...
@@ -212,6 +199,7 @@ const UserManage = () => {
...
@@ -212,6 +199,7 @@ const UserManage = () => {
setLoading
(
false
);
setLoading
(
false
);
setIsModalAccountOpen
(
false
);
setIsModalAccountOpen
(
false
);
message
.
success
(
'编辑成功'
);
message
.
success
(
'编辑成功'
);
accountForm
.
resetFields
();
actionRef
.
current
?.
reload
();
actionRef
.
current
?.
reload
();
})
})
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
...
@@ -277,6 +265,7 @@ const UserManage = () => {
...
@@ -277,6 +265,7 @@ const UserManage = () => {
setResetLoading
(
false
);
setResetLoading
(
false
);
setIsModalResetPassword
(
false
);
setIsModalResetPassword
(
false
);
actionRef
.
current
?.
reload
();
actionRef
.
current
?.
reload
();
resetPasswordForm
.
resetFields
();
message
.
success
(
'重置成功'
);
message
.
success
(
'重置成功'
);
})
})
.
catch
((
err
)
=>
{
.
catch
((
err
)
=>
{
...
@@ -312,7 +301,12 @@ const UserManage = () => {
...
@@ -312,7 +301,12 @@ const UserManage = () => {
}
}
}
}
footer=
{
null
}
footer=
{
null
}
>
>
<
Form
{
...
resetLayout
}
onFinish=
{
handleClickOpenModalReset
}
name=
"resetPassword"
>
<
Form
form=
{
resetPasswordForm
}
{
...
resetLayout
}
onFinish=
{
handleClickOpenModalReset
}
name=
"resetPassword"
>
<
Item
<
Item
name=
{
'newPassword'
}
name=
{
'newPassword'
}
label=
{
'新密码'
}
label=
{
'新密码'
}
...
@@ -387,7 +381,7 @@ const UserManage = () => {
...
@@ -387,7 +381,7 @@ const UserManage = () => {
{
validator
:
validatePassword
},
{
validator
:
validatePassword
},
]
}
]
}
>
>
<
Input
/>
<
Password
/>
</
Item
>
</
Item
>
</>
</>
)
}
)
}
...
@@ -448,7 +442,7 @@ const UserManage = () => {
...
@@ -448,7 +442,7 @@ const UserManage = () => {
}
}
}
}
rowKey=
"id"
rowKey=
"id"
pagination=
{
{
pagination=
{
{
pageSize
:
5
,
pageSize
:
9
,
onChange
:
(
page
)
=>
{},
onChange
:
(
page
)
=>
{},
}
}
}
}
options=
{
false
}
options=
{
false
}
...
...
src/pages/Welcome.tsx
View file @
977dae7f
...
@@ -5,8 +5,6 @@ import { FormattedMessage, useIntl } from 'umi';
...
@@ -5,8 +5,6 @@ import { FormattedMessage, useIntl } from 'umi';
const
{
Content
}
=
Layout
;
const
{
Content
}
=
Layout
;
const
Welcome
:
React
.
FC
=
()
=>
{
const
Welcome
:
React
.
FC
=
()
=>
{
const
intl
=
useIntl
();
return
(
return
(
<
Layout
>
<
Layout
>
<
Content
>
欢迎进入后台管理页面
</
Content
>
<
Content
>
欢迎进入后台管理页面
</
Content
>
...
...
src/services/chatGLM/api.ts
View file @
977dae7f
...
@@ -42,7 +42,7 @@ export function loginChatGLM(options: ILoginParams) {
...
@@ -42,7 +42,7 @@ export function loginChatGLM(options: ILoginParams) {
}
}
export
interface
IPromptWord
{
export
interface
IPromptWord
{
t
itl
e
:
string
;
t
yp
e
:
string
;
content
:
string
;
content
:
string
;
}
}
export
function
GetChatGLMToken
():
Promise
<
string
>
{
export
function
GetChatGLMToken
():
Promise
<
string
>
{
...
@@ -140,7 +140,7 @@ export const postResetUser = (params?: any): Promise<string> => {
...
@@ -140,7 +140,7 @@ export const postResetUser = (params?: any): Promise<string> => {
});
});
};
};
export
const
postEditUser
=
(
params
?:
any
):
Promise
<
string
>
=>
{
export
const
postEditUser
=
(
params
?:
any
):
Promise
<
string
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com/User/update'
,
{
return
request
(
'https://glm-mangement-api.baibaomen.com/User/update'
,
{
method
:
'POST'
,
method
:
'POST'
,
body
:
JSON
.
stringify
(
params
),
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