mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-16 01:01:38 +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',
|
SETQUERY = 'SETQUERY',
|
||||||
SETPATH = 'SETPATH',
|
SETPATH = 'SETPATH',
|
||||||
SETTHEME = 'SETTHEME',
|
SETTHEME = 'SETTHEME',
|
||||||
|
SETTOKEN = 'SETTOEKN',
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReducerAction = {
|
type ReducerAction = {
|
||||||
@ -27,12 +28,18 @@ type State = {
|
|||||||
* Use document.documentElement.classList
|
* Use document.documentElement.classList
|
||||||
*/
|
*/
|
||||||
isDark: boolean;
|
isDark: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User token, if exist that's mean user logined.
|
||||||
|
*/
|
||||||
|
token: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialState: State = {
|
const initialState: State = {
|
||||||
searchQuery: '',
|
searchQuery: '',
|
||||||
backPath: '',
|
backPath: '',
|
||||||
isDark: false,
|
isDark: false,
|
||||||
|
token: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const reducer = (state: State, action: ReducerAction): State => {
|
const reducer = (state: State, action: ReducerAction): State => {
|
||||||
@ -47,6 +54,11 @@ const reducer = (state: State, action: ReducerAction): State => {
|
|||||||
...state,
|
...state,
|
||||||
isDark: document.documentElement.classList.contains('dark'),
|
isDark: document.documentElement.classList.contains('dark'),
|
||||||
};
|
};
|
||||||
|
case ActionKind.SETTOKEN:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
token: window.localStorage.getItem('token'),
|
||||||
|
};
|
||||||
default:
|
default:
|
||||||
throw new Error();
|
throw new Error();
|
||||||
}
|
}
|
||||||
@ -68,6 +80,10 @@ const RUAStore: FC = ({ children }) => {
|
|||||||
type: ActionKind.SETTHEME,
|
type: ActionKind.SETTHEME,
|
||||||
payload: '',
|
payload: '',
|
||||||
});
|
});
|
||||||
|
dispatch({
|
||||||
|
type: ActionKind.SETTOKEN,
|
||||||
|
payload: '',
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Reference in New Issue
Block a user