import {createApp} from 'vue'
import '@/app.scss'
import '@/assets/css/main.css'
import {pinia} from "@/store";
import Taro from "@tarojs/taro";
import {MINI_PROGRAM_USER_CONFIG} from "@/config";
import {useUserStore} from "@/store/userStore";
import {initEnum} from "@/enums";

const App = createApp({
  onLaunch(opt) {
    initEnum()
    if (opt.path === 'subPages/projectManager/securityUserForm/securityUserForm' && opt.query.type === 'QcCodeInput') {
      return
    }
    const tokenInfo = useUserStore().getTokenInfo();
    if (tokenInfo) {
      Taro.switchTab({
        url: MINI_PROGRAM_USER_CONFIG[tokenInfo.extData.identity.value].toIndex
      })
    } else {
      Taro.navigateTo({
        url: '/pages/login/login',
      })
    }
  },
  // 入口组件不需要实现 render 方法，即使实现了也会被 taro 所覆盖
})

App.use(pinia)

export default App
