mirror of
https://github.com/flarum/framework.git
synced 2025-02-27 14:13:10 +08:00
Use resolver instead of catch-all route for errors
This commit is contained in:
parent
b5d2cbda9c
commit
058f0c50d2
@ -1,4 +1,4 @@
|
||||
import Page from '../../common/components/Page';
|
||||
import Page from './Page';
|
||||
|
||||
export default class ErrorPage extends Page {
|
||||
view() {
|
@ -1,4 +1,5 @@
|
||||
import Mithril from 'mithril';
|
||||
import ErrorPage from '../components/ErrorPage';
|
||||
|
||||
/**
|
||||
* Generates a route resolver for a given component.
|
||||
@ -32,6 +33,13 @@ export default class DefaultResolver {
|
||||
}
|
||||
|
||||
onmatch(args, requestedPath, route) {
|
||||
const errorCode = app.data.errorCode;
|
||||
const currRoute = m.route.get();
|
||||
if (errorCode) {
|
||||
delete app.data.errorCode;
|
||||
return { view: () => ErrorPage.component({ errorCode, currRoute }) };
|
||||
}
|
||||
|
||||
return this.component;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import PostsUserPage from './components/PostsUserPage';
|
||||
import DiscussionsUserPage from './components/DiscussionsUserPage';
|
||||
import SettingsPage from './components/SettingsPage';
|
||||
import NotificationsPage from './components/NotificationsPage';
|
||||
import ErrorPage from './components/ErrorPage';
|
||||
import DiscussionPageResolver from './resolvers/DiscussionPageResolver';
|
||||
|
||||
/**
|
||||
@ -25,8 +24,6 @@ export default function (app) {
|
||||
|
||||
settings: { path: '/settings', component: SettingsPage },
|
||||
notifications: { path: '/notifications', component: NotificationsPage },
|
||||
|
||||
error: { path: '/:error', component: ErrorPage },
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user