diff --git a/wwwroot/shell_theme.js b/wwwroot/shell_theme.js index 229c5ac..31ca1a7 100644 --- a/wwwroot/shell_theme.js +++ b/wwwroot/shell_theme.js @@ -132,6 +132,35 @@ }); } + // Called by user_logined event — skip dashboard if Router has a saved route + window.sageOnLogin = async function(dashboardUrl) { + var target = bricks.getWidgetById('sage_main_content', bricks.app); + if (!target) return; + + var hasRoute = false; + if (bricks.Router && bricks.Router._enabled) { + hasRoute = bricks.Router.current('sage_main_content') + || new URLSearchParams(window.location.search).has('page'); + } + + if (hasRoute) { + console.log('[Shell] Router has route, skip dashboard load'); + return; + } + + // No route — load dashboard via Router + if (dashboardUrl && bricks.Router && bricks.Router._enabled) { + bricks.Router.navigate('sage_main_content', dashboardUrl); + } else if (dashboardUrl) { + var desc = { widgettype: 'urlwidget', options: { url: dashboardUrl } }; + var w = await bricks.widgetBuild(desc, bricks.app); + if (w) { + target.clear_widgets(); + target.add_widget(w); + } + } + }; + // Reload global menu after login/logout window.sageReloadMenu = async function() { if (typeof bricks === 'undefined') return;