import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {HomeComponent} from './pages/home/home.component';
import {RuleComponent} from './pages/rule/rule.component';
import {LoginComponent} from './pages/login/login.component';
import {ShareComponent} from './pages/share/share.component';
import {ShareApplicationComponent} from './pages/share-application/share-application.component';
import {ShareInviteComponent} from './pages/share-invite/share-invite.component';
import {rootUrl} from './utils/common';

// const routes: Routes = [
//   {
//     path: rootUrl,
//     children: [
//       {path: 'index', component: HomeComponent},//首页
//       {path: 'rule', component: RuleComponent},//规则
//       {path: 'login', component: LoginComponent},//登陆注册
//       {path: 's', component: ShareComponent},//分享页面1
//       {path: 'apply', component: ShareApplicationComponent},//提交
//       {path: 'exclusive', component: ShareInviteComponent},//专属页面-我的
//       {path: '', pathMatch: 'full', redirectTo: 'index'},
//     ],
//   },
//   {path: '', pathMatch: 'full', redirectTo: rootUrl},
// ];

const routes: Routes = [
  {path: 'index', component: HomeComponent},//首页
  {path: 'rule', component: RuleComponent},//规则
  {path: 'login', component: LoginComponent},//登陆注册
  {
    path: 's', children: [
      {path: '', component: ShareComponent},
      {path: 'apply', component: ShareApplicationComponent},//提交
    ]
  },//分享页面1
  {path: 'exclusive', component: ShareInviteComponent},//专属页面-我的
  {path: '**', pathMatch: 'full', redirectTo: 'index'},
];

@NgModule({
  imports: [RouterModule.forRoot(routes, {
    initialNavigation: 'enabled'
  })],
  exports: [RouterModule]
})
export class AppRoutingModule {
}
