mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-15 08:41:37 +00:00
Update docker compose file
* Add token in global state
This commit is contained in:
36
docker-compose.yml
Normal file
36
docker-compose.yml
Normal file
@ -0,0 +1,36 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
mysql:
|
||||
container_name: mysql
|
||||
image: mysql
|
||||
# restart: always
|
||||
volumes:
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
ports:
|
||||
- "3309:3306"
|
||||
environment:
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: true
|
||||
networks:
|
||||
- "front"
|
||||
|
||||
blog:
|
||||
container_name: blog
|
||||
build:
|
||||
context: .
|
||||
network: defectingcatgithubio_front
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
depends_on:
|
||||
- "mysql"
|
||||
networks:
|
||||
- "front"
|
||||
|
||||
networks:
|
||||
front:
|
||||
driver: bridge
|
||||
driver_opts:
|
||||
com.docker.network.enable_ipv6: "true"
|
@ -4,6 +4,7 @@ export enum ActionKind {
|
||||
SETQUERY = 'SETQUERY',
|
||||
SETPATH = 'SETPATH',
|
||||
SETTHEME = 'SETTHEME',
|
||||
SETTOKEN = 'SETTOEKN',
|
||||
}
|
||||
|
||||
type ReducerAction = {
|
||||
@ -27,12 +28,18 @@ type State = {
|
||||
* Use document.documentElement.classList
|
||||
*/
|
||||
isDark: boolean;
|
||||
|
||||
/**
|
||||
* User token, if exist that's mean user logined.
|
||||
*/
|
||||
token: string | null;
|
||||
};
|
||||
|
||||
const initialState: State = {
|
||||
searchQuery: '',
|
||||
backPath: '',
|
||||
isDark: false,
|
||||
token: null,
|
||||
};
|
||||
|
||||
const reducer = (state: State, action: ReducerAction): State => {
|
||||
@ -47,6 +54,11 @@ const reducer = (state: State, action: ReducerAction): State => {
|
||||
...state,
|
||||
isDark: document.documentElement.classList.contains('dark'),
|
||||
};
|
||||
case ActionKind.SETTOKEN:
|
||||
return {
|
||||
...state,
|
||||
token: window.localStorage.getItem('token'),
|
||||
};
|
||||
default:
|
||||
throw new Error();
|
||||
}
|
||||
@ -68,6 +80,10 @@ const RUAStore: FC = ({ children }) => {
|
||||
type: ActionKind.SETTHEME,
|
||||
payload: '',
|
||||
});
|
||||
dispatch({
|
||||
type: ActionKind.SETTOKEN,
|
||||
payload: '',
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
Reference in New Issue
Block a user