UserPage.jsx 1.31 KB
Newer Older
wuhao's avatar
wuhao committed
1 2 3 4 5
import * as React from "react";
import Tabs from "@mui/material/Tabs";
import Tab from "@mui/material/Tab";
import Box from "@mui/material/Box";
import { Container } from "@mui/material";
wuhao's avatar
wuhao committed
6
import { useLocation } from "@umijs/max";
wuhao's avatar
wuhao committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
import navConfig from "../nav/config";

export default function UserPage() {
  const [value, setValue] = React.useState("one");

  const handleChange = (event, newValue) => {
    setValue(newValue);
  };
  const location = useLocation();
  console.log("====================================");
  console.log(location.pathname);
  console.log("====================================");

  const data = React.useMemo(() => {
    const currouteconfig = navConfig?.filter((it, i) => {
      return it?.path === location?.pathname;
    });
    return currouteconfig[0]?.children ?? [];
  }, [location.pathname]);

  return (
    <Container maxWidth="xl">
      <Tabs
        value={value}
        onChange={handleChange}
        textColor="secondary"
        indicatorColor="secondary"
        aria-label="secondary tabs example"
        sx={{ height: 64,ml:"-16px" }}
      >
        {data?.map((it, i) => (
          <Tab
            value={it?.path+i}
            label={it?.title}
            sx={{ height: 64, margin: "0 6px" }}
            key={i}
          />
        ))}
      </Tabs>
    </Container>
  );
}