<template>
  <div v-if="show">
    <router-view v-slot="{ Component }">
      <transition mode="out-in">
        <component :is="Component"></component>
      </transition>
    </router-view>
  </div>
</template>

<script>
import { addRoutes, store } from 'vue-helper'
import { axios } from 'axios'
import { ref } from 'vue'
import URLUtil from '../utils/url-util.mjs'

export default {
  setup() {
    const show = ref(false)

    const key = URLUtil.getQueryVar('key')
    if (key) store.dispatch('setRouteParams', { key: key })
    const params = store.getters.getRouteParams

    console.log(params);
    if (!params || !params.key) return vant.Dialog.alert({ title: '提示', message: '权限不足！密钥缺失。' }).then(() => { })

    axios.verify(true, false, true).then(resp => {
      addRoutes('/ol-doctor', [
        {
          title: '医生问诊',
          name: 'ol-doctor',
          path: '/ol-doctor',
          component: '@/views/online/online-doctor/online-box.vue'
        }
      ])

      show.value = true
    })

    return {
      show
    }
  }
}
</script>
<style scoped>
</style>
