using Microsoft.Extensions.Logging; using Microsoft.Maui.Handlers; using SunlightAggregationTerminal.Models; using ZXing.Net.Maui.Controls; namespace SunlightAggregationTerminal { public static class MauiProgram { public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder .UseMauiApp() .UseBarcodeReader() .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); }) .ConfigureMauiHandlers(handlers => { // 这里的 "NoUnderline" 是自定义映射名称,可以随意命名 EntryHandler.Mapper.AppendToMapping("NoUnderline", (handler, view) => { #if ANDROID // 将背景 tint 设为透明 // 这会移除 Android 默认的下划线颜色 handler.PlatformView.BackgroundTintList = Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Transparent); // 如果想彻底移除背景绘制(不仅仅是颜色透明) // handler.PlatformView.Background = null; #endif }); }); // 将 HttpClient 注册为单例服务 builder.Services.AddSingleton(); builder.Services.AddSingleton(); #if DEBUG builder.Logging.AddDebug(); #endif return builder.Build(); } } }