-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auth service, password 404 pages
- Loading branch information
Showing
35 changed files
with
792 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,43 @@ | ||
import axios from 'axios'; | ||
import { notification } from 'antd'; | ||
import config from './config.js'; | ||
|
||
const http = axios.create({ | ||
baseURL: config.url, | ||
timeout: 20000 | ||
}); | ||
|
||
http.interceptors.request.use( | ||
(config) => config, | ||
(err) => Promise.reject(err) | ||
); | ||
|
||
http.interceptors.response.use( | ||
(response) => { | ||
if (response.data) response.config.headers['Content-Type'] = 'application/json'; | ||
return response.data; | ||
}, | ||
(err) => { | ||
notification.error({ | ||
message: 'Http request error', | ||
description: err instanceof Error ? err.message : err || 'Unknown error', | ||
placement: 'topRight' | ||
}); | ||
return Promise.reject(err); | ||
} | ||
); | ||
|
||
export default http; | ||
import axios from 'axios' | ||
import { notification } from 'antd' | ||
import config from './config.js' | ||
import { getToken } from '@/store/adminReducer.js' | ||
import store from '@/store/' | ||
|
||
function axiosCreator() { | ||
const http = axios.create({ | ||
baseURL: config.url, | ||
timeout: 20000 | ||
}) | ||
|
||
http.interceptors.request.use( | ||
(config) => { | ||
const token = getToken(store.getState()) | ||
if (token) config.headers.Authorization = `Bearer ${token}` | ||
return config | ||
}, | ||
(err) => Promise.reject(err) | ||
) | ||
|
||
http.interceptors.response.use((response) => { | ||
if (response.data) response.config.headers['Content-Type'] = 'application/json' | ||
return response.data | ||
}) | ||
|
||
return http | ||
} | ||
|
||
const http = axiosCreator() | ||
|
||
http.interceptors.response.use(undefined, (err) => { | ||
notification.error({ | ||
message: 'Http request error', | ||
description: err instanceof Error ? err.message : err || 'Unknown error', | ||
placement: 'topRight' | ||
}) | ||
return Promise.reject(err) | ||
}) | ||
|
||
export const httpNoCatcher = axiosCreator() | ||
|
||
export default http |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Card, Typography, Flex, Button } from 'antd' | ||
import { HomeOutlined } from '@ant-design/icons' | ||
import { useNavigate } from 'react-router-dom' | ||
|
||
const { Title } = Typography | ||
|
||
const NotFoundView: React.FC = () => { | ||
const navigate = useNavigate() | ||
|
||
return ( | ||
<div> | ||
<Flex justify="center" align="center" style={{ marginTop: '25vh' }}> | ||
<Card className="card cardFixed" style={{ maxWidth: 500 }}> | ||
<Flex vertical align="center" gap="middle"> | ||
<Title level={1} style={{ marginBottom: 0, color: 'pink', fontSize: '10rem' }}> | ||
404 | ||
</Title> | ||
<Title level={3} type="warning"> | ||
{'页面走丢了呜呜 ヽ(*。>Д<)o゜'} | ||
</Title> | ||
<Button className="cardButton clean" icon={<HomeOutlined />} onClick={() => navigate('/')}> | ||
回到主页 | ||
</Button> | ||
</Flex> | ||
</Card> | ||
</Flex> | ||
</div> | ||
) | ||
} | ||
|
||
export default NotFoundView |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.