File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed
example/views/category1/2018
packages/vuepress-theme-reco Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ date: 2018-12-15
44tags :
55 - tag1
66categories :
7- - category1
7+ - 分类
88---
99
1010first page in category1
Original file line number Diff line number Diff line change 22import postMixin from '@theme/mixins/posts'
33import localMixin from '@theme/mixins/locales'
44import { addLinkToHead , addScriptToHead } from '@theme/helpers/utils'
5- import { registerCodeThemeCss , interceptRouterError } from '@theme/helpers/other'
5+ import { registerCodeThemeCss , interceptRouterError , fixRouterError404 } from '@theme/helpers/other'
66import { install } from 'vue-demi'
77
88export default ( {
@@ -21,4 +21,5 @@ export default ({
2121 }
2222
2323 interceptRouterError ( router )
24+ fixRouterError404 ( router )
2425}
Original file line number Diff line number Diff line change @@ -34,3 +34,18 @@ export function interceptRouterError (router) {
3434 return originalPush . call ( this , location ) . catch ( err => err )
3535 }
3636}
37+
38+ export function fixRouterError404 ( router ) {
39+ router . beforeEach ( ( to , from , next ) => {
40+ // 解决非ASCII文件名的路由, 防止 404
41+ const decodedPath = decodeURIComponent ( to . path )
42+ if ( decodedPath !== to . path ) {
43+ next ( Object . assign ( { } , to , {
44+ fullPath : decodeURIComponent ( to . fullPath ) ,
45+ path : decodedPath
46+ } ) )
47+ } else {
48+ next ( )
49+ }
50+ } )
51+ }
You can’t perform that action at this time.
0 commit comments