// import 'default-passive-events';
import App from './App'
import AppM from './AppM'

import store from './store/index'
import { Provider } from 'react-redux'
import { createRoot } from 'react-dom/client'

import { ConfigProvider } from 'antd'
// 兼容360浏览器
import { StyleProvider, legacyLogicalPropertiesTransformer } from '@ant-design/cssinjs'

import 'dayjs/locale/zh-cn'
import locale from 'antd/locale/zh_CN'

import { isMobileFu } from './utils/history'
import { httpGet } from './utils/http'

const container = document.getElementById('root') as HTMLElement
const root = createRoot(container)

// 浏览量
httpGet('https://count.4dage.com/api/count/saveVisit/SG-mSXPpz8xPea', res => {
  if (res.code === 0) {
    store.dispatch({ type: 'layout/visitSum', payload: res.data.visitSum })
  }
})

root.render(
  <ConfigProvider
    locale={locale}
    theme={{
      token: {
        colorPrimary: '#f58543'
      }
    }}
  >
    <Provider store={store}>
      <StyleProvider hashPriority='high' transformers={[legacyLogicalPropertiesTransformer]}>
        {/* 渲染 移动端 或 pc端 */}
        {isMobileFu() ? <AppM /> : <App />}
      </StyleProvider>
    </Provider>
  </ConfigProvider>
)
