提交 31a17b88 编写于 作者: fxy060608's avatar fxy060608

fix(app): popGesture with reLaunch

上级 3c0e95e9
...@@ -17168,8 +17168,8 @@ var serviceContext = (function (vue) { ...@@ -17168,8 +17168,8 @@ var serviceContext = (function (vue) {
// 需要序列化一遍 // 需要序列化一遍
const routeOptions = JSON.parse(JSON.stringify(getRouteOptions(path))); const routeOptions = JSON.parse(JSON.stringify(getRouteOptions(path)));
routeOptions.meta = initRouteMeta(routeOptions.meta); routeOptions.meta = initRouteMeta(routeOptions.meta);
if (openType === 'reLaunch' || if (!__uniConfig.realEntryPagePath &&
(!__uniConfig.realEntryPagePath && getCurrentPages().length === 0) // redirectTo (openType === 'reLaunch' || getCurrentPages().length === 0) // redirectTo
) { ) {
routeOptions.meta.isQuit = true; routeOptions.meta.isQuit = true;
} }
...@@ -17501,6 +17501,26 @@ var serviceContext = (function (vue) { ...@@ -17501,6 +17501,26 @@ var serviceContext = (function (vue) {
}); });
} }
/**
* 是否处于直达页面
* @param page
* @returns
*/
function isDirectPage(page) {
return (__uniConfig.realEntryPagePath &&
page.$page.route === __uniConfig.entryPagePath);
}
/**
* 重新启动到首页
*/
function reLaunchEntryPage() {
__uniConfig.entryPagePath = __uniConfig.realEntryPagePath;
delete __uniConfig.realEntryPagePath;
uni.reLaunch({
url: addLeadingSlash(__uniConfig.entryPagePath),
});
}
let lastStatusBarStyle; let lastStatusBarStyle;
let oldSetStatusBarStyle = plus.navigator.setStatusBarStyle; let oldSetStatusBarStyle = plus.navigator.setStatusBarStyle;
function restoreOldSetStatusBarStyle(setStatusBarStyle) { function restoreOldSetStatusBarStyle(setStatusBarStyle) {
...@@ -17621,11 +17641,17 @@ var serviceContext = (function (vue) { ...@@ -17621,11 +17641,17 @@ var serviceContext = (function (vue) {
setStatusBarStyle(popStartStatusBarStyle); setStatusBarStyle(popStartStatusBarStyle);
} }
else if (e.type === 'end' && e.result) { else if (e.type === 'end' && e.result) {
const page = getCurrentPage();
removeCurrentPage(); removeCurrentPage();
setStatusBarStyle(); setStatusBarStyle();
if (page && isDirectPage(page)) {
reLaunchEntryPage();
}
else {
// 触发前一个页面 onShow // 触发前一个页面 onShow
invokeHook(ON_SHOW); invokeHook(ON_SHOW);
} }
}
}); });
} }
...@@ -19520,16 +19546,8 @@ var serviceContext = (function (vue) { ...@@ -19520,16 +19546,8 @@ var serviceContext = (function (vue) {
if (page.$page.meta.isQuit) { if (page.$page.meta.isQuit) {
quit(); quit();
} }
else if ( else if (isDirectPage(page)) {
// 处于直达页面 reLaunchEntryPage();
page.$page.route === __uniConfig.entryPagePath &&
__uniConfig.realEntryPagePath) {
// condition
__uniConfig.entryPagePath = __uniConfig.realEntryPagePath;
delete __uniConfig.realEntryPagePath;
uni.reLaunch({
url: addLeadingSlash(__uniConfig.entryPagePath),
});
} }
else { else {
const { delta, animationType, animationDuration } = args; const { delta, animationType, animationDuration } = args;
......
import { addLeadingSlash } from '@dcloudio/uni-shared'
/**
* 是否处于直达页面
* @param page
* @returns
*/
export function isDirectPage(page: Page.PageInstance) {
return (
__uniConfig.realEntryPagePath &&
page.$page.route === __uniConfig.entryPagePath
)
}
/**
* 重新启动到首页
*/
export function reLaunchEntryPage() {
__uniConfig.entryPagePath = __uniConfig.realEntryPagePath
delete __uniConfig.realEntryPagePath
uni.reLaunch({
url: addLeadingSlash(__uniConfig.entryPagePath!),
})
}
import { ComponentPublicInstance } from 'vue'
import { import {
API_NAVIGATE_BACK, API_NAVIGATE_BACK,
API_TYPE_NAVIGATE_BACK, API_TYPE_NAVIGATE_BACK,
...@@ -11,12 +12,13 @@ import { ...@@ -11,12 +12,13 @@ import {
invokeHook, invokeHook,
} from '@dcloudio/uni-core' } from '@dcloudio/uni-core'
import { useI18n } from '@dcloudio/uni-core' import { useI18n } from '@dcloudio/uni-core'
import { addLeadingSlash, ON_BACK_PRESS, ON_SHOW } from '@dcloudio/uni-shared' import { ON_BACK_PRESS, ON_SHOW } from '@dcloudio/uni-shared'
import { ComponentPublicInstance } from 'vue'
import { ANI_CLOSE, ANI_DURATION } from '../../constants' import { ANI_CLOSE, ANI_DURATION } from '../../constants'
import { removePage } from '../../framework/page/getCurrentPages' import { removePage } from '../../framework/page/getCurrentPages'
import { setStatusBarStyle } from '../../statusBar' import { setStatusBarStyle } from '../../statusBar'
import { backWebview, closeWebview } from './webview' import { backWebview, closeWebview } from './webview'
import { isDirectPage, reLaunchEntryPage } from './direct'
export const navigateBack = defineAsyncApi<API_TYPE_NAVIGATE_BACK>( export const navigateBack = defineAsyncApi<API_TYPE_NAVIGATE_BACK>(
API_NAVIGATE_BACK, API_NAVIGATE_BACK,
...@@ -36,17 +38,8 @@ export const navigateBack = defineAsyncApi<API_TYPE_NAVIGATE_BACK>( ...@@ -36,17 +38,8 @@ export const navigateBack = defineAsyncApi<API_TYPE_NAVIGATE_BACK>(
uni.hideLoading() uni.hideLoading()
if (page.$page.meta.isQuit) { if (page.$page.meta.isQuit) {
quit() quit()
} else if ( } else if (isDirectPage(page)) {
// 处于直达页面 reLaunchEntryPage()
page.$page.route === __uniConfig.entryPagePath &&
__uniConfig.realEntryPagePath
) {
// condition
__uniConfig.entryPagePath = __uniConfig.realEntryPagePath
delete __uniConfig.realEntryPagePath
uni.reLaunch({
url: addLeadingSlash(__uniConfig.entryPagePath),
})
} else { } else {
const { delta, animationType, animationDuration } = args const { delta, animationType, animationDuration } = args
back(delta!, animationType, animationDuration) back(delta!, animationType, animationDuration)
......
...@@ -9,8 +9,8 @@ export function initRouteOptions(path: string, openType: UniApp.OpenType) { ...@@ -9,8 +9,8 @@ export function initRouteOptions(path: string, openType: UniApp.OpenType) {
routeOptions.meta = initRouteMeta(routeOptions.meta) routeOptions.meta = initRouteMeta(routeOptions.meta)
if ( if (
openType === 'reLaunch' || !__uniConfig.realEntryPagePath &&
(!__uniConfig.realEntryPagePath && getCurrentPages().length === 0) // redirectTo (openType === 'reLaunch' || getCurrentPages().length === 0) // redirectTo
) { ) {
routeOptions.meta.isQuit = true routeOptions.meta.isQuit = true
} else if (!routeOptions.meta.isTabBar) { } else if (!routeOptions.meta.isTabBar) {
......
import { invokeHook } from '@dcloudio/uni-core' import { getCurrentPage, invokeHook } from '@dcloudio/uni-core'
import { ON_SHOW } from '@dcloudio/uni-shared' import { ON_SHOW } from '@dcloudio/uni-shared'
import { isDirectPage, reLaunchEntryPage } from '../../../../api/route/direct'
import { import {
lastStatusBarStyle, lastStatusBarStyle,
setStatusBarStyle, setStatusBarStyle,
...@@ -22,10 +23,15 @@ export function onWebviewPopGesture(webview: PlusWebviewWebviewObject) { ...@@ -22,10 +23,15 @@ export function onWebviewPopGesture(webview: PlusWebviewWebviewObject) {
// 拖拽未完成,设置为当前状态栏前景色 // 拖拽未完成,设置为当前状态栏前景色
setStatusBarStyle(popStartStatusBarStyle) setStatusBarStyle(popStartStatusBarStyle)
} else if (e.type === 'end' && e.result) { } else if (e.type === 'end' && e.result) {
const page = getCurrentPage()
removeCurrentPage() removeCurrentPage()
setStatusBarStyle() setStatusBarStyle()
if (page && isDirectPage(page)) {
reLaunchEntryPage()
} else {
// 触发前一个页面 onShow // 触发前一个页面 onShow
invokeHook(ON_SHOW) invokeHook(ON_SHOW)
} }
}
}) })
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册