|
|
|
|
@ -5,8 +5,9 @@
|
|
|
|
|
<div class="nav-links">
|
|
|
|
|
<span class="nav-btn-text" @click="goToHome">首页</span>
|
|
|
|
|
<span class="nav-btn-text" @click="goToCheckin">每日打卡</span>
|
|
|
|
|
<button class="nav-btn-secondary" @click="goToProfile">个人中心</button>
|
|
|
|
|
<button class="nav-btn-primary" @click="handleLogout">退出登录</button>
|
|
|
|
|
<button v-if="isLoggedIn" class="nav-btn-secondary" @click="goToProfile">个人中心</button>
|
|
|
|
|
<button v-if="isLoggedIn" class="nav-btn-primary" @click="handleLogout">退出登录</button>
|
|
|
|
|
<button v-else class="nav-btn-primary" @click="goToLogin">登录</button>
|
|
|
|
|
</div>
|
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
@ -46,8 +47,14 @@
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { useRouter } from 'vue-router'
|
|
|
|
|
import { ref, onMounted } from 'vue'
|
|
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
const isLoggedIn = ref(false)
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
isLoggedIn.value = !!localStorage.getItem('token')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const handleLogout = () => {
|
|
|
|
|
localStorage.removeItem('token')
|
|
|
|
|
@ -70,6 +77,10 @@ const goToProfile = () => {
|
|
|
|
|
const startLearning = () => {
|
|
|
|
|
alert('功能即将上线!')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const goToLogin = () => {
|
|
|
|
|
router.push('/login')
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|