index.jsx 1.5 KB
Newer Older
wuhao's avatar
wuhao committed
1 2 3 4 5 6 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 49 50 51 52 53 54 55
import { Link, Outlet, history } from "umi";
import { Button, ConfigProvider, theme, Segmented, Space, Divider } from "antd";
import styles from "./index.less";
import React, { useState, useEffect } from "react";
import { AppstoreOutlined, BarsOutlined } from "@ant-design/icons";
import IconFont from "@/components/IconFont";
import Switches from "@/components/Switches";
import zhCN from "antd/locale/zh_CN";
import "dayjs/locale/zh-cn";
import dayjs from "dayjs";

dayjs.locale("zh-cn");

export default function Layout() {
  const [mode, setmode] = useState("light");

  return (
    <ConfigProvider
      theme={{
        algorithm: mode === "light" ? theme.algorithm : theme.darkAlgorithm,
        token: { 
          colorPrimary: "#59c4f2", 
          colorBorder:mode === "light" ? "#f0f0f0": "transparent"
        },
      }}
      locale={zhCN}
    >
      <div
        style={{ backgroundColor: mode === "light" ? "#fff" : "#363636" }}
      >
        <div className="drag"></div>
        <Space
          align="center"
          direction="horizontal"
          split={<Divider type="vertical" />}
          style={{
            justifyContent: "space-bewteen",
            position: "fixed",
            zIndex: 9999,
            right: 24,
            top: 26,
          }}
        >
          <Switches
            value={mode}
            onChange={(val) => {
              setmode(val);
            }}
          ></Switches>
        </Space>
        <Outlet context={{ mode }} />
      </div>
    </ConfigProvider>
  );
}