// src/app/app.routes.ts
import { Routes } from '@angular/router';
import { LoginComponent } from './pages/login.component';
import { MainLayoutComponent } from './layouts/main-layout.component';
import { AuthGuard } from './guards/auth.guard';
import { UserComponent } from './pages/user.component';
import { DashboardComponent } from './pages/dashboard.component'; // 修正：组件文件的导入路径
import { MessageTemplateComponent } from './pages/message-template.component';
import { MessageActivityComponent } from './pages/message-activity.component';
import { MessageRecordComponent } from './pages/message-record.component';
import { MessageStrategyComponent } from './pages/message-strategy.component';
import { MessageDashboardComponent } from './pages/message-dashboard.component';
import { MultiDimensionalDashboardComponent } from './pages/multi-dimensional-dashboard.component';

export const routes: Routes = [
  { path: 'login', component: LoginComponent },
  {
    path: '', // MainLayoutComponent 对应的是空路径
    component: MainLayoutComponent,
    canActivate: [AuthGuard], // 使用路由守卫保护此路由
    children: [
      // 当访问 `/` 时，默认跳转到 `/dashboard`
      { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
      { path: 'dashboard', component: DashboardComponent },
      { path: 'user', component: UserComponent },
      { path: 'message-activity', component: MessageActivityComponent },
      { path: 'message-record', component: MessageRecordComponent },
      { path: 'message-template', component: MessageTemplateComponent },
      { path: 'message-strategy', component: MessageStrategyComponent },
      { path: 'message-dashboard', component: MessageDashboardComponent },
      {
        path: 'message-multi-dimentsional',
        component: MultiDimensionalDashboardComponent,
      },
    ],
  },
  // 顶级重定向：确保应用启动时重定向到 '/dashboard'
  { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
  { path: '**', redirectTo: 'dashboard' }, // 捕获所有未知路由
];
