diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d062169 --- /dev/null +++ b/docker-compose.yml @@ -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" \ No newline at end of file diff --git a/lib/store/index.tsx b/lib/store/index.tsx index 3a050ea..6180355 100644 --- a/lib/store/index.tsx +++ b/lib/store/index.tsx @@ -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 (