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

feat(h5): onPageNotFound #2876

上级 9bc6bdaf
......@@ -6589,10 +6589,12 @@ function usePageRoute() {
query = uniShared.parseQuery(url.slice(searchPos + 1, hashPos > -1 ? hashPos : url.length));
}
const { meta } = __uniRoutes[0];
const path = "/" + meta.route;
return {
meta,
query,
path: "/" + meta.route
path,
matched: [{ path }]
};
}
function initPageMeta(id) {
......
......@@ -13288,10 +13288,12 @@ function usePageRoute() {
query = parseQuery(url.slice(searchPos + 1, hashPos > -1 ? hashPos : url.length));
}
const { meta } = __uniRoutes[0];
const path = "/" + meta.route;
return {
meta,
query,
path: "/" + meta.route
path,
matched: [{ path }]
};
}
function initPageMeta(id2) {
......@@ -13732,7 +13734,7 @@ function setupApp(comp) {
setup(instance2) {
const route = usePageRoute();
const onLaunch = () => {
const { onLaunch: onLaunch2, onShow } = instance2;
const { onLaunch: onLaunch2, onShow, onPageNotFound } = instance2;
const path = route.path.substr(1);
const launchOptions = {
path: path || __uniRoutes[0].meta.route,
......@@ -13742,6 +13744,18 @@ function setupApp(comp) {
};
onLaunch2 && invokeArrayFns$1(onLaunch2, launchOptions);
onShow && invokeArrayFns$1(onShow, launchOptions);
if (__UNI_FEATURE_PAGES__) {
if (!route.matched.length) {
const pageNotFoundOptions = {
notFound: true,
openType: "appLaunch",
path: route.path,
query: {},
scene: 1001
};
onPageNotFound && invokeArrayFns$1(onPageNotFound, pageNotFoundOptions);
}
}
};
injectAppLaunchHooks(instance2);
if (__UNI_FEATURE_PAGES__) {
......
......@@ -134,7 +134,7 @@ export function setupApp(comp: any) {
return route.query
}
const onLaunch = () => {
const { onLaunch, onShow } = instance
const { onLaunch, onShow, onPageNotFound } = instance
const path = route.path.substr(1)
const launchOptions = {
path: path || __uniRoutes[0].meta.route,
......@@ -144,6 +144,19 @@ export function setupApp(comp: any) {
}
onLaunch && invokeArrayFns(onLaunch, launchOptions)
onShow && invokeArrayFns(onShow, launchOptions)
if (__UNI_FEATURE_PAGES__) {
if (!route.matched.length) {
const pageNotFoundOptions = {
notFound: true,
openType: 'appLaunch',
path: route.path,
query: {},
scene: 1001,
}
onPageNotFound &&
invokeArrayFns(onPageNotFound, pageNotFoundOptions)
}
}
}
injectAppLaunchHooks(instance)
if (__UNI_FEATURE_PAGES__) {
......
......@@ -37,10 +37,12 @@ export function usePageRoute() {
)
}
const { meta } = __uniRoutes[0]
const path = '/' + meta.route
return {
meta,
query: query,
path: '/' + meta.route,
path,
matched: [{ path }],
}
}
function initPageMeta(id: number) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册