improve 404 logic (#1398)
This commit is contained in:
parent
77c4451d24
commit
06f6e1e7bd
@ -168,7 +168,8 @@ export const applyEvent = async (event, router, socket) => {
|
|||||||
|
|
||||||
// Send the event to the server.
|
// Send the event to the server.
|
||||||
event.token = getToken();
|
event.token = getToken();
|
||||||
event.router_data = (({ pathname, query }) => ({ pathname, query }))(router);
|
event.router_data = (({ pathname, query, asPath }) => ({ pathname, query, asPath }))(router);
|
||||||
|
|
||||||
if (socket) {
|
if (socket) {
|
||||||
socket.emit("event", JSON.stringify(event));
|
socket.emit("event", JSON.stringify(event));
|
||||||
return true;
|
return true;
|
||||||
|
@ -432,14 +432,7 @@ class App(Base):
|
|||||||
)
|
)
|
||||||
|
|
||||||
froute = format.format_route
|
froute = format.format_route
|
||||||
if (froute(constants.ROOT_404) not in self.pages) and (
|
self.pages[froute(constants.SLUG_404)] = component
|
||||||
not any(page.startswith("[[...") for page in self.pages)
|
|
||||||
):
|
|
||||||
self.pages[froute(constants.ROOT_404)] = component
|
|
||||||
if not any(
|
|
||||||
page.startswith("[...") or page.startswith("[[...") for page in self.pages
|
|
||||||
):
|
|
||||||
self.pages[froute(constants.SLUG_404)] = component
|
|
||||||
|
|
||||||
def setup_admin_dash(self):
|
def setup_admin_dash(self):
|
||||||
"""Setup the admin dash."""
|
"""Setup the admin dash."""
|
||||||
@ -663,9 +656,7 @@ def upload(app: App):
|
|||||||
update = await app.postprocess(state, event, update)
|
update = await app.postprocess(state, event, update)
|
||||||
# Send update to client
|
# Send update to client
|
||||||
await asyncio.create_task(
|
await asyncio.create_task(
|
||||||
app.event_namespace.emit( # type: ignore
|
app.event_namespace.emit(str(constants.SocketEvent.EVENT), update.json(), to=sid) # type: ignore
|
||||||
str(constants.SocketEvent.EVENT), update.json(), to=sid
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
# Set the state for the session.
|
# Set the state for the session.
|
||||||
app.state_manager.set_state(event.token, state)
|
app.state_manager.set_state(event.token, state)
|
||||||
|
@ -350,8 +350,7 @@ class RouteRegex(SimpleNamespace):
|
|||||||
|
|
||||||
|
|
||||||
# 404 variables
|
# 404 variables
|
||||||
ROOT_404 = ""
|
SLUG_404 = "404"
|
||||||
SLUG_404 = "[..._]"
|
|
||||||
TITLE_404 = "404 - Not Found"
|
TITLE_404 = "404 - Not Found"
|
||||||
FAVICON_404 = "favicon.ico"
|
FAVICON_404 = "favicon.ico"
|
||||||
DESCRIPTION_404 = "The page was not found"
|
DESCRIPTION_404 = "The page was not found"
|
||||||
|
Loading…
Reference in New Issue
Block a user