整合管理器应用端(MAUI跨平台)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.7 KiB

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<App>()
.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<HttpClient>();
builder.Services.AddSingleton<DataModel>();
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}
}