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
5ac257d2
Commit
5ac257d2
authored
Apr 16, 2023
by
littleforest
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.baibaomen.com/jian.liu/chatgml
parents
6816cd67
e3046051
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
12 deletions
+5
-12
index.tsx
src/components/loginModal/index.tsx
+1
-9
index.tsx
src/pages/Chat/index.tsx
+1
-1
api.ts
src/services/chatGLM/api.ts
+3
-2
No files found.
src/components/loginModal/index.tsx
View file @
5ac257d2
import
styles
from
'./index.less'
;
import
styles
from
'./index.less'
;
import
{
Button
,
Checkbox
,
Form
,
Input
,
Modal
,
message
}
from
'antd'
;
import
{
Button
,
Checkbox
,
Form
,
Input
,
Modal
}
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
{
useState
}
from
'react'
;
import
{
useState
}
from
'react'
;
import
{
loginChatGLM
}
from
'@/services/chatGLM/api'
;
import
{
loginChatGLM
}
from
'@/services/chatGLM/api'
;
import
{
useIntl
}
from
'react-intl'
;
interface
ILoginModalProps
{
interface
ILoginModalProps
{
open
:
boolean
;
open
:
boolean
;
setOpen
:
(
value
:
boolean
)
=>
void
;
setOpen
:
(
value
:
boolean
)
=>
void
;
...
@@ -14,7 +12,6 @@ interface ILoginModalProps {
...
@@ -14,7 +12,6 @@ interface ILoginModalProps {
const
LoginModal
=
(
props
:
ILoginModalProps
)
=>
{
const
LoginModal
=
(
props
:
ILoginModalProps
)
=>
{
const
{
open
,
setOpen
}
=
props
;
const
{
open
,
setOpen
}
=
props
;
const
intl
=
useIntl
();
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
...
@@ -36,11 +33,6 @@ const LoginModal = (props: ILoginModalProps) => {
...
@@ -36,11 +33,6 @@ const LoginModal = (props: ILoginModalProps) => {
reset
();
reset
();
}
catch
(
error
)
{
}
catch
(
error
)
{
setLoading
(
false
);
setLoading
(
false
);
const
defaultLoginFailureMessage
=
intl
.
formatMessage
({
id
:
'pages.login.failure'
,
defaultMessage
:
'登录失败,请重试!'
,
});
message
.
error
(
defaultLoginFailureMessage
);
}
}
};
};
...
...
src/pages/Chat/index.tsx
View file @
5ac257d2
...
@@ -83,7 +83,7 @@ const Chat: React.FC = () => {
...
@@ -83,7 +83,7 @@ const Chat: React.FC = () => {
messageHistory
.
current
.
push
({
prompt
:
chat
,
answer
:
''
});
messageHistory
.
current
.
push
({
prompt
:
chat
,
answer
:
''
});
}
}
const
user
=
JSON
.
parse
(
localStorage
.
getItem
(
'user
'
));
const
user
=
JSON
.
parse
(
JSON
.
stringify
(
localStorage
.
getItem
(
'user'
)
||
'
'
));
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
user
?.
token
)
{
if
(
user
?.
token
)
{
...
...
src/services/chatGLM/api.ts
View file @
5ac257d2
import
{
extend
}
from
'umi-request'
;
import
{
extend
}
from
'umi-request'
;
import
{
history
}
from
'umi'
;
import
{
history
}
from
'umi'
;
import
{
message
}
from
'antd'
;
interface
ILoginParams
{
interface
ILoginParams
{
name
:
string
;
name
:
string
;
password
:
string
;
password
:
string
;
}
}
const
request
=
extend
({});
const
request
=
extend
({});
request
.
interceptors
.
request
.
use
((
url
,
options
)
=>
{
request
.
interceptors
.
request
.
use
((
url
,
options
)
=>
{
const
token
=
JSON
.
parse
(
localStorage
.
getItem
(
'user
'
))?.
token
;
const
token
=
JSON
.
parse
(
JSON
.
stringify
(
localStorage
.
getItem
(
'user'
)
||
'
'
))?.
token
;
const
authHeader
=
{
const
authHeader
=
{
Authorization
:
`Bearer
${
token
||
''
}
`
,
Authorization
:
`Bearer
${
token
||
''
}
`
,
'Content-Type'
:
'application/json'
,
'Content-Type'
:
'application/json'
,
...
@@ -30,6 +30,7 @@ request.interceptors.response.use(async (response): Promise<any> => {
...
@@ -30,6 +30,7 @@ request.interceptors.response.use(async (response): Promise<any> => {
}
else
if
(
response
.
status
===
200
)
{
}
else
if
(
response
.
status
===
200
)
{
return
response
;
return
response
;
}
else
{
}
else
{
message
.
error
(
'请求失败,请重试! '
)
return
Promise
.
reject
(
response
.
statusText
);
return
Promise
.
reject
(
response
.
statusText
);
}
}
})
})
...
...
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