mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-17 02:31:34 +08:00
fix(vue): canGoBack now returns correct result with initial load redirect (#22071)
This commit is contained in:
@ -31,15 +31,6 @@ export const createIonRouter = (opts: IonicVueRouterOptions, router: Router) =>
|
|||||||
// TODO types
|
// TODO types
|
||||||
let historyChangeListeners: any[] = [];
|
let historyChangeListeners: any[] = [];
|
||||||
|
|
||||||
const currentRoute = router.currentRoute.value;
|
|
||||||
currentRouteInfo = {
|
|
||||||
id: generateId('routeInfo'),
|
|
||||||
pathname: currentRoute.path,
|
|
||||||
search: currentRoute.fullPath.split('?')[1] || '',
|
|
||||||
params: currentRoute.params
|
|
||||||
}
|
|
||||||
locationHistory.add(currentRouteInfo)
|
|
||||||
|
|
||||||
if (typeof (document as any) !== 'undefined') {
|
if (typeof (document as any) !== 'undefined') {
|
||||||
document.addEventListener('ionBackButton', (ev: Event) => {
|
document.addEventListener('ionBackButton', (ev: Event) => {
|
||||||
(ev as any).detail.register(0, (processNextHandler: () => void) => {
|
(ev as any).detail.register(0, (processNextHandler: () => void) => {
|
||||||
@ -105,6 +96,13 @@ export const createIonRouter = (opts: IonicVueRouterOptions, router: Router) =>
|
|||||||
leavingLocationInfo = locationHistory.current();
|
leavingLocationInfo = locationHistory.current();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!leavingLocationInfo) {
|
||||||
|
leavingLocationInfo = {
|
||||||
|
pathname: '',
|
||||||
|
search: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const leavingUrl = leavingLocationInfo.pathname + leavingLocationInfo.search;
|
const leavingUrl = leavingLocationInfo.pathname + leavingLocationInfo.search;
|
||||||
if (leavingUrl !== location.fullPath) {
|
if (leavingUrl !== location.fullPath) {
|
||||||
if (!incomingRouteParams) {
|
if (!incomingRouteParams) {
|
||||||
|
Reference in New Issue
Block a user