2025-10-11 18:25:59 +08:00

34 lines
997 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.Extensions.DependencyInjection;
using XiaoZhiSharp_MauiBlazorApp.Services;
namespace XiaoZhiSharp_MauiBlazorApp
{
public partial class App : Application
{
public App()
{
InitializeComponent();
}
protected override Window CreateWindow(IActivationState? activationState)
{
var window = new Window(new MainPage()) { Title = "XiaoZhiSharp_MauiBlazorApp" };
// 添加窗口关闭事件处理
window.Destroying += Window_Destroying;
return window;
}
private void Window_Destroying(object? sender, EventArgs e)
{
// 在窗口关闭时获取XiaoZhi_AgentService并释放
var agentService = IPlatformApplication.Current?.Services?.GetService<XiaoZhi_AgentService>();
if (agentService != null)
{
agentService.Dispose();
}
}
}
}