38 lines
875 B
Markdown
38 lines
875 B
Markdown
# Router Documentation
|
|
|
|
## Route Configuration
|
|
|
|
### Public Routes
|
|
- `/login`: Login page
|
|
- `/register`: Registration page
|
|
|
|
### Authenticated Routes (Nested under Layout)
|
|
- `/dashboard`: Main dashboard
|
|
- `/user`: User management
|
|
- `/account`: Account settings
|
|
- `/model`: Model management
|
|
|
|
## Route Meta Fields
|
|
- `requiresAuth`: Boolean indicating if authentication is required
|
|
|
|
## Route Guards
|
|
### Authentication Check
|
|
1. Checks for `access_token` in localStorage
|
|
2. Redirects to `/login` if:
|
|
- Route requires auth (`meta.requiresAuth`)
|
|
- No valid token found
|
|
|
|
## Technical Details
|
|
- **Mode**: HTML5 History Mode
|
|
- **Component Loading**: Dynamic imports (code splitting)
|
|
- **Base Path**: Project root (`/`)
|
|
|
|
## Example Usage
|
|
```javascript
|
|
// Adding a new route
|
|
{
|
|
path: 'new-route',
|
|
component: () => import('../views/NewRoute.vue'),
|
|
meta: { requiresAuth: true }
|
|
}
|