temp
This commit is contained in:
24
src/App.tsx
24
src/App.tsx
@@ -79,17 +79,17 @@ function openFNotification() {
|
||||
* 获取服务端异步菜单
|
||||
* @param handler 执行回调
|
||||
*/
|
||||
function fetchSmenu(handler: any) {
|
||||
const setAlitaMenu = (menus: any) => {
|
||||
handler(menus);
|
||||
// this.props.setAlitaState({ stateName: 'smenus', data: menus });
|
||||
};
|
||||
setAlitaMenu(umbrella.getLocalStorage('smenus') || []);
|
||||
fetchMenu().then((smenus) => {
|
||||
setAlitaMenu(smenus);
|
||||
umbrella.setLocalStorage('smenus', smenus);
|
||||
});
|
||||
}
|
||||
// function fetchSmenu(handler: any) {
|
||||
// const setAlitaMenu = (menus: any) => {
|
||||
// handler(menus);
|
||||
// // this.props.setAlitaState({ stateName: 'smenus', data: menus });
|
||||
// };
|
||||
// setAlitaMenu(umbrella.getLocalStorage('smenus') || []);
|
||||
// fetchMenu().then((smenus) => {
|
||||
// setAlitaMenu(smenus);
|
||||
// umbrella.setLocalStorage('smenus', smenus);
|
||||
// });
|
||||
// }
|
||||
|
||||
const App = (props: AppProps) => {
|
||||
const [collapsed, setCollapsed] = useState<boolean>(false);
|
||||
@@ -106,7 +106,7 @@ const App = (props: AppProps) => {
|
||||
|
||||
handleResize((isMobile: boolean) => setAlita('responsive', { isMobile }));
|
||||
openFNotification();
|
||||
fetchSmenu((smenus: any[]) => setAlita('smenus', smenus));
|
||||
// fetchSmenu((smenus: any[]) => setAlita('smenus', smenus));
|
||||
}, [setAlita]);
|
||||
|
||||
function toggle() {
|
||||
|
||||
@@ -26,7 +26,7 @@ const SiderCustom = (props: SiderCustomProps) => {
|
||||
const [firstHide, tFirstHide] = useSwitch();
|
||||
const [menu, setMenu] = useState<IMenu>({ openKeys: [''], selectedKey: '' });
|
||||
// 异步菜单
|
||||
const [smenus] = useAlita({ smenus: [] }, { light: true });
|
||||
// const [smenus] = useAlita({ smenus: [] }, { light: true });
|
||||
const { location, collapsed: pCollapsed } = props;
|
||||
const prePathname = usePrevious(props.location.pathname);
|
||||
|
||||
@@ -81,7 +81,8 @@ const SiderCustom = (props: SiderCustomProps) => {
|
||||
>
|
||||
<div className="logo" />
|
||||
<SiderMenu
|
||||
menus={[...routes.menus, ...smenus]}
|
||||
// menus={[...routes.menus, ...smenus]}
|
||||
menus={[...routes.menus]}
|
||||
onClick={menuClick}
|
||||
mode="inline"
|
||||
selectedKeys={[menu.selectedKey]}
|
||||
|
||||
@@ -34,6 +34,7 @@ import Env from './env';
|
||||
import Home from './visualize/Home';
|
||||
import UserManage from './management/UserManage';
|
||||
import BlankPage from './management/BlankPage';
|
||||
import StationInfo from './station/StationInfo';
|
||||
|
||||
const WysiwygBundle = Loadable({
|
||||
// 按需加载富文本配置
|
||||
@@ -73,4 +74,5 @@ export default {
|
||||
Home,
|
||||
UserManage,
|
||||
BlankPage,
|
||||
StationInfo,
|
||||
} as any;
|
||||
|
||||
@@ -36,10 +36,18 @@ const Login = (props: LoginProps) => {
|
||||
}, [history, auth]);
|
||||
|
||||
const handleSubmit = async (values: any) => {
|
||||
console.log(await checkUser(values));
|
||||
if (await checkUser(values)) {
|
||||
setAlita({ funcName: values.userName, stateName: 'auth' });
|
||||
}
|
||||
trailwayLogin({ username: values.userName, password: values.password }).then((res) => {
|
||||
if (res.data.success) {
|
||||
let user = {
|
||||
uid: res.data.id,
|
||||
role: res.data.role === 1 ? '系统管理员' : '访客',
|
||||
roleType: res.data.role,
|
||||
username: values.userName,
|
||||
permissions: res.data.role === 1 ? ['auth/admin'] : [],
|
||||
};
|
||||
setAlita('auth', user);
|
||||
}
|
||||
});
|
||||
};
|
||||
const checkUser = async (values: any) => {
|
||||
let success = await trailwayLogin({
|
||||
|
||||
19
src/components/station/StationInfo.tsx
Normal file
19
src/components/station/StationInfo.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Card } from 'antd';
|
||||
import React from 'react';
|
||||
|
||||
type StationInfoProps = {
|
||||
query: any;
|
||||
};
|
||||
|
||||
const StationInfo = (props: StationInfoProps) => {
|
||||
console.log(props.query.param1);
|
||||
return (
|
||||
<div>
|
||||
<Card title="站点信息">
|
||||
<p>参数:{props.query.t}</p>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default StationInfo;
|
||||
@@ -8,6 +8,7 @@ export interface IFMenuBase {
|
||||
route?: string;
|
||||
/** 是否登录校验,true不进行校验(访客) */
|
||||
login?: boolean;
|
||||
showAuth?: string;
|
||||
}
|
||||
|
||||
export interface IFMenu extends IFMenuBase {
|
||||
@@ -150,6 +151,12 @@ const menus: {
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
{
|
||||
key: '/app/station',
|
||||
title: '站点信息',
|
||||
icon: 'bars',
|
||||
component: 'StationInfo',
|
||||
},
|
||||
{
|
||||
key: '/app/manage',
|
||||
title: '管理',
|
||||
@@ -159,6 +166,7 @@ const menus: {
|
||||
key: '/app/manage/user',
|
||||
title: '用户管理',
|
||||
component: 'UserManage',
|
||||
requireAuth: 'auth/admin',
|
||||
},
|
||||
// {
|
||||
// key: '/app/extension/visitor',
|
||||
|
||||
@@ -16,7 +16,7 @@ type CRouterProps = {
|
||||
|
||||
const CRouter = (props: CRouterProps) => {
|
||||
const { auth } = props;
|
||||
const [smenus] = useAlita({ smenus: null }, { light: true });
|
||||
// const [smenus] = useAlita({ smenus: null }, { light: true });
|
||||
|
||||
const getPermits = (): any[] | null => {
|
||||
return auth ? auth.permissions : null;
|
||||
|
||||
@@ -19,4 +19,4 @@ export const GIT_USER = 'https://api.github.com/user';
|
||||
export const NEWS_BBC =
|
||||
'https://newsapi.org/v2/top-headlines?sources=bbc-news&apiKey=429904aa01f54a39a278a406acf50070';
|
||||
|
||||
export const TRAILWAY_API = 'http://localhost:8000';
|
||||
export const TRAILWAY_API = 'http://127.0.0.1:8000';
|
||||
|
||||
Reference in New Issue
Block a user