import React from "react"
import { createRoot } from 'react-dom/client'
import Router from "./router"
import { Provider } from "react-redux"
import { HashRouter } from "react-router-dom"
import store from "./store"
import { ConfigProvider } from "antd"
import zhCN from "antd/lib/locale/zh_CN.js"
import "@/assets/css/index.scss"


/*
 * 初始化默认引入主题样式
 */
const createThemeSheet = (props) => {
  let skin = localStorage.getItem("skin") || 'dark'
  let head = document.head || document.getElementsByTagName('head')[0];
  let style = document.createElement('link');
  style.setAttribute('rel', 'stylesheet');
  style.setAttribute('href', `./static/css/antd.${skin}.min.css`);
  style.setAttribute('id', 'theme-style');
  head.appendChild(style);
}
const container = document.getElementById('root')
const root = createRoot(container)
createThemeSheet()
root.render(
  <ConfigProvider locale={zhCN}>
    <Provider store={store}>
      <HashRouter><Router /></HashRouter>
    </Provider>
  </ConfigProvider>
)
