Layout 100%, Notificações, SetupWizard
This commit is contained in:
+6
-29
@@ -1,7 +1,7 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import App from './App.vue'
|
||||
import router from '@/router'
|
||||
import { pinia } from '@/plugins/pinia' // ← singleton criado antes do router
|
||||
import { setOnSignedOut, initSession, listenAuthChanges, refreshSession } from '@/app/session'
|
||||
|
||||
import Aura from '@primeuix/themes/aura'
|
||||
@@ -61,11 +61,7 @@ async function applyUserThemeEarly () {
|
||||
if (error || !settings?.theme_mode) return
|
||||
|
||||
const isDark = settings.theme_mode === 'dark'
|
||||
|
||||
// o PrimeVue usa o selector .app-dark
|
||||
const root = document.documentElement
|
||||
root.classList.toggle('app-dark', isDark)
|
||||
|
||||
document.documentElement.classList.toggle('app-dark', isDark)
|
||||
localStorage.setItem('ui_theme_mode', settings.theme_mode)
|
||||
} catch {}
|
||||
}
|
||||
@@ -80,30 +76,20 @@ window.__fromVisibilityRefresh = false
|
||||
window.__appBootstrapped = false
|
||||
// ========================================
|
||||
|
||||
// 🛟 ao voltar da aba: refresh leve, sem martelar e sem rodar antes do app subir
|
||||
let lastVisibilityRefreshAt = 0
|
||||
|
||||
document.addEventListener('visibilitychange', async () => {
|
||||
if (document.visibilityState !== 'visible') return
|
||||
|
||||
// só depois do app montar (evita refresh no meio do bootstrap)
|
||||
if (!window.__appBootstrapped) return
|
||||
|
||||
const now = Date.now()
|
||||
|
||||
// no máximo 1 refresh a cada 10s
|
||||
if (now - lastVisibilityRefreshAt < 10_000) return
|
||||
|
||||
// se já tem refresh em andamento, não entra
|
||||
if (window.__sessionRefreshing) return
|
||||
|
||||
// (opcional) se não houver user, não precisa refresh
|
||||
try {
|
||||
const { data } = await supabase.auth.getUser()
|
||||
if (!data?.user) return
|
||||
} catch {
|
||||
// se falhar getUser, deixa tentar refreshSession mesmo assim
|
||||
}
|
||||
} catch {}
|
||||
|
||||
lastVisibilityRefreshAt = now
|
||||
console.log('[VISIBILITY] Aba voltou -> refreshSession()')
|
||||
@@ -114,8 +100,6 @@ document.addEventListener('visibilitychange', async () => {
|
||||
|
||||
await refreshSession()
|
||||
|
||||
// 🔔 avisa o app inteiro SOMENTE em áreas TENANT.
|
||||
// Portal (/portal) e área global (/account) NÃO devem rehidratar tenantStore/menu.
|
||||
try {
|
||||
const path = router.currentRoute.value?.path || ''
|
||||
const isTenantArea =
|
||||
@@ -130,9 +114,7 @@ document.addEventListener('visibilitychange', async () => {
|
||||
} else {
|
||||
console.log('[VISIBILITY] refresh ok (skip event) - area não-tenant:', path)
|
||||
}
|
||||
} catch {
|
||||
// se algo der errado, não dispare evento global por segurança
|
||||
}
|
||||
} catch {}
|
||||
} finally {
|
||||
window.__fromVisibilityRefresh = false
|
||||
window.__sessionRefreshing = false
|
||||
@@ -147,17 +129,14 @@ async function bootstrap () {
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
const pinia = createPinia()
|
||||
// ✅ usa o pinia singleton — o mesmo que o router/guards já conhecem
|
||||
app.use(pinia)
|
||||
|
||||
app.use(router)
|
||||
|
||||
// ✅ garante router pronto antes de montar
|
||||
await router.isReady()
|
||||
|
||||
// ✅ PrimeVue global config (tema + locale pt-BR)
|
||||
app.use(PrimeVue, {
|
||||
locale: ptBR, // 🔥 isso traduz Calendar/DatePicker
|
||||
locale: ptBR,
|
||||
theme: {
|
||||
preset: Aura,
|
||||
options: { darkModeSelector: '.app-dark' }
|
||||
@@ -167,7 +146,6 @@ async function bootstrap () {
|
||||
app.use(ToastService)
|
||||
app.use(ConfirmationService)
|
||||
|
||||
// Registro global de componentes PrimeVue frequentes
|
||||
app.component('Button', Button)
|
||||
app.component('InputText', InputText)
|
||||
app.component('Tag', Tag)
|
||||
@@ -186,7 +164,6 @@ async function bootstrap () {
|
||||
|
||||
app.mount('#app')
|
||||
|
||||
// ✅ marca boot completo
|
||||
window.__appBootstrapped = true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user