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
7febc228
Commit
7febc228
authored
Apr 14, 2023
by
Ylg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add login api
parent
4ce8dd4a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
6 deletions
+64
-6
index.tsx
src/components/loginModal/index.tsx
+28
-5
index.tsx
src/pages/Chat/index.tsx
+1
-0
index.tsx
src/pages/PromptWord/index.tsx
+18
-1
api.ts
src/services/chatGLM/api.ts
+17
-0
No files found.
src/components/loginModal/index.tsx
View file @
7febc228
import
styles
from
'./index.less'
;
import
{
Button
,
Checkbox
,
Form
,
FormInstance
,
Input
,
Modal
}
from
'antd'
;
import
{
Button
,
Checkbox
,
Form
,
FormInstance
,
Input
,
Modal
,
message
}
from
'antd'
;
import
{
LockOutlined
,
UserOutlined
}
from
'@ant-design/icons'
;
import
logoSvg
from
'../../assets/logo.svg'
;
import
{
useRef
}
from
'react'
;
import
{
useRef
,
useState
}
from
'react'
;
import
{
loginChatGLM
}
from
'@/services/chatGLM/api'
;
import
{
useIntl
}
from
'react-intl'
;
interface
ILoginModalProps
{
open
:
boolean
;
...
...
@@ -11,6 +13,11 @@ interface ILoginModalProps {
const
LoginModal
=
(
props
:
ILoginModalProps
)
=>
{
const
{
open
,
setOpen
}
=
props
;
const
intl
=
useIntl
();
const
[
loginResult
,
setLoginResult
]
=
useState
({});
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
formRef
=
useRef
<
FormInstance
>
(
null
);
...
...
@@ -19,15 +26,31 @@ const LoginModal = (props: ILoginModalProps) => {
formRef
.
current
?.
resetFields
();
};
const
handle
Login
=
(
values
:
any
)
=>
{
const
handle
Submit
=
async
(
values
:
any
)
=>
{
console
.
log
(
'values'
,
values
);
setLoading
(
true
);
const
{
username
,
password
,
checked
}
=
values
;
try
{
const
result
=
await
loginChatGLM
({
name
:
username
,
password
,
});
console
.
log
(
'result'
,
result
);
setLoading
(
false
);
}
catch
(
error
)
{
const
defaultLoginFailureMessage
=
intl
.
formatMessage
({
id
:
'pages.login.failure'
,
defaultMessage
:
'登录失败,请重试!'
,
});
message
.
error
(
defaultLoginFailureMessage
);
}
reset
();
};
return
(
<
Modal
open=
{
open
}
onOk=
{
handleLogin
}
footer=
{
null
}
closable=
{
false
}
width=
{
480
}
...
...
@@ -45,7 +68,7 @@ const LoginModal = (props: ILoginModalProps) => {
<
Form
name=
"normal_login"
initialValues=
{
{
remember
:
true
}
}
onFinish=
{
handle
Login
}
onFinish=
{
handle
Submit
}
onValuesChange=
{
(
value
)
=>
{
console
.
log
(
value
);
}
}
...
...
src/pages/Chat/index.tsx
View file @
7febc228
...
...
@@ -13,6 +13,7 @@ import {
WechatOutlined
,
}
from
'@ant-design/icons'
;
import
classNames
from
'classnames'
;
import
LoginModal
from
'@/components/loginModal'
;
const
{
Sider
}
=
Layout
;
const
{
Item
}
=
Form
;
...
...
src/pages/PromptWord/index.tsx
View file @
7febc228
import
LoginModal
from
"@/components/loginModal"
;
import
{
Button
}
from
"antd"
;
import
{
useState
}
from
"react"
;
const
PromptWord
=
()
=>
{
return
<>
PromptWord
</>;
const
[
open
,
setOpen
]
=
useState
(
false
);
return
(
<>
PromptWord
<
Button
onClick=
{
()
=>
setOpen
(
true
)
}
/>
<
LoginModal
open=
{
open
}
setOpen=
{
setOpen
}
/>
</>
)
};
export
default
PromptWord
;
src/services/chatGLM/api.ts
View file @
7febc228
import
{
request
}
from
'umi'
;
interface
LoginParams
{
name
:
string
;
password
:
string
;
}
export
function
loginChatGLM
(
options
:
LoginParams
)
{
return
request
(
'https://glm-mangement-api.baibaomen.com/api/app/account/login'
,
{
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json'
,
'__tenant'
:
'3a0a90fe-9a0d-70f4-200d-a80a41fb6195'
},
data
:
options
})
}
\ No newline at end of file
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