Skip to content
This repository has been archived by the owner on Jul 29, 2021. It is now read-only.

Commit

Permalink
fix: πŸ› remove # from url and add language into url
Browse files Browse the repository at this point in the history
remove # from url  and add language into url

βœ… Closes: #86
  • Loading branch information
huweihong committed Nov 9, 2020
1 parent 88c268e commit 0175608
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ import { PreloadAllModules, RouterModule, Routes } from '@angular/router';

const routes: Routes = [
{
path: 'swap',
path: ':lang/swap',
loadChildren: () =>
import('./swap/swap.module').then((m) => m.SwapPageModule),
},
{
path: 'liquid',
path: ':lang/liquid',
loadChildren: () =>
import('./liquid/liquid.module').then((m) => m.LiquidPageModule),
},
{
path: 'income',
path: ':lang/income',
loadChildren: () =>
import('./income/income.module').then((m) => m.IncomePageModule),
},
{
path: 'cofi',
path: ':lang/cofi',
loadChildren: () =>
import('./cofi/cofi.module').then((m) => m.CofiPageModule),
},
{
path: '',
redirectTo: '/swap',
redirectTo: ':lang/swap',
pathMatch: 'full',
},
];
Expand All @@ -33,7 +33,7 @@ const routes: Routes = [
imports: [
RouterModule.forRoot(routes, {
preloadingStrategy: PreloadAllModules,
useHash: true,
//useHash: true,
}),
],
exports: [RouterModule],
Expand Down
5 changes: 4 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export class AppComponent implements OnInit {
}

ngOnInit() {
this.router.navigateByUrl(this.shareStateQuery.getValue().activeTab);
this.router.navigateByUrl(
`${this.shareStateQuery.getValue().lang}/` +
this.shareStateQuery.getValue().activeTab
);
}
}
6 changes: 5 additions & 1 deletion src/app/common/components/header/header.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { EventBusService } from 'src/app/service/eventbus.service';
import { Router } from '@angular/router';
import { fromEvent, Subscription } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { ShareStateQuery } from '../../state/share.query';
@Component({
selector: 'app-header',
templateUrl: './header.page.html',
Expand Down Expand Up @@ -42,6 +43,7 @@ export class HeaderPage implements OnInit, OnDestroy {
constructor(
private shareStateService: ShareStateService,
private eventbusService: EventBusService,
private shareStateQuery: ShareStateQuery,
private router: Router
) {
this.eventbusService.on('accountsChanged', (account) => {
Expand Down Expand Up @@ -91,7 +93,9 @@ export class HeaderPage implements OnInit, OnDestroy {

selectTab(tabId) {
this.shareStateService.updateActiveTab(tabId);
this.router.navigateByUrl(tabId);
this.router.navigateByUrl(
`${this.shareStateQuery.getValue().lang}/${tabId}`
);
}
onConnected() {
this.onRefresh.emit();
Expand Down
7 changes: 6 additions & 1 deletion src/app/common/components/switch-lang/menu/menu.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { PopoverController } from '@ionic/angular';
import { ShareStateQuery } from 'src/app/common/state/share.query';
import { ShareStateService } from 'src/app/common/state/share.service';
import { FOOTER_ITEMS, LANG_ITEMS } from 'src/app/common/constants';
import { Router } from '@angular/router';
@Component({
selector: 'app-menu',
templateUrl: './menu.page.html',
Expand All @@ -17,7 +18,8 @@ export class MenuPage implements OnInit {
private translate: TranslateService,
public shareStateQuery: ShareStateQuery,
private shareStateService: ShareStateService,
private popoverController: PopoverController
private popoverController: PopoverController,
private router: Router
) {}

ngOnInit() {
Expand All @@ -28,9 +30,12 @@ export class MenuPage implements OnInit {
changeLang(lang) {
this.translate.use(lang);
this.shareStateService.updateLang(lang);

if (this.style === 'pop') {
this.popoverController?.dismiss();
}
const tabId = this.router.url.split('/')[2];
this.router.navigateByUrl(`${lang}/${tabId}`);
}
goto(link) {
window.open(link);
Expand Down
2 changes: 1 addition & 1 deletion src/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ ion-button {
right: 120px;
}
.popover-warning .modal-wrapper {
width: 90%;
width: 94%;
min-height: 486px;
}
.close-icon {
Expand Down
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" />
<title>CoFiX: The most efficient On-Chain Market Making</title>

<base href="" />
<base href="/" />

<meta name="color-scheme" content="light dark" />
<meta
Expand Down

0 comments on commit 0175608

Please sign in to comment.