import { Component } from 'react'
import { Provider } from 'react-redux';
import { createLogger } from 'redux-logger'
import dva from '@/utils/dva';
import models from '@/models'
import API from "@/services";
import './app.scss'


const dvaApp = dva.createApp({
  initialState: {},
  onAction: createLogger(),
  models: models,
  onError(e, dispatch) {
    console.log('发生错误 ===> ', e, dispatch)
  },
})

const store = dvaApp.getStore();

class App extends Component {
  constructor(props: any) {
    super(props)
  }

  componentWillMount() {
    API.login()?.then(res => {
      console.log(res)
    })
  }

  render () {
    return <Provider store={store}>{this.props.children}</Provider>
  }
}

export default App
