fix: `router.path` not consistent across envs (#446) (#684)

fix #446
pull/688/head
Divyansh Singh 3 years ago committed by GitHub
parent f64f83df02
commit 0d9dfe0d94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,7 +1,7 @@
import { reactive, inject, markRaw, nextTick, readonly } from 'vue' import { reactive, inject, markRaw, nextTick, readonly } from 'vue'
import type { Component, InjectionKey } from 'vue' import type { Component, InjectionKey } from 'vue'
import { PageData } from '../shared' import { PageData } from '../shared'
import { inBrowser } from './utils' import { inBrowser, withBase } from './utils'
import { siteDataRef } from './data' import { siteDataRef } from './data'
export interface Route { export interface Route {
@ -82,7 +82,7 @@ export function createRouter(
throw new Error(`Invalid route component: ${comp}`) throw new Error(`Invalid route component: ${comp}`)
} }
route.path = pendingPath route.path = inBrowser ? pendingPath : withBase(pendingPath)
route.component = markRaw(comp) route.component = markRaw(comp)
route.data = import.meta.env.PROD route.data = import.meta.env.PROD
? markRaw(JSON.parse(__pageData)) ? markRaw(JSON.parse(__pageData))
@ -127,7 +127,7 @@ export function createRouter(
if (latestPendingPath === pendingPath) { if (latestPendingPath === pendingPath) {
latestPendingPath = null latestPendingPath = null
route.path = pendingPath route.path = inBrowser ? pendingPath : withBase(pendingPath)
route.component = fallbackComponent ? markRaw(fallbackComponent) : null route.component = fallbackComponent ? markRaw(fallbackComponent) : null
route.data = notFoundPageData route.data = notFoundPageData
} }

Loading…
Cancel
Save