<template>
  <el-config-provider :locale="zhCn">
    <RouterView v-if="isRouterActive"></RouterView>
  </el-config-provider>
</template>

<script setup lang="ts">
// 引入组件刷新功能
import { provide , nextTick , ref , onMounted } from 'vue'
import { ElConfigProvider } from 'element-plus'
import router from './router';
import zhCn from 'element-plus/es/locale/lang/zh-cn' //引入ElemenetPlus中文
import myAxios from './api/myAxios';

const isRouterActive = ref(true)

provide('reload', () => {  //页面刷新
  isRouterActive.value = false
  nextTick(() => {
    isRouterActive.value = true
  })
})
onMounted(()=>{
  checkLoginState()
})
const checkLoginState = async ()=>{  //监测登陆状态
  console.log("start")
  const res = await myAxios.get('/user/get/login')
  console.log("end")
  if(res.data.code != 1)  {
    router.push('/')
  }
}
</script>


<style scoped>
html {
  padding: 0;
  margin: 0;
}
body {
  padding: 0;
  margin: 0;
}


</style>
