mirror of
https://github.com/PlayEdu/h5.git
synced 2025-12-26 01:49:46 +08:00
项目初始化
This commit is contained in:
2
src/pages/index.ts
Normal file
2
src/pages/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './login';
|
||||
export * from './layout';
|
||||
0
src/pages/index/index.module.scss
Normal file
0
src/pages/index/index.module.scss
Normal file
28
src/pages/index/index.tsx
Normal file
28
src/pages/index/index.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { user } from "../../api/index";
|
||||
import styles from "./index.module.scss";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
const IndexPage = () => {
|
||||
const systemConfig = useSelector((state: any) => state.systemConfig.value);
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [tabKey, setTabKey] = useState(0);
|
||||
const departments = useSelector(
|
||||
(state: any) => state.loginUser.value.departments
|
||||
);
|
||||
const currentDepId = useSelector(
|
||||
(state: any) => state.loginUser.value.currentDepId
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
document.title = systemConfig.systemName || "首页";
|
||||
}, [systemConfig]);
|
||||
|
||||
return (
|
||||
<div className="main-body">
|
||||
<div className="content">我是首页</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default IndexPage;
|
||||
66
src/pages/init/index.tsx
Normal file
66
src/pages/init/index.tsx
Normal file
@@ -0,0 +1,66 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { Outlet } from "react-router-dom";
|
||||
import {
|
||||
SystemConfigStoreInterface,
|
||||
saveConfigAction,
|
||||
} from "../../store/system/systemConfigSlice";
|
||||
import { loginAction } from "../../store/user/loginUserSlice";
|
||||
import { useParams, useLocation } from "react-router-dom";
|
||||
|
||||
interface Props {
|
||||
loginData?: any;
|
||||
configData?: any;
|
||||
}
|
||||
|
||||
export const InitPage = (props: Props) => {
|
||||
const pathname = useLocation().pathname;
|
||||
const params = useParams();
|
||||
const dispatch = useDispatch();
|
||||
const [init, setInit] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (props.loginData) {
|
||||
dispatch(loginAction(props.loginData));
|
||||
}
|
||||
if (props.configData) {
|
||||
let config: SystemConfigStoreInterface = {
|
||||
//系统配置
|
||||
systemApiUrl: props.configData["system-api-url"],
|
||||
systemH5Url: props.configData["system-h5-url"],
|
||||
systemLogo: props.configData["system-logo"],
|
||||
systemName: props.configData["system-name"],
|
||||
systemPcUrl: props.configData["system-pc-url"],
|
||||
pcIndexFooterMsg: props.configData["system-pc-index-footer-msg"],
|
||||
//播放器配置
|
||||
playerPoster: props.configData["player-poster"],
|
||||
playerIsEnabledBulletSecret:
|
||||
props.configData["player-is-enabled-bullet-secret"] &&
|
||||
props.configData["player-is-enabled-bullet-secret"] === "1"
|
||||
? true
|
||||
: false,
|
||||
playerIsDisabledDrag:
|
||||
props.configData["player-disabled-drag"] &&
|
||||
props.configData["player-disabled-drag"] === "1"
|
||||
? true
|
||||
: false,
|
||||
playerBulletSecretText: props.configData["player-bullet-secret-text"],
|
||||
playerBulletSecretColor: props.configData["player-bullet-secret-color"],
|
||||
playerBulletSecretOpacity:
|
||||
props.configData["player-bullet-secret-opacity"],
|
||||
};
|
||||
dispatch(saveConfigAction(config));
|
||||
}
|
||||
setInit(true);
|
||||
}, [props]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{init && (
|
||||
<div>
|
||||
<Outlet />
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
11
src/pages/loading/index.tsx
Normal file
11
src/pages/loading/index.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import { DotLoading } from 'antd-mobile'
|
||||
|
||||
const LoadingPage = () => {
|
||||
return (
|
||||
<>
|
||||
<DotLoading color='primary' />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default LoadingPage;
|
||||
0
src/pages/login/index.module.scss
Normal file
0
src/pages/login/index.module.scss
Normal file
40
src/pages/login/index.tsx
Normal file
40
src/pages/login/index.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Button } from "antd-mobile";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { loginAction, logoutAction } from "../../store/user/loginUserSlice";
|
||||
|
||||
const LoginPage = () => {
|
||||
const dispatch = useDispatch();
|
||||
const loginState = useSelector((state: any) => {
|
||||
return state.loginUser.value;
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
onClick={() => {
|
||||
dispatch(
|
||||
loginAction({
|
||||
user: {
|
||||
name: "霸王",
|
||||
},
|
||||
})
|
||||
);
|
||||
}}
|
||||
>
|
||||
登录吧
|
||||
</Button>
|
||||
|
||||
{loginState.isLogin && (
|
||||
<Button
|
||||
onClick={() => {
|
||||
dispatch(logoutAction());
|
||||
}}
|
||||
>
|
||||
{loginState.user.name}
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default LoginPage;
|
||||
Reference in New Issue
Block a user