App.vue 810 B

12345678910111213141516171819202122232425262728293031323334
  1. <template>
  2. <view class="app-container" :data-theme="themeStore.theme">
  3. <slot />
  4. </view>
  5. </template>
  6. <script setup>
  7. import { onLaunch } from '@dcloudio/uni-app'
  8. import { useUserStore } from '@/stores/user'
  9. import { useThemeStore } from '@/stores/theme'
  10. const userStore = useUserStore()
  11. const themeStore = useThemeStore()
  12. onLaunch(() => {
  13. // Initialize theme first (before anything renders)
  14. themeStore.init()
  15. // Fetch user profile if logged in
  16. if (userStore.isLoggedIn) {
  17. userStore.fetchProfile().catch(() => {})
  18. }
  19. })
  20. </script>
  21. <style>
  22. .app-container {
  23. min-height: 100vh;
  24. /* Use CSS variables for theme-aware backgrounds */
  25. background: var(--color-bg);
  26. color: var(--color-text-primary);
  27. transition: background var(--transition-normal), color var(--transition-normal);
  28. }
  29. </style>