Skip to content

Commit b1687fe

Browse files
modify some router setups in example projects (#418)
1 parent 6c218bf commit b1687fe

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

examples/lazy-loading/vite/src/router.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ export function setupRouter(i18n: I18n): Router {
3838
})
3939

4040
// navigation guards
41-
router.beforeEach(async (to, from, next) => {
42-
const paramsLocale = (to.params as any).locale as string
41+
router.beforeEach(async to => {
42+
const paramsLocale = to.params.locale as string
4343

4444
// use locale if paramsLocale is not in SUPPORT_LOCALES
4545
if (!SUPPORT_LOCALES.includes(paramsLocale)) {
46-
return next(`/${locale}`)
46+
return `/${locale}`
4747
}
4848

4949
// load locale messages
@@ -53,8 +53,6 @@ export function setupRouter(i18n: I18n): Router {
5353

5454
// set i18n language
5555
setI18nLanguage(i18n, paramsLocale)
56-
57-
return next()
5856
})
5957

6058
return router

examples/lazy-loading/webpack/src/router.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ export function setupRouter(i18n) {
3333
})
3434

3535
// navigation guards
36-
router.beforeEach(async (to, from, next) => {
36+
router.beforeEach(async to => {
3737
const paramsLocale = to.params.locale
3838

3939
// use locale if paramsLocale is not in SUPPORT_LOCALES
4040
if (!SUPPORT_LOCALES.includes(paramsLocale)) {
41-
return next(`/${locale}`)
41+
return `/${locale}`
4242
}
4343

4444
// load locale messages
@@ -48,8 +48,6 @@ export function setupRouter(i18n) {
4848

4949
// set i18n language
5050
setI18nLanguage(i18n, paramsLocale)
51-
52-
return next()
5351
})
5452

5553
return router

0 commit comments

Comments
 (0)