ref/ make app reloading/working with and without usehash routing strategy
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "angular-electron",
|
||||
"version": "7.0.3",
|
||||
"version": "7.0.4",
|
||||
"description": "Angular 9 with Electron (Typescript + SASS + Hot Reload)",
|
||||
"homepage": "https://github.com/maximegris/angular-electron",
|
||||
"author": {
|
||||
@@ -22,7 +22,7 @@
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"ng": "ng",
|
||||
"start": "npm-run-all -p electron:serve ng:serve",
|
||||
"build": "npm run electron:serve-tsc && ng build",
|
||||
"build": "npm run electron:serve-tsc && ng build --base-href ./",
|
||||
"build:dev": "npm run build -- -c dev",
|
||||
"build:prod": "npm run build -- -c production",
|
||||
"ng:serve": "ng serve",
|
||||
|
||||
@@ -2,6 +2,9 @@ import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { PageNotFoundComponent } from './shared/components';
|
||||
|
||||
import { HomeRoutingModule } from './home/home-routing.module';
|
||||
import { DetailRoutingModule } from './detail/detail-routing.module';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
@@ -15,7 +18,11 @@ const routes: Routes = [
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forRoot(routes, { useHash: true })],
|
||||
imports: [
|
||||
RouterModule.forRoot(routes),
|
||||
HomeRoutingModule,
|
||||
DetailRoutingModule
|
||||
],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class AppRoutingModule {}
|
||||
export class AppRoutingModule { }
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
:host {
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
|
||||
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
|
||||
|
||||
import { HomeModule } from './home/home.module';
|
||||
import { DetailModule } from './detail/detail.module';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
@@ -32,6 +33,7 @@ export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
|
||||
CoreModule,
|
||||
SharedModule,
|
||||
HomeModule,
|
||||
DetailModule,
|
||||
AppRoutingModule,
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
|
||||
18
src/app/detail/detail-routing.module.ts
Normal file
18
src/app/detail/detail-routing.module.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { DetailComponent } from './detail.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: 'detail',
|
||||
component: DetailComponent
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
declarations: [],
|
||||
imports: [CommonModule, RouterModule.forChild(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class DetailRoutingModule {}
|
||||
7
src/app/detail/detail.component.html
Normal file
7
src/app/detail/detail.component.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<div class="container">
|
||||
<h1 class="title">
|
||||
{{ 'PAGES.DETAIL.TITLE' | translate }}
|
||||
</h1>
|
||||
|
||||
<a routerLink="/">{{ 'PAGES.DETAIL.BACK_TO_HOME' | translate }}</a>
|
||||
</div>
|
||||
3
src/app/detail/detail.component.scss
Normal file
3
src/app/detail/detail.component.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
:host {
|
||||
|
||||
}
|
||||
35
src/app/detail/detail.component.spec.ts
Normal file
35
src/app/detail/detail.component.spec.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { DetailComponent } from './detail.component';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
describe('DetailComponent', () => {
|
||||
let component: DetailComponent;
|
||||
let fixture: ComponentFixture<DetailComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [DetailComponent],
|
||||
imports: [TranslateModule.forRoot(), RouterTestingModule]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DetailComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should render title in a h1 tag', async(() => {
|
||||
const compiled = fixture.debugElement.nativeElement;
|
||||
expect(compiled.querySelector('h1').textContent).toContain(
|
||||
'PAGES.DETAIL.TITLE'
|
||||
);
|
||||
}));
|
||||
});
|
||||
14
src/app/detail/detail.component.ts
Normal file
14
src/app/detail/detail.component.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-detail',
|
||||
templateUrl: './detail.component.html',
|
||||
styleUrls: ['./detail.component.scss']
|
||||
})
|
||||
export class DetailComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit(): void { }
|
||||
|
||||
}
|
||||
13
src/app/detail/detail.module.ts
Normal file
13
src/app/detail/detail.module.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { DetailRoutingModule } from './detail-routing.module';
|
||||
|
||||
import { DetailComponent } from './detail.component';
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [DetailComponent],
|
||||
imports: [CommonModule, SharedModule, DetailRoutingModule]
|
||||
})
|
||||
export class DetailModule {}
|
||||
@@ -2,4 +2,6 @@
|
||||
<h1 class="title">
|
||||
{{ 'PAGES.HOME.TITLE' | translate }}
|
||||
</h1>
|
||||
|
||||
<a routerLink="/detail">{{ 'PAGES.HOME.GO_TO_DETAIL' | translate }}</a>
|
||||
</div>
|
||||
|
||||
@@ -1,16 +1,3 @@
|
||||
.container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
:host {
|
||||
|
||||
background: url(../../assets/background.jpg) no-repeat center fixed;
|
||||
-webkit-background-size: cover; /* pour anciens Chrome et Safari */
|
||||
background-size: cover; /* version standardisée */
|
||||
|
||||
.title {
|
||||
color: white;
|
||||
margin: 0;
|
||||
padding: 50px 20px;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { HomeComponent } from './home.component';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
describe('HomeComponent', () => {
|
||||
let component: HomeComponent;
|
||||
@@ -10,7 +11,7 @@ describe('HomeComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [HomeComponent],
|
||||
imports: [TranslateModule.forRoot()]
|
||||
imports: [TranslateModule.forRoot(), RouterTestingModule]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
@@ -7,7 +8,7 @@ import { Component, OnInit } from '@angular/core';
|
||||
})
|
||||
export class HomeComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
constructor(private router: Router) { }
|
||||
|
||||
ngOnInit(): void { }
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
{
|
||||
"PAGES": {
|
||||
"HOME": {
|
||||
"TITLE": "App works !"
|
||||
"TITLE": "App works !",
|
||||
"GO_TO_DETAIL": "Go to Detail"
|
||||
},
|
||||
"DETAIL": {
|
||||
"TITLE": "Detail page !",
|
||||
"BACK_TO_HOME": "Back to Home"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>AngularElectron</title>
|
||||
<base href="">
|
||||
<title>Angular Electron</title>
|
||||
<base href="/">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="assets/icons/favicon.ico">
|
||||
|
||||
@@ -4,4 +4,46 @@ html, body {
|
||||
padding: 0;
|
||||
|
||||
height: 100%;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
/* CAN (MUST) BE REMOVED ! Sample Global style */
|
||||
.container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
background: url(./assets/background.jpg) no-repeat center fixed;
|
||||
-webkit-background-size: cover; /* pour anciens Chrome et Safari */
|
||||
background-size: cover; /* version standardisée */
|
||||
|
||||
.title {
|
||||
color: white;
|
||||
margin: 0;
|
||||
padding: 50px 20px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #fff !important;
|
||||
text-transform: uppercase;
|
||||
text-decoration: none;
|
||||
background: #ed3330;
|
||||
padding: 20px;
|
||||
border-radius: 5px;
|
||||
display: inline-block;
|
||||
border: none;
|
||||
transition: all 0.4s ease 0s;
|
||||
|
||||
&:hover {
|
||||
background: #fff;
|
||||
color: #ed3330 !important;
|
||||
letter-spacing: 1px;
|
||||
-webkit-box-shadow: 0px 5px 40px -10px rgba(0,0,0,0.57);
|
||||
-moz-box-shadow: 0px 5px 40px -10px rgba(0,0,0,0.57);
|
||||
box-shadow: 5px 40px -10px rgba(0,0,0,0.57);
|
||||
transition: all 0.4s ease 0s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user