import { Routes,mapToCanActivate } from '@angular/router';
import { TabsRoutingModule } from '../modules/tabs/tabs.modules.routes';
import { AuthGuard } from '../services/auth.guard';

import { TabsComponent } from '../modules/tabs/tabs/tabs.component';
import { UserRoutingModule } from '../modules/user/user.modules.routes';
import { AccountRoutingModule } from '../modules/account/account.modules.routes';
import { GoodsRoutingModule } from '../modules/goods/goods.modules.routes';
import { LiveRoutingModule } from '../modules/live/live.modules.routes';
import { LoginAuthGuard } from '../modules/login/auth.guard';

export const routes: Routes = [
  { path: '', redirectTo:'tabs', pathMatch: "full",}, // 默认跳转到 ''
  {
    path: 'invite/:id',
    loadComponent:()=> import('../modules/login/invite/invite.component').then((mod) => mod.InviteComponent),
  },
  {
    path: 'login',
    canActivate: mapToCanActivate([LoginAuthGuard]),
    loadComponent:()=> import('../modules/login/login.component').then((mod) => mod.LoginComponent),
  },
  {
    path: 'webview',
    canActivate: mapToCanActivate([AuthGuard]),
    loadComponent:()=> import('../modules/webview/webview.component').then((mod) => mod.WebviewComponent),
  },
  {
    path: 'tabs', //首页tabs
    component: TabsComponent,
    canActivate: mapToCanActivate([AuthGuard]),
    loadChildren: () =>TabsRoutingModule,
  },
  {
    path: 'user', 
    canActivate: mapToCanActivate([AuthGuard]),
    loadChildren: () =>UserRoutingModule,
  },
  {
    path: 'account', 
    canActivate: mapToCanActivate([AuthGuard]),
    loadChildren: () =>AccountRoutingModule,
  },
  {
    path: 'goods', 
    canActivate: mapToCanActivate([AuthGuard]),
    loadChildren: () =>GoodsRoutingModule,
  },
  {
    path: 'live', 
    canActivate: mapToCanActivate([AuthGuard]),
    loadChildren: () =>LiveRoutingModule,
  },
  
];
