From 65b66e2fb6ba1f02f3bd6eb427c6368372d00d26 Mon Sep 17 00:00:00 2001 From: YUCLing Date: Sat, 7 Dec 2024 14:22:45 +0800 Subject: [PATCH] fix: admin app --- .../core/js/src/admin/AdminApplication.tsx | 17 +++++++---------- framework/core/js/src/common/Application.tsx | 4 ++-- .../core/js/src/common/utils/patchMithril.js | 4 ++-- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/framework/core/js/src/admin/AdminApplication.tsx b/framework/core/js/src/admin/AdminApplication.tsx index fd00ac8066..4cddd13ca2 100644 --- a/framework/core/js/src/admin/AdminApplication.tsx +++ b/framework/core/js/src/admin/AdminApplication.tsx @@ -145,16 +145,13 @@ export default class AdminApplication extends Application { // we need to go to https://example.com/admin#/ explicitly. if (!document.location.hash) document.location.hash = '#/'; - m.route.prefix = '#'; - super.mount(); - - m.mount(document.getElementById('app-navigation')!, { - view: () => , - }); - m.mount(document.getElementById('header-navigation')!, Navigation); - m.mount(document.getElementById('header-primary')!, HeaderPrimary); - m.mount(document.getElementById('header-secondary')!, HeaderSecondary); - m.mount(document.getElementById('admin-navigation')!, AdminNav); + super.mount('#'); + + m.mount(document.getElementById('app-navigation')!, () => ); + m.mount(document.getElementById('header-navigation')!, () => ); + m.mount(document.getElementById('header-primary')!, () => ); + m.mount(document.getElementById('header-secondary')!, () => ); + m.mount(document.getElementById('admin-navigation')!, () => ); } getRequiredPermissions(permission: string) { diff --git a/framework/core/js/src/common/Application.tsx b/framework/core/js/src/common/Application.tsx index 13916cd59e..cb706ca63c 100644 --- a/framework/core/js/src/common/Application.tsx +++ b/framework/core/js/src/common/Application.tsx @@ -345,7 +345,7 @@ export default class Application { }); } - protected mount(basePath: string = '') { + protected mount(routePrefix = '/', basePath: string = '') { // An object with a callable view property is used in order to pass arguments to the component; see https://mithril.js.org/mount.html this.redraw.modal = m.mount(document.getElementById('modal')!, () => ); this.redraw.alert = m.mount(document.getElementById('alerts')!, () => ); @@ -357,7 +357,7 @@ export default class Application { let lastRoute: string; let comp: Component | null = null; function RoutedApp() { - return () => m.route('/', ({route}) => { + return () => m.route(routePrefix, ({route}) => { for (const k in routes) { let match; if (match = route.match(k)) { diff --git a/framework/core/js/src/common/utils/patchMithril.js b/framework/core/js/src/common/utils/patchMithril.js index 689a2b09da..eaca9ee5c5 100644 --- a/framework/core/js/src/common/utils/patchMithril.js +++ b/framework/core/js/src/common/utils/patchMithril.js @@ -167,12 +167,12 @@ export default function patchMithril(global) { } modifiedMithril.route.param = function (k) { - console.warn('m.route.param is not available in v3'); + console.warn('m.route.param is not available in v3, falling back to managed routing'); return app.routing.params[k]; } modifiedMithril.route.get = function () { - console.warn('m.route.get is not available in v3'); + console.warn('m.route.get is not available in v3, falling back to managed routing'); return app.routing.current; }