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

fix(app): popGesture with reLaunch

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