Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5083eaab
authored
Jul 23, 2024
by
1808837298@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: first login error (close #385)
parent
2041a2e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
web/src/components/LoginForm.js
+2
-1
web/src/helpers/api.js
+12
-1
No files found.
web/src/components/LoginForm.js
View file @
5083eaab
import
React
,
{
useContext
,
useEffect
,
useState
}
from
'react'
;
import
{
Link
,
useNavigate
,
useSearchParams
}
from
'react-router-dom'
;
import
{
UserContext
}
from
'../context/User'
;
import
{
API
,
getLogo
,
showError
,
showInfo
,
showSuccess
}
from
'../helpers'
;
import
{
API
,
getLogo
,
showError
,
showInfo
,
showSuccess
,
updateAPI
}
from
'../helpers'
;
import
{
onGitHubOAuthClicked
}
from
'./utils'
;
import
Turnstile
from
'react-turnstile'
;
import
{
...
...
@@ -101,6 +101,7 @@ const LoginForm = () => {
if
(
success
)
{
userDispatch
({
type
:
'login'
,
payload
:
data
});
setUserData
(
data
);
updateAPI
()
showSuccess
(
'登录成功!'
);
if
(
username
===
'root'
&&
password
===
'123456'
)
{
Modal
.
error
({
...
...
web/src/helpers/api.js
View file @
5083eaab
import
{
getUserIdFromLocalStorage
,
showError
}
from
'./utils'
;
import
axios
from
'axios'
;
export
cons
t
API
=
axios
.
create
({
export
le
t
API
=
axios
.
create
({
baseURL
:
import
.
meta
.
env
.
VITE_REACT_APP_SERVER_URL
?
import
.
meta
.
env
.
VITE_REACT_APP_SERVER_URL
:
''
,
...
...
@@ -10,6 +10,17 @@ export const API = axios.create({
}
});
export
function
updateAPI
()
{
API
=
axios
.
create
({
baseURL
:
import
.
meta
.
env
.
VITE_REACT_APP_SERVER_URL
?
import
.
meta
.
env
.
VITE_REACT_APP_SERVER_URL
:
''
,
headers
:
{
'New-API-User'
:
getUserIdFromLocalStorage
()
}
});
}
API
.
interceptors
.
response
.
use
(
(
response
)
=>
response
,
(
error
)
=>
{
...
...
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