vuepress-theme-reco-1.x
vuepress-theme-reco-1.x copied to clipboard
enhanceApp.js 解决中文路径问题出现 开发环境导航栏点击后直接跳转到生产环境页面
在你的仓库中的话可以 迭代一下
.vuepress/enhanceApp.js
export default (ctx) => { const routes = ctx.router.getRoutes() ctx.router.beforeEach((to, from, next) => { // 解决decode后反复重定向的问题 const route = routes.find((v) => v.regex.test(to.path)) // .html有重定向路由,无需特殊处理 if (/\.html$/.test(to.path)) { return next() } // 不特殊处理 非通配符的 没有重定向的路由 if (route && route.path !== '*' && !route.redirect) { return next() } // 解决中文标签/分类路由无法被正确加载的问题 if (decodeURIComponent(to.path) !== to.path) { return next( Object.assign({}, to, { path: decodeURIComponent(to.path), fullPath: decodeURIComponent(to.fullPath) }) ) } next() }) // 临时解决,防止内部调用钩子再处理 ctx.router.beforeEach = () => { return } }
经过测试已经成功解决了这个问题
Originally posted by @duktig666 in https://github.com/vuepress-reco/vuepress-theme-reco-1.x/issues/395#issuecomment-1032088529
@ATQQ
不太清楚标题描述的问题,给个demo演示一下?
问题
开发环境点击中文路由:
点击中文路由跳转生产环境:
控制台警告:
导航栏配置:
信息
版本:1.6.10 开发环境:win10 生产环境:github pages 仓库地址:https://github.com/duktig666/duktig666.github.io
不太清楚标题描述的问题,给个demo演示一下? @ATQQ
跳转到生产环境的链接 好像有重定向错误,具体如下: https://www.duktig.cn/?error=redirect_uri_mismatch&error_description=The%20redirect_uri%20MUST%20match%20the%20registered%20callback%20URL%20for%20this%20application.&error_uri=https%3A%2F%2Fdocs.github.com%2Fapps%2Fmanaging-oauth-apps%2Ftroubleshooting-authorization-request-errors%2F%23redirect-uri-mismatch&state=Vssue
跳转到生产环境的链接 好像有重定向错误,具体如下: https://www.duktig.cn/?error=redirect_uri_mismatch&error_description=The%20redirect_uri%20MUST%20match%20the%20registered%20callback%20URL%20for%20this%20application.&error_uri=https%3A%2F%2Fdocs.github.com%2Fapps%2Fmanaging-oauth-apps%2Ftroubleshooting-authorization-request-errors%2F%23redirect-uri-mismatch&state=Vssue
没有复现你所描述的问题呢