Skip to content

Commit

Permalink
fix: redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
cgilbe27 committed May 21, 2024
1 parent 75cd3e5 commit cf79114
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
31 changes: 18 additions & 13 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useBlockchain } from "@/stores";
import { createRouter, createWebHistory } from "vue-router";
import { useBlockchain } from '@/stores';
import { createRouter, createWebHistory } from 'vue-router';
// @ts-ignore
import { setupLayouts } from "virtual:generated-layouts";
import { setupLayouts } from 'virtual:generated-layouts';
// @ts-ignore
import routes from "~pages";
import routes from '~pages';

const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
Expand All @@ -12,15 +12,20 @@ const router = createRouter({

//update current blockchain
router.beforeEach((to) => {
const { chain } = to.params
if(chain){
const blockchain = useBlockchain()
if(chain !== blockchain.chainName) {
blockchain.setCurrent(chain.toString())
}
}
})
console.log(to);
if (to.path === '/') {
window.location.replace('/nibiru');
}

const { chain } = to.params;
if (chain) {
const blockchain = useBlockchain();
if (chain !== blockchain.chainName) {
blockchain.setCurrent(chain.toString());
}
}
});

// Docs: https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards

export default router;
export default router;
1 change: 0 additions & 1 deletion src/stores/useBlockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export const useBlockchain = defineStore('blockchain', {
const router = useRouter();
const routes = router?.getRoutes() || [];
if (this.current && routes) {
console.log(this.current);
if (this.current?.themeColor) {
const { color } = hexToRgb(this.current?.themeColor);
const { h, s, l } = rgbToHsl(color);
Expand Down

0 comments on commit cf79114

Please sign in to comment.