From fa6173ec573587afccc7435a6a0789e1db6b06f6 Mon Sep 17 00:00:00 2001 From: AricRedemption Date: Fri, 26 Apr 2024 12:00:25 +0800 Subject: [PATCH] chore: update router rules --- src/router.ts | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/router.ts b/src/router.ts index b5fe4c5f..63060bb6 100644 --- a/src/router.ts +++ b/src/router.ts @@ -7,7 +7,7 @@ import { needMigrate } from './lib/migrate' import { hasPassword } from './lib/password' import Wallet from './pages/wallet/Index.vue' import { getCurrentAccountId } from './lib/account' -import { getCurrentWalletId, hasWallets } from './lib/wallet' +import { getCurrentWalletId, hasV3Wallets, hasWallets } from './lib/wallet' const routes = [ { @@ -496,29 +496,33 @@ const authPages = [ router.beforeEach(async (to, _, next) => { if (to.fullPath !== '/migrateV2' && (await needMigrate())) { next('/migrateV2') - } else if (!authPages.includes(to.path) && (!await hasPassword())) { - next('/wallet/set-password') - } else if (to.fullPath !== '/lock' && (await isLocked())) { - next('/lock') - } else if (!authPages.includes(to.path) && (!(await getCurrentAccountId()) || !(await getCurrentWalletId()))) { - if (await hasWallets()) { - next('/manage/wallets') + } else if (!authPages.includes(to.path)) { + if (!(await getCurrentAccountId()) || !(await getCurrentWalletId())) { + if (await hasWallets()) { + next('/manage/wallets') + } else { + goToTab('/welcome', true) + next('/welcome') + } + } else if (!(await hasPassword())) { + next('/wallet/set-password') + } else if (await isLocked()) { + next('/lock') } else { - goToTab('/welcome', true) - next('/welcome') - } - } else { - if (['asset', 'token'].includes(to.name as string)) { - to.meta.headerTitle = to.params.symbol - } + if (['asset', 'token'].includes(to.name as string)) { + to.meta.headerTitle = to.params.symbol + } - if (to.name === 'send-token') { - to.meta.headerTitle = `Send ${to.params.symbol}` - } + if (to.name === 'send-token') { + to.meta.headerTitle = `Send ${to.params.symbol}` + } - if (to.path === '/wallet') { - assetList.value = [] + if (to.path === '/wallet') { + assetList.value = [] + } + next() } + } else { next() } })