推送
This commit is contained in:
@@ -74,6 +74,10 @@ namespace FATrace.WPLApp
|
||||
// 应用主题样式
|
||||
Syncfusion.SfSkinManager.SfSkinManager.ApplyStylesOnApplication = true;
|
||||
|
||||
//从容器中获取MainView的实例对象
|
||||
var container = ContainerLocator.Container;
|
||||
var shell = container.Resolve<object>("MainView");
|
||||
|
||||
// 先显示 Shell,避免耗时初始化阻塞界面呈现
|
||||
base.OnInitialized();
|
||||
|
||||
@@ -81,7 +85,7 @@ namespace FATrace.WPLApp
|
||||
LogService = Container.Resolve<ILogService>();
|
||||
LogService.Info("OnInitialized-UI Ready");
|
||||
|
||||
if (Current.MainWindow is Window view)
|
||||
if (shell is Window view)
|
||||
{
|
||||
var regionManager = Container.Resolve<IRegionManager>();
|
||||
RegionManager.SetRegionManager(view, regionManager);
|
||||
@@ -98,9 +102,9 @@ namespace FATrace.WPLApp
|
||||
LogService?.Error("Current.MainWindow 为 null,执行回退创建 MainView");
|
||||
try
|
||||
{
|
||||
var fallback = new MainView();
|
||||
Current.MainWindow = fallback;
|
||||
fallback.Show();
|
||||
//var fallback = new MainView();
|
||||
//Current.MainWindow = fallback;
|
||||
//fallback.Show();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -161,26 +165,8 @@ namespace FATrace.WPLApp
|
||||
regionAdapterMappings.RegisterMapping(typeof(SfNavigationDrawer), Container.Resolve<SfNavigationDrawerRegionAdapter>());
|
||||
}
|
||||
|
||||
protected override Window CreateShell()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Container.Resolve<MainView>();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 记录并回退到直接创建,避免因容器解析失败导致无界面
|
||||
Debug.WriteLine($"CreateShell 容器解析 MainView 失败: {ex}");
|
||||
try
|
||||
{
|
||||
return new MainView();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw; // 让全局异常处理捕获
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override Window CreateShell() => null;
|
||||
|
||||
|
||||
protected override void RegisterTypes(IContainerRegistry containerRegistry)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user