import React, { Component } from 'react';
import Taro from '@tarojs/taro';
import { SWRConfig } from 'swr';
import 'taro-ui/dist/style/index.scss';
//import appUpdate from './utils/appUpdate';
import './app.scss';

class App extends Component {


  componentDidMount() {
    const userInfo = Taro.getStorageSync('userInfo') || null;
    const token = Taro.getStorageSync('token') || null;
    if (!userInfo || !token) {
      Taro.showModal({
        title: '提示',
        content: '未获取用户信息,请重新登录',
        showCancel: false,
        success: (res) => {
          if (res.confirm) {
            Taro.reLaunch({
              url: '/pages/auth/login/login'
            });
          }
        }
      });
    }
  }

  componentDidShow() { }

  componentDidHide() { }

  componentDidCatchError() { }

  // 在 App 类中的 render() 函数没有实际作用
  // 请勿修改此函数
  render() {
    return (
      <SWRConfig
        value={{
          suspense: false,
          dedupingInterval: 2000
        }}
      >
        {this.props.children}
      </SWRConfig>
    )
  }
}

export default App
