You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<RouterView />
<AuthModal v-model:visible="showAuthModal" @success="handleAuthSuccess" />
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { RouterView } from 'vue-router'
import { useAuthStore } from './stores/auth'
import AuthModal from './components/AuthModal.vue'
const authStore = useAuthStore()
const showAuthModal = ref(false)
onMounted(async () => {
// 初始化用户会话
await authStore.init()
// 检查游客数据是否即将过期
checkGuestDataExpiry()
})
function handleAuthSuccess() {
// 登录成功后,如果有游客数据,提示迁移
if (authStore.guestId) {
if (confirm('检测到您有游客期间的行程数据,是否迁移到当前账户?')) {
authStore.migrateGuestData()
}
}
}
function checkGuestDataExpiry() {
if (authStore.isGuestDataExpiring) {
alert('提示您的游客数据将在2小时内过期建议登录账户以保存数据。')
showAuthModal.value = true
}
}
</script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: rgba(0,0,0,0.2);
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: rgba(0,0,0,0.3);
}
</style>