import React from "react"; import { Menu, Icon, Layout } from "antd"; import "@/account/leftTab.less"; const SubMenu = Menu.SubMenu; import { Link } from "react-router"; import { adminMenu } from "../menu"; import logo from "img/acc-logo.png"; const LeftTab = React.createClass({ getInitialState() { return { openKeys: ["sub1"], current: "index", switch: false, rootSubmenuKeys: [ "advertisementList", "proservlist", "buyList", "firmList", "talentsList", "activity" ] }; }, menuClick(e) { this.setState({ current: e.key }); window.location.hash = e.key; }, iconFun() { let menuW = document.querySelector(".ant-layout-sider"); if (this.state.switch) { menuW.style.width = "200px"; menuW.style.flex = "0 0 200px"; } else { menuW.style.width = "50px"; menuW.style.flex = "0 0 50px"; } this.setState({ switch: !this.state.switch }); }, onOpenChange(openKeys) { const latestOpenKey = openKeys.find( key => this.state.openKeys.indexOf(key) === -1 ); if (this.state.rootSubmenuKeys.indexOf(latestOpenKey) === -1) { this.setState({ openKeys }); } else { this.setState({ openKeys: latestOpenKey ? [latestOpenKey] : [] }); } }, componentWillMount() { if (window.location.hash) { let current = window.location.hash.substr(2), open = []; if (!current.length) { window.location.hash = "index"; this.setState({ openKeys: ["advertisementList"], current: "advertisementList" }); } else { adminMenu.map(item => { if (item.children) { item.children.map(atem => { if (current == atem.url) { open.push(item.url); return false; } }); } }); this.setState({ openKeys: open, current }); } } else { window.location.hash = "index"; this.setState({ openKeys: ["advertisementList"], current: "advertisementList" }); } }, render() { return (
{!this.state.switch && } {!this.state.switch && ( 管理员中心 )} {/* */}
{adminMenu.map(subMenu => { if (subMenu.children && subMenu.children.length) { return ( {!this.state.switch && {subMenu.name}} } > {subMenu.children.map(menu => ( {menu.name} ))} ); } return ( {subMenu.name} ); })}
); } }); export default LeftTab;