import Taro from "@tarojs/taro";
import { Component, PropsWithChildren } from "react";
import "./app.less";
// // html4
// import "@tarojs/taro/html.css";
// // html5
// import "@tarojs/taro/html5.css";

import { Provider } from "react-redux";
import store from "./store";
import "./iconfont/iconfont.css";
import "taro-ui/rn/style/components/icon.scss";

import { go } from "./utils/traoAPI";

class App extends Component<PropsWithChildren> {
  // 可以使用所有的 React 生命周期方法
  componentDidMount() {}

  // 对应 onLaunch
  onLaunch(options) {
    // console.log("onLaunch", options);
    if (options.scene == 1007 || options.scene == 1008) {
      return;
    }

    // 每次进入小程序，删除可能残留的同步状态
    Taro.removeStorageSync("isSyncHistory");

    // go("/instrument/pages/instrument_clickin_upload/index");
    // go("/instrument/pages/instrument/intro");
    // Taro.switchTab({
    //   url: "/pages/user/user",
    // });
  }

  onError(error) {
    console.log("error 错误捕获", error);
  }
  onUnload() {
    console.log("App onUnload");
    Taro.removeStorageSync("isScan"); // 扫码弹窗显示完后，不需要再判断是否扫码
    Taro.removeStorageSync("serial"); // 扫码弹窗显示完后，删除缓存的扫码序列号
  }

  // 对应 onShow
  componentDidShow() {}

  // 对应 onHide
  componentDidHide() {}

  // this.props.children 是将要会渲染的页面
  render() {
    // return this.props.children
    return <Provider store={store} children={this.props.children}></Provider>;
  }
}

export default App;
