2026-02-21 09:53:31 -05:00
|
|
|
<script setup lang="ts">
|
2026-03-03 15:04:16 -05:00
|
|
|
import { computed, onMounted, onUnmounted } from 'vue'
|
2026-02-21 09:53:31 -05:00
|
|
|
import { RouterView, useRoute } from "vue-router";
|
|
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
|
import MainLayout from "./components/layouts/MainLayout.vue";
|
|
|
|
|
import { useThemeStore } from './stores/theme'
|
2026-02-25 16:29:13 -05:00
|
|
|
import { useAuthStore } from './stores/auth'
|
|
|
|
|
import { useFavoritesStore } from './stores/favorites'
|
2026-02-21 09:53:31 -05:00
|
|
|
import { analyticsService } from '@/services/analyticsService'
|
|
|
|
|
|
|
|
|
|
// Initialize theme store
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const { locale } = useI18n()
|
|
|
|
|
const themeStore = useThemeStore()
|
2026-02-25 16:29:13 -05:00
|
|
|
const authStore = useAuthStore()
|
|
|
|
|
const favoritesStore = useFavoritesStore()
|
2026-02-21 09:53:31 -05:00
|
|
|
|
|
|
|
|
const isSplashScreen = computed(() => route.name === 'splash')
|
2026-03-01 15:20:49 -05:00
|
|
|
const isAuthScreen = computed(() => {
|
2026-03-01 17:35:13 -05:00
|
|
|
return route.path === '/login' || route.path === '/register' || route.name === 'auth'
|
2026-03-01 15:20:49 -05:00
|
|
|
})
|
2026-02-21 09:53:31 -05:00
|
|
|
|
2026-03-03 15:04:16 -05:00
|
|
|
let lastHiddenAt: number | null = null
|
2026-03-03 20:51:17 -05:00
|
|
|
let refocusDebounceTimer: ReturnType<typeof setTimeout> | null = null
|
|
|
|
|
|
|
|
|
|
function dispatchRefocus(reason: string) {
|
|
|
|
|
// Debounce: no disparar dos eventos seguidos en menos de 1 segundo
|
|
|
|
|
if (refocusDebounceTimer) return
|
|
|
|
|
refocusDebounceTimer = setTimeout(() => { refocusDebounceTimer = null }, 1000)
|
|
|
|
|
console.log(`SIBU | App refocus — motivo: ${reason}`)
|
|
|
|
|
window.dispatchEvent(new CustomEvent('app-refocus'))
|
|
|
|
|
}
|
2026-03-03 15:04:16 -05:00
|
|
|
|
|
|
|
|
function handleVisibilityChange() {
|
|
|
|
|
if (document.visibilityState === 'hidden') {
|
|
|
|
|
lastHiddenAt = Date.now()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (document.visibilityState === 'visible' && lastHiddenAt !== null) {
|
|
|
|
|
const secondsAway = (Date.now() - lastHiddenAt) / 1000
|
2026-03-03 20:51:17 -05:00
|
|
|
// Umbral bajo (1 s) para capturar retornos rápidos desde Google Maps / links externos
|
|
|
|
|
if (secondsAway > 1) {
|
|
|
|
|
dispatchRefocus(`visibilitychange tras ${secondsAway.toFixed(1)}s`)
|
|
|
|
|
}
|
|
|
|
|
lastHiddenAt = null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fallback: 'pageshow' se dispara al volver desde el bfcache (back-forward cache)
|
|
|
|
|
// Muy común en Safari/iOS cuando se abre un link externo y se regresa
|
|
|
|
|
function handlePageShow(event: PageTransitionEvent) {
|
|
|
|
|
if (event.persisted) {
|
|
|
|
|
// La página fue restaurada desde bfcache — siempre necesita refocus
|
|
|
|
|
dispatchRefocus('pageshow persisted (bfcache)')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fallback: 'focus' en window cubre casos donde visibilitychange no se dispara
|
|
|
|
|
// (algunos navegadores Android al volver de otra app)
|
|
|
|
|
let windowFocusTimer: ReturnType<typeof setTimeout> | null = null
|
|
|
|
|
function handleWindowFocus() {
|
|
|
|
|
// Solo si la pestaña estuvo oculta antes
|
|
|
|
|
if (lastHiddenAt !== null) {
|
|
|
|
|
const secondsAway = (Date.now() - lastHiddenAt) / 1000
|
|
|
|
|
if (secondsAway > 1) {
|
|
|
|
|
dispatchRefocus(`window focus tras ${secondsAway.toFixed(1)}s`)
|
2026-03-03 15:04:16 -05:00
|
|
|
}
|
|
|
|
|
lastHiddenAt = null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-21 09:53:31 -05:00
|
|
|
onMounted(() => {
|
|
|
|
|
themeStore.applyTheme()
|
|
|
|
|
analyticsService.logEvent({
|
|
|
|
|
event_name: 'app_open',
|
|
|
|
|
properties: { language: locale.value }
|
|
|
|
|
})
|
2026-02-25 16:29:13 -05:00
|
|
|
// Load favorites if the user is already logged in
|
|
|
|
|
if (authStore.isAuthenticated) {
|
|
|
|
|
favoritesStore.loadFavorites()
|
|
|
|
|
}
|
2026-03-03 15:04:16 -05:00
|
|
|
document.addEventListener('visibilitychange', handleVisibilityChange)
|
2026-03-03 20:51:17 -05:00
|
|
|
window.addEventListener('pageshow', handlePageShow)
|
|
|
|
|
window.addEventListener('focus', handleWindowFocus)
|
2026-03-03 15:04:16 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
document.removeEventListener('visibilitychange', handleVisibilityChange)
|
2026-03-03 20:51:17 -05:00
|
|
|
window.removeEventListener('pageshow', handlePageShow)
|
|
|
|
|
window.removeEventListener('focus', handleWindowFocus)
|
|
|
|
|
if (refocusDebounceTimer) clearTimeout(refocusDebounceTimer)
|
|
|
|
|
if (windowFocusTimer) clearTimeout(windowFocusTimer)
|
2026-02-21 09:53:31 -05:00
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<MainLayout v-if="!isSplashScreen && !isAuthScreen">
|
|
|
|
|
<RouterView />
|
|
|
|
|
</MainLayout>
|
|
|
|
|
<RouterView v-else />
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style>
|
2026-02-22 10:29:41 -05:00
|
|
|
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');
|
2026-02-21 09:53:31 -05:00
|
|
|
|
|
|
|
|
:root {
|
|
|
|
|
/* Common Variables */
|
|
|
|
|
--safe-area-top: env(safe-area-inset-top, 0px);
|
|
|
|
|
--safe-area-bottom: env(safe-area-inset-bottom, 0px);
|
2026-02-22 10:29:41 -05:00
|
|
|
--transition-speed: 0.4s;
|
|
|
|
|
--font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
|
2026-02-21 09:53:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* DARK THEME (Default & .dark) */
|
|
|
|
|
:root,
|
|
|
|
|
html.dark {
|
|
|
|
|
--bg-primary: #0f172a;
|
|
|
|
|
--bg-secondary: #020617;
|
|
|
|
|
--text-primary: #f8fafc;
|
|
|
|
|
--text-secondary: #94a3b8;
|
2026-02-22 10:29:41 -05:00
|
|
|
--border-color: rgba(255, 255, 255, 0.1);
|
|
|
|
|
--shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
|
2026-02-21 09:53:31 -05:00
|
|
|
|
2026-02-22 10:29:41 -05:00
|
|
|
--header-bg: rgba(15, 23, 42, 0.8);
|
2026-02-21 09:53:31 -05:00
|
|
|
--header-text: #ffffff;
|
|
|
|
|
|
2026-02-22 10:29:41 -05:00
|
|
|
--card-bg: rgba(30, 41, 59, 0.7);
|
|
|
|
|
--hover-bg: rgba(254, 231, 21, 0.08); /* SIBU Gold hint on hover */
|
2026-02-21 09:53:31 -05:00
|
|
|
--active-bg: rgba(254, 231, 21, 0.15);
|
|
|
|
|
--active-color: #fee715;
|
|
|
|
|
--accent-color: #fee715;
|
|
|
|
|
--accent-hover: #fde047;
|
|
|
|
|
|
2026-02-22 10:29:41 -05:00
|
|
|
--glass-bg: rgba(15, 23, 42, 0.6);
|
|
|
|
|
--glass-border: rgba(254, 231, 21, 0.2);
|
2026-02-21 09:53:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* LIGHT THEME */
|
|
|
|
|
html.light-theme {
|
2026-02-22 10:33:29 -05:00
|
|
|
--bg-primary: #f0f4f8;
|
2026-02-21 09:53:31 -05:00
|
|
|
--bg-secondary: #ffffff;
|
|
|
|
|
--text-primary: #0f172a;
|
2026-02-22 10:33:29 -05:00
|
|
|
--text-secondary: #475569;
|
|
|
|
|
--border-color: rgba(15, 23, 42, 0.1);
|
|
|
|
|
--header-bg: rgba(255, 255, 255, 0.85);
|
2026-02-21 09:53:31 -05:00
|
|
|
--header-text: #0f172a;
|
2026-02-22 10:33:29 -05:00
|
|
|
--card-bg: rgba(255, 255, 255, 0.95);
|
2026-03-03 13:21:09 -05:00
|
|
|
--hover-bg: rgba(254, 231, 21, 0.08);
|
2026-02-22 10:33:29 -05:00
|
|
|
--glass-bg: rgba(255, 255, 255, 0.8);
|
2026-03-03 13:21:09 -05:00
|
|
|
--glass-border: rgba(254, 231, 21, 0.2);
|
2026-02-22 10:33:29 -05:00
|
|
|
--shadow: 0 15px 40px rgba(15, 23, 42, 0.1);
|
2026-03-03 13:21:09 -05:00
|
|
|
--active-bg: rgba(254, 231, 21, 0.15);
|
|
|
|
|
--active-color: #fee715;
|
|
|
|
|
--accent-color: #fee715;
|
2026-02-21 09:53:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html,
|
|
|
|
|
body {
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
overflow-x: hidden;
|
|
|
|
|
background-color: var(--bg-primary);
|
|
|
|
|
color: var(--text-primary);
|
2026-02-22 10:29:41 -05:00
|
|
|
transition: background-color 0.5s ease-in-out;
|
|
|
|
|
font-family: var(--font-family);
|
|
|
|
|
letter-spacing: -0.02em;
|
2026-02-21 09:53:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
body {
|
|
|
|
|
-webkit-font-smoothing: antialiased;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#app {
|
|
|
|
|
width: 100%;
|
2026-02-22 13:57:31 -05:00
|
|
|
height: 100vh;
|
2026-02-21 09:53:31 -05:00
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Global Utilities */
|
|
|
|
|
.glass-effect {
|
|
|
|
|
background: var(--glass-bg);
|
|
|
|
|
backdrop-filter: blur(12px);
|
|
|
|
|
-webkit-backdrop-filter: blur(12px);
|
|
|
|
|
border: 1px solid var(--glass-border);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.gradient-text {
|
|
|
|
|
background: linear-gradient(135deg, #fee715 0%, #facc15 100%);
|
|
|
|
|
-webkit-background-clip: text;
|
|
|
|
|
background-clip: text;
|
|
|
|
|
-webkit-text-fill-color: transparent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* App Transition */
|
|
|
|
|
.page-enter-active,
|
|
|
|
|
.page-leave-active {
|
|
|
|
|
transition: opacity 0.3s ease, transform 0.3s ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.page-enter-from {
|
|
|
|
|
opacity: 0;
|
|
|
|
|
transform: translateY(10px);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.page-leave-to {
|
|
|
|
|
opacity: 0;
|
|
|
|
|
transform: translateY(-10px);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::-webkit-scrollbar {
|
|
|
|
|
width: 5px;
|
|
|
|
|
}
|
|
|
|
|
::-webkit-scrollbar-track {
|
|
|
|
|
background: transparent;
|
|
|
|
|
}
|
|
|
|
|
::-webkit-scrollbar-thumb {
|
|
|
|
|
background: var(--border-color);
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
}
|
|
|
|
|
::-webkit-scrollbar-thumb:hover {
|
|
|
|
|
background: var(--active-color);
|
|
|
|
|
}
|
|
|
|
|
</style>
|