# Layout Components Integration Guide ## Quick Start ### 1. Import Layout Components ```typescript // In your view files import { AppLayout, AuthLayout } from '@/components/layout'; ``` ### 2. Use in Routes ```typescript // src/router/index.ts import { createRouter, createWebHistory } from 'vue-router'; import type { RouteRecordRaw } from 'vue-router'; // Views import DashboardView from '@/views/DashboardView.vue'; import LoginView from '@/views/auth/LoginView.vue'; import RegisterView from '@/views/auth/RegisterView.vue'; const routes: RouteRecordRaw[] = [ // Auth routes (no layout needed - views use AuthLayout internally) { path: '/login', name: 'Login', component: LoginView, meta: { requiresAuth: false }, }, { path: '/register', name: 'Register', component: RegisterView, meta: { requiresAuth: false }, }, // User routes (use AppLayout) { path: '/dashboard', name: 'Dashboard', component: DashboardView, meta: { requiresAuth: true, title: 'Dashboard' }, }, { path: '/api-keys', name: 'ApiKeys', component: () => import('@/views/ApiKeysView.vue'), meta: { requiresAuth: true, title: 'API Keys' }, }, { path: '/usage', name: 'Usage', component: () => import('@/views/UsageView.vue'), meta: { requiresAuth: true, title: 'Usage Statistics' }, }, { path: '/redeem', name: 'Redeem', component: () => import('@/views/RedeemView.vue'), meta: { requiresAuth: true, title: 'Redeem Code' }, }, { path: '/profile', name: 'Profile', component: () => import('@/views/ProfileView.vue'), meta: { requiresAuth: true, title: 'Profile Settings' }, }, // Admin routes (use AppLayout, admin only) { path: '/admin/dashboard', name: 'AdminDashboard', component: () => import('@/views/admin/DashboardView.vue'), meta: { requiresAuth: true, requiresAdmin: true, title: 'Admin Dashboard' }, }, { path: '/admin/users', name: 'AdminUsers', component: () => import('@/views/admin/UsersView.vue'), meta: { requiresAuth: true, requiresAdmin: true, title: 'User Management' }, }, { path: '/admin/groups', name: 'AdminGroups', component: () => import('@/views/admin/GroupsView.vue'), meta: { requiresAuth: true, requiresAdmin: true, title: 'Groups' }, }, { path: '/admin/accounts', name: 'AdminAccounts', component: () => import('@/views/admin/AccountsView.vue'), meta: { requiresAuth: true, requiresAdmin: true, title: 'Accounts' }, }, { path: '/admin/proxies', name: 'AdminProxies', component: () => import('@/views/admin/ProxiesView.vue'), meta: { requiresAuth: true, requiresAdmin: true, title: 'Proxies' }, }, { path: '/admin/redeem-codes', name: 'AdminRedeemCodes', component: () => import('@/views/admin/RedeemCodesView.vue'), meta: { requiresAuth: true, requiresAdmin: true, title: 'Redeem Codes' }, }, // Default redirect { path: '/', redirect: '/dashboard', }, ]; const router = createRouter({ history: createWebHistory(), routes, }); // Navigation guards router.beforeEach((to, from, next) => { const authStore = useAuthStore(); if (to.meta.requiresAuth && !authStore.isAuthenticated) { // Redirect to login if not authenticated next('/login'); } else if (to.meta.requiresAdmin && !authStore.isAdmin) { // Redirect to dashboard if not admin next('/dashboard'); } else { next(); } }); export default router; ``` ### 3. Initialize Stores in main.ts ```typescript // src/main.ts import { createApp } from 'vue'; import { createPinia } from 'pinia'; import App from './App.vue'; import router from './router'; import './style.css'; const app = createApp(App); const pinia = createPinia(); app.use(pinia); app.use(router); // Initialize auth state on app startup import { useAuthStore } from '@/stores'; const authStore = useAuthStore(); authStore.checkAuth(); app.mount('#app'); ``` ### 4. Update App.vue ```vue ``` --- ## View Component Templates ### Authenticated Page Template ```vue ``` ### Auth Page Template ```vue ``` --- ## Customization ### Changing Colors The components use Tailwind's indigo color scheme by default. To change: ```vue
``` ### Adding Custom Icons Replace HTML entity icons with your preferred icon library: ```vue 📈 ``` ### Sidebar Customization Modify navigation items in `AppSidebar.vue`: ```typescript // Add/remove/modify navigation items const userNavItems = [ { path: '/dashboard', label: 'Dashboard', icon: '📈' }, { path: '/new-page', label: 'New Page', icon: '📄' }, // Add new item // ... ]; ``` ### Header Customization Modify user dropdown in `AppHeader.vue`: ```vue Settings ``` --- ## Mobile Responsive Behavior ### Sidebar - **Desktop (md+)**: Always visible, can be collapsed to icon-only view - **Mobile**: Hidden by default, shown via menu toggle in header ### Header - **Desktop**: Shows full user info and balance - **Mobile**: Shows compact view with hamburger menu To improve mobile experience, you can add overlay and transitions: ```vue
``` --- ## State Management Integration ### Auth Store Usage ```typescript import { useAuthStore } from '@/stores'; const authStore = useAuthStore(); // Check if user is authenticated if (authStore.isAuthenticated) { // User is logged in } // Check if user is admin if (authStore.isAdmin) { // User has admin role } // Get current user const user = authStore.user; ``` ### App Store Usage ```typescript import { useAppStore } from '@/stores'; const appStore = useAppStore(); // Toggle sidebar appStore.toggleSidebar(); // Show notifications appStore.showSuccess('Operation completed!'); appStore.showError('Something went wrong'); appStore.showInfo('Did you know...'); appStore.showWarning('Be careful!'); // Loading state appStore.setLoading(true); // ... perform operation appStore.setLoading(false); // Or use helper await appStore.withLoading(async () => { // Your async operation }); ``` --- ## Accessibility Features All layout components include: - **Semantic HTML**: Proper use of `