<template>
  <div class="loading-box_wrapper" v-show="loading">
    <div class="loading-box">
      <van-loading size="24px" type="spinner" color="#1989fa" vertical>
        <span style="color: #1989fa">加载中...</span>
      </van-loading>
    </div>
  </div>
  <router-view />
</template>

<script setup>
import { computed } from 'vue'
import store from './store'

const loading = computed(() => {
  return store.state.loading
})

function getScreenSize() {
  const w = window.innerWidth
  const h = window.innerHeight
  const width = w + 'px'
  const height = h + 'px'
  return { w, h, width, height }
}

{
  store.dispatch({
    type: 'storeScreenSize',
    screenSize: getScreenSize()
  })
  let localCards = localStorage.getItem('patientCards')
  if (localCards) {
    let cardList = JSON.parse(localCards)
    store.dispatch({
      type: 'storePatientCardsOnly',
      cards: cardList
    })
  }
}

</script>