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