<script setup>
import { RouterLink, RouterView } from 'vue-router'
import {onMounted} from "vue";
import { useRouter } from 'vue-router'
const router = useRouter()
onMounted(() => {
  const isAuthenticated = sessionStorage.getItem('isAuthenticated')
  //   需要认证但未登录 → 跳转登录页
  if (!isAuthenticated) {
    router.push('/login')
  }else{
    // 已登录访问登录页 → 跳转首页
    router.push('/')
  }
  window.addEventListener('beforeunload', () => {
    sessionStorage.removeItem('isAuthenticated')
  })


})
</script>

<template>
  <!-- <HomeView></HomeView> -->
  
  <!-- <header>
    <img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" />

    <div class="wrapper">
      <HelloWorld msg="You did it!" />

      <nav>
        <RouterLink to="/">Home</RouterLink>
        <RouterLink to="/about">About</RouterLink>
      </nav>
    </div>
  </header> -->


  <RouterView />
</template>

<style scoped>

</style>

