diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 79accdb..395fc07 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,10 +1,20 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; +import { Router, RouterEvent } from '@angular/router'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'], }) -export class AppComponent { + +export class AppComponent implements OnInit{ + constructor(private router: Router){ } + + ngOnInit(){ + document.addEventListener('GoChangeRoute_Callback', (event:any) => { + this.router.navigate([event.detail]) + console.log("here") + }) + } title = 'go-web'; } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index ca26181..ce9ca93 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -14,9 +14,10 @@ import { MainModule } from './components/main/main.module'; import { PlaygroundModule } from './components/playground/playground.module'; import { SandboxModule } from './components/sandbox/sandbox.module'; import { SignInModule } from './components/sign-in/sign-in.module'; +import { LoadingScreenComponent } from './components/loading-screen/loading-screen.component'; @NgModule({ - declarations: [AppComponent], + declarations: [AppComponent, LoadingScreenComponent], imports: [ BrowserModule, AppRoutingModule, diff --git a/src/app/components/loading-screen/loading-screen.component.html b/src/app/components/loading-screen/loading-screen.component.html new file mode 100644 index 0000000..a400711 --- /dev/null +++ b/src/app/components/loading-screen/loading-screen.component.html @@ -0,0 +1 @@ +

loading-screen works!

diff --git a/src/app/components/loading-screen/loading-screen.component.scss b/src/app/components/loading-screen/loading-screen.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/components/loading-screen/loading-screen.component.spec.ts b/src/app/components/loading-screen/loading-screen.component.spec.ts new file mode 100644 index 0000000..3ea00df --- /dev/null +++ b/src/app/components/loading-screen/loading-screen.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { LoadingScreenComponent } from './loading-screen.component'; + +describe('LoadingScreenComponent', () => { + let component: LoadingScreenComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ LoadingScreenComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(LoadingScreenComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/loading-screen/loading-screen.component.ts b/src/app/components/loading-screen/loading-screen.component.ts new file mode 100644 index 0000000..98e6f2f --- /dev/null +++ b/src/app/components/loading-screen/loading-screen.component.ts @@ -0,0 +1,14 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + templateUrl: './loading-screen.component.html', + styleUrls: ['./loading-screen.component.scss'] +}) +export class LoadingScreenComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/interfaces/game.interface.ts b/src/app/interfaces/game.interface.ts index f8ad7fb..350daf3 100644 --- a/src/app/interfaces/game.interface.ts +++ b/src/app/interfaces/game.interface.ts @@ -1,5 +1,4 @@ export interface Game { - //id: number; //TODO: Заменить на строку gameId: string title: string; image: string; diff --git a/src/app/modules/app-routing.module.ts b/src/app/modules/app-routing.module.ts index d1ee2ce..d468c51 100644 --- a/src/app/modules/app-routing.module.ts +++ b/src/app/modules/app-routing.module.ts @@ -1,5 +1,6 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { LoadingScreenComponent } from '../components/loading-screen/loading-screen.component'; import { MainRoutingModule } from '../components/main/routing.module'; import { PlaygroundComponent } from '../components/playground/playground.component'; import { SandboxComponent } from '../components/sandbox/sandbox.component'; @@ -11,7 +12,7 @@ const routes: Routes = [ component: PlaygroundComponent, }, { - path: '', + path: 'main', loadChildren: () => MainRoutingModule, }, { @@ -22,6 +23,10 @@ const routes: Routes = [ path: 'sign-in', component: SignInComponent, }, + { + path: '', + component: LoadingScreenComponent, + }, ]; @NgModule({ diff --git a/src/app/services/go.ts b/src/app/services/go.ts index 1c85eb2..84fc019 100644 --- a/src/app/services/go.ts +++ b/src/app/services/go.ts @@ -9,13 +9,16 @@ export interface Go extends Window { export interface GoCallback extends Window { SetVersion: (value: string) => void; + GoChangeRoute: (value: string) => void; } let { GoGetGames, GoRunGame, GoGetSessions } = window as unknown as Go; -let { SetVersion } = window as unknown as GoCallback; +let { SetVersion, GoChangeRoute } = window as unknown as GoCallback; let w = window as unknown as GoCallback; + + // var register = function (name: string): void { // const event = new CustomEvent(`${name}_Callback`, { // detail: value @@ -25,11 +28,11 @@ let w = window as unknown as GoCallback; // w.SetVersion = register('SetVersion') -// ((window)).SetVersion = function (value: T): void { -// const event = new CustomEvent('GetVersion_Callback', { -// detail: value, -// }); -// document.dispatchEvent(event); -// }; +((window)).GoChangeRoute = function (value: T): void { + const event = new CustomEvent('GoChangeRoute_Callback', { + detail: value, + }); + document.dispatchEvent(event); +}; -export { GoGetGames, GoGetSessions, SetVersion, GoRunGame }; +export { GoGetGames, GoGetSessions, SetVersion, GoRunGame, GoChangeRoute };