fix(router): fixing sub path refresh issue on gh-pages
Reference: Step 5. https://medium.com/swlh/how-to-host-your-angular-reactjs-vuejs-spa-on-github-pages-2d9ab102ac7b
This commit is contained in:
parent
5da96ad206
commit
626012cb15
3 changed files with 12 additions and 1 deletions
|
|
@ -19,7 +19,8 @@
|
|||
"polyfills": "src/polyfills.ts",
|
||||
"assets": [
|
||||
"src/assets",
|
||||
"src/pow.wasm"
|
||||
"src/pow.wasm",
|
||||
"src/404.html"
|
||||
],
|
||||
"styles": [
|
||||
"src/styles.less"
|
||||
|
|
|
|||
5
src/404.html
Normal file
5
src/404.html
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<script>
|
||||
const path = window.location.pathname.slice(1);
|
||||
localStorage.setItem('path', path);
|
||||
window.location.href='../';
|
||||
</script>
|
||||
|
|
@ -58,6 +58,11 @@ export class AppComponent implements OnInit {
|
|||
private ledger: LedgerService,
|
||||
public price: PriceService) {
|
||||
router.events.subscribe(() => { this.navExpanded = false })
|
||||
let path = localStorage.getItem('path');
|
||||
if(path) {
|
||||
localStorage.removeItem('path');
|
||||
this.router.navigate([path]);
|
||||
}
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue