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
22a08e65
Commit
22a08e65
authored
Apr 15, 2023
by
Ylg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split new session component
parent
8954c246
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
107 additions
and
67 deletions
+107
-67
index.tsx
src/components/loginModal/index.tsx
+6
-7
answer.component.tsx
src/components/newSession/answer.component.tsx
+46
-0
index.less
src/components/newSession/index.less
+15
-1
index.tsx
src/components/newSession/index.tsx
+12
-54
issue.component.tsx
src/components/newSession/issue.component.tsx
+20
-0
index.tsx
src/pages/Chat/index.tsx
+8
-5
No files found.
src/components/loginModal/index.tsx
View file @
22a08e65
import
styles
from
'./index.less'
;
import
styles
from
'./index.less'
;
import
{
Button
,
Checkbox
,
Form
,
FormInstance
,
Input
,
Modal
,
message
}
from
'antd'
;
import
{
Button
,
Checkbox
,
Form
,
Input
,
Modal
,
message
}
from
'antd'
;
import
{
LockOutlined
,
UserOutlined
}
from
'@ant-design/icons'
;
import
{
LockOutlined
,
UserOutlined
}
from
'@ant-design/icons'
;
import
logoSvg
from
'../../assets/logo.svg'
;
import
logoSvg
from
'../../assets/logo.svg'
;
import
{
use
Ref
,
use
State
}
from
'react'
;
import
{
useState
}
from
'react'
;
import
{
loginChatGLM
}
from
'@/services/chatGLM/api'
;
import
{
loginChatGLM
}
from
'@/services/chatGLM/api'
;
import
{
useIntl
}
from
'react-intl'
;
import
{
useIntl
}
from
'react-intl'
;
...
@@ -16,12 +16,12 @@ const LoginModal = (props: ILoginModalProps) => {
...
@@ -16,12 +16,12 @@ const LoginModal = (props: ILoginModalProps) => {
const
intl
=
useIntl
();
const
intl
=
useIntl
();
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
form
]
=
Form
.
useForm
();
const
formRef
=
useRef
<
FormInstance
>
(
null
);
const
reset
=
()
=>
{
const
reset
=
()
=>
{
setOpen
(
false
);
setOpen
(
false
);
form
Ref
.
current
?
.
resetFields
();
form
.
resetFields
();
};
};
const
handleSubmit
=
async
(
values
:
any
)
=>
{
const
handleSubmit
=
async
(
values
:
any
)
=>
{
setLoading
(
true
);
setLoading
(
true
);
...
@@ -73,7 +73,6 @@ const LoginModal = (props: ILoginModalProps) => {
...
@@ -73,7 +73,6 @@ const LoginModal = (props: ILoginModalProps) => {
console
.
log
(
value
);
console
.
log
(
value
);
}
}
}
}
className=
{
styles
.
modal_form
}
className=
{
styles
.
modal_form
}
ref=
{
formRef
}
>
>
<
Form
.
Item
<
Form
.
Item
name=
"username"
name=
"username"
...
@@ -91,7 +90,7 @@ const LoginModal = (props: ILoginModalProps) => {
...
@@ -91,7 +90,7 @@ const LoginModal = (props: ILoginModalProps) => {
<
Checkbox
>
自动登录
</
Checkbox
>
<
Checkbox
>
自动登录
</
Checkbox
>
</
Form
.
Item
>
</
Form
.
Item
>
<
Form
.
Item
>
<
Form
.
Item
>
<
Button
type=
"primary"
htmlType=
"submit"
className=
{
styles
.
modal_button
}
>
<
Button
type=
"primary"
htmlType=
"submit"
className=
{
styles
.
modal_button
}
loading=
{
loading
}
>
登录
登录
</
Button
>
</
Button
>
</
Form
.
Item
>
</
Form
.
Item
>
...
...
src/components/newSession/answer.component.tsx
0 → 100644
View file @
22a08e65
import
logoSvg
from
'../../assets/logo.svg'
;
import
copySvg
from
'../../assets/copy.svg'
;
import
{
Button
}
from
'antd'
;
import
styles
from
'./index.less'
;
interface
IAnswerProps
{
answerValue
:
string
;
loading
:
boolean
isShowRetry
?:
boolean
;
}
const
Answer
=
(
props
:
IAnswerProps
)
=>
{
const
{
answerValue
,
loading
,
isShowRetry
}
=
props
return
(
<
div
>
<
p
className=
{
styles
.
question
}
>
<
img
src=
{
logoSvg
}
alt=
""
/>
<
span
>
回答如下:
</
span
>
</
p
>
<
div
className=
{
styles
.
chat
}
>
<
div
>
<
p
className=
{
styles
.
copyAnswer
}
onClick=
{
()
=>
{
}
}
>
<
img
src=
{
copySvg
}
alt=
""
/>
<
span
>
复制回答
</
span
>
</
p
>
<
div
className=
{
styles
.
answer
}
>
<
p
>
{
loading
?
'请耐心等待3-5秒~'
:
answerValue
}
</
p
>
</
div
>
</
div
>
{
isShowRetry
&&
<
Button
>
重试
</
Button
>
}
</
div
>
</
div
>
);
}
export
default
Answer
;
\ No newline at end of file
src/components/newSession/index.less
View file @
22a08e65
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
display: flex;
display: flex;
div {
div {
position: relative;
position: relative;
p
{
.copyAnswer
{
position: absolute;
position: absolute;
bottom: 0;
bottom: 0;
right: 16px;
right: 16px;
...
@@ -41,6 +41,20 @@
...
@@ -41,6 +41,20 @@
font-size: 14px;
font-size: 14px;
}
}
}
}
.answer {
width: 900px;
margin-left: 28px;
background: #F0F3F6;
border-radius: 4px;
font-size: 18px;
color: rgba(0,0,0,0.85);
line-height: 32px;
min-height: 268px;
p {
padding: 16px;
}
}
}
}
button {
button {
width: 90px;
width: 90px;
...
...
src/components/newSession/index.tsx
View file @
22a08e65
import
styles
from
'./index.less'
;
import
styles
from
'./index.less'
;
import
userSvg
from
'../../assets/user.svg'
;
import
Issue
from
'./issue.component'
;
import
logoSvg
from
'../../assets/logo.svg'
;
import
Answer
from
'./answer.component'
;
import
copySvg
from
'../../assets/copy.svg'
;
import
{
Button
,
Input
}
from
'antd'
;
import
{
useState
}
from
'react'
;
const
{
TextArea
}
=
Input
;
interface
INewSessionProps
{
interface
INewSessionProps
{
questionValue
:
string
;
questionValue
:
string
;
answerValue
:
string
;
}
}
const
NewSession
=
(
props
:
INewSessionProps
)
=>
{
const
NewSession
=
(
props
:
INewSessionProps
)
=>
{
const
{
questionValue
}
=
props
;
const
{
questionValue
,
answerValue
}
=
props
;
const
[
answerValue
,
setAnswerValue
]
=
useState
(
''
);
return
(
return
(
<
div
className=
{
styles
.
newSession
}
>
<
div
className=
{
styles
.
newSession
}
>
<
div
className=
{
styles
.
question
}
style=
{
{
marginBottom
:
'40px'
}
}
>
<
Issue
<
img
src=
{
userSvg
}
alt=
""
/>
questionValue=
{
questionValue
}
<
span
>
{
questionValue
}
</
span
>
/>
</
div
>
<
Answer
<
div
>
answerValue=
{
answerValue
}
<
p
className=
{
styles
.
question
}
>
loading
<
img
src=
{
logoSvg
}
alt=
""
/>
/>
<
span
>
回答如下:
</
span
>
</
p
>
<
div
className=
{
styles
.
chat
}
>
<
div
>
<
p
onClick=
{
()
=>
{
}
}
>
<
img
src=
{
copySvg
}
alt=
""
/>
<
span
>
复制回答
</
span
>
</
p
>
<
TextArea
value=
{
answerValue
}
onChange=
{
(
e
)
=>
setAnswerValue
(
e
.
target
.
value
)
}
placeholder=
"请耐心等待3-5秒~"
// autoSize={{ minRows: 3, maxRows: 5 }}
style=
{
{
width
:
'900px'
,
height
:
'268px'
,
marginLeft
:
'28px'
,
background
:
'#F0F3F6'
,
borderRadius
:
'4px'
,
fontSize
:
'18px'
,
color
:
'rgba(0,0,0,0.85)'
,
lineHeight
:
'32px'
,
}
}
/>
</
div
>
<
Button
onClick=
{
()
=>
{
}
}
>
重试
</
Button
>
</
div
>
</
div
>
</
div
>
</
div
>
);
);
}
}
...
...
src/components/newSession/issue.component.tsx
0 → 100644
View file @
22a08e65
import
userSvg
from
'../../assets/user.svg'
;
import
styles
from
'./index.less'
;
interface
IIssueProps
{
questionValue
:
string
;
}
const
Issue
=
(
props
:
IIssueProps
)
=>
{
const
{
questionValue
}
=
props
;
return
(
<
div
className=
{
styles
.
question
}
style=
{
{
marginBottom
:
'40px'
}
}
>
<
img
src=
{
userSvg
}
alt=
""
/>
<
span
>
{
questionValue
}
</
span
>
</
div
>
);
}
export
default
Issue
;
\ No newline at end of file
src/pages/Chat/index.tsx
View file @
22a08e65
...
@@ -31,7 +31,9 @@ const Chat: React.FC = () => {
...
@@ -31,7 +31,9 @@ const Chat: React.FC = () => {
const
[
selectSiderTabs
,
setSelectSiderTabs
]
=
useState
(
''
);
const
[
selectSiderTabs
,
setSelectSiderTabs
]
=
useState
(
''
);
const
[
open
,
setOpen
]
=
useState
(
false
);
const
[
open
,
setOpen
]
=
useState
(
false
);
const
tabShow
=
showSider
;
const
tabShow
=
showSider
;
const
questionValue
=
form
.
getFieldValue
(
'chatInput'
);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
isMobile
)
{
if
(
!
isMobile
)
{
...
@@ -39,8 +41,8 @@ const Chat: React.FC = () => {
...
@@ -39,8 +41,8 @@ const Chat: React.FC = () => {
}
}
},
[
isMobile
]);
},
[
isMobile
]);
useEffect
(()
=>
{
let
token
=
''
;
let
token
=
''
;
useEffect
(()
=>
{
if
(
localStorage
.
getItem
(
'user'
))
{
if
(
localStorage
.
getItem
(
'user'
))
{
token
=
JSON
.
parse
(
localStorage
.
user
)?.
token
;
token
=
JSON
.
parse
(
localStorage
.
user
)?.
token
;
}
}
...
@@ -190,6 +192,7 @@ const Chat: React.FC = () => {
...
@@ -190,6 +192,7 @@ const Chat: React.FC = () => {
{
firstChat
?
(
{
firstChat
?
(
<
NewSession
<
NewSession
questionValue=
{
chat
}
questionValue=
{
chat
}
answerValue=
''
/>
/>
)
:
(
)
:
(
<
Item
name=
"firstInput"
>
<
Item
name=
"firstInput"
>
...
@@ -199,7 +202,7 @@ const Chat: React.FC = () => {
...
@@ -199,7 +202,7 @@ const Chat: React.FC = () => {
<
div
className=
{
styles
.
footer
}
>
<
div
className=
{
styles
.
footer
}
>
<
Row
>
<
Row
>
<
Col
span=
{
16
}
push=
{
4
}
>
<
Col
span=
{
16
}
push=
{
4
}
>
<
div
className=
{
styles
.
chatWrapper
}
style=
{
{
margin
:
isMobile
&&
'
o
auto'
}
}
>
<
div
className=
{
styles
.
chatWrapper
}
style=
{
{
margin
:
isMobile
&&
'
0
auto'
}
}
>
<
Item
name=
"chatInput"
>
<
Item
name=
"chatInput"
>
<
Input
<
Input
placeholder=
"在这里输入你想知道的问题,给我几句提示,我来帮你回答"
placeholder=
"在这里输入你想知道的问题,给我几句提示,我来帮你回答"
...
@@ -211,7 +214,7 @@ const Chat: React.FC = () => {
...
@@ -211,7 +214,7 @@ const Chat: React.FC = () => {
<
Col
span=
{
4
}
push=
{
4
}
>
<
Col
span=
{
4
}
push=
{
4
}
>
<
div
className=
{
styles
.
outputButtonWrapper
}
>
<
div
className=
{
styles
.
outputButtonWrapper
}
>
<
Item
name=
"outputButton"
>
<
Item
name=
"outputButton"
>
<
Button
htmlType=
"submit"
type=
"primary"
size=
"large"
disabled=
{
chat
.
length
===
0
}
>
<
Button
htmlType=
"submit"
type=
"primary"
size=
"large"
>
发送
发送
</
Button
>
</
Button
>
</
Item
>
</
Item
>
...
...
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