feat(app): 初始化本地通知桌面应用
搭建 .NET 8 WPF 应用骨架,加入系统托盘、单实例启动与主控制面板。 实现本地 HTTP /notify 消息接入、频道严格匹配、免打扰、熔断限流与历史持久化。 补充弹窗样式配置、队列/推挤/替换展示、溢出处理、应用图标和项目文档。 Initial-Commit: true
This commit is contained in:
119
Models.cs
Normal file
119
Models.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace OmniNotify;
|
||||
|
||||
public enum NotificationStatus
|
||||
{
|
||||
Displayed,
|
||||
DndMuted,
|
||||
IllegalChannel,
|
||||
System
|
||||
}
|
||||
|
||||
public enum ScreenAnchor
|
||||
{
|
||||
TopLeft,
|
||||
TopCenter,
|
||||
TopRight,
|
||||
MiddleLeft,
|
||||
Center,
|
||||
MiddleRight,
|
||||
BottomLeft,
|
||||
BottomCenter,
|
||||
BottomRight
|
||||
}
|
||||
|
||||
public enum StackMode
|
||||
{
|
||||
Queue,
|
||||
Push,
|
||||
Replace
|
||||
}
|
||||
|
||||
public enum OverflowMode
|
||||
{
|
||||
Truncate,
|
||||
VerticalScroll,
|
||||
Split
|
||||
}
|
||||
|
||||
public enum PopupAnimation
|
||||
{
|
||||
Fade,
|
||||
Slide,
|
||||
Zoom
|
||||
}
|
||||
|
||||
public sealed class AppState
|
||||
{
|
||||
public GlobalSettings Settings { get; set; } = new();
|
||||
public ObservableCollection<Channel> Channels { get; set; } = [];
|
||||
public ObservableCollection<HistoryItem> History { get; set; } = [];
|
||||
}
|
||||
|
||||
public sealed class GlobalSettings
|
||||
{
|
||||
public bool StartWithWindows { get; set; }
|
||||
public bool DndEnabled { get; set; }
|
||||
public bool CircuitBreakerOpen { get; set; }
|
||||
public int MaxMessagesPerSecond { get; set; } = 8;
|
||||
public int RetainDays { get; set; } = 30;
|
||||
public int RetainCount { get; set; } = 1000;
|
||||
public int LocalPort { get; set; } = 19845;
|
||||
}
|
||||
|
||||
public sealed class Channel
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
public string Name { get; set; } = "default";
|
||||
public NotificationProfile Profile { get; set; } = NotificationProfile.CreateDefault();
|
||||
}
|
||||
|
||||
public sealed class NotificationProfile
|
||||
{
|
||||
public int ScreenIndex { get; set; }
|
||||
public ScreenAnchor Anchor { get; set; } = ScreenAnchor.TopRight;
|
||||
public double MarginX { get; set; } = 24;
|
||||
public double MarginY { get; set; } = 24;
|
||||
public double Width { get; set; } = 360;
|
||||
public double MaxHeight { get; set; } = 220;
|
||||
public double Padding { get; set; } = 18;
|
||||
public string FontFamily { get; set; } = "Microsoft YaHei UI";
|
||||
public double TitleFontSize { get; set; } = 16;
|
||||
public double BodyFontSize { get; set; } = 13;
|
||||
public string TextColor { get; set; } = "#F8FAFC";
|
||||
public string BackgroundColor { get; set; } = "#242934";
|
||||
public double BackgroundOpacity { get; set; } = 0.94;
|
||||
public string BorderColor { get; set; } = "#5B6B84";
|
||||
public double BorderOpacity { get; set; } = 0.65;
|
||||
public double OverallOpacity { get; set; } = 1;
|
||||
public double LifetimeSeconds { get; set; } = 4.5;
|
||||
public PopupAnimation EnterAnimation { get; set; } = PopupAnimation.Slide;
|
||||
public PopupAnimation ExitAnimation { get; set; } = PopupAnimation.Fade;
|
||||
public StackMode StackMode { get; set; } = StackMode.Queue;
|
||||
public OverflowMode OverflowMode { get; set; } = OverflowMode.Truncate;
|
||||
public double SplitIntervalSeconds { get; set; } = 0.6;
|
||||
[JsonPropertyName("MarqueeHoldSeconds")]
|
||||
public double VerticalScrollHoldSeconds { get; set; } = 1;
|
||||
public double VerticalScrollSpeed { get; set; } = 30;
|
||||
|
||||
public static NotificationProfile CreateDefault() => new();
|
||||
}
|
||||
|
||||
public sealed class HistoryItem
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
public DateTime ReceivedAt { get; set; } = DateTime.Now;
|
||||
public string Channel { get; set; } = "";
|
||||
public string Title { get; set; } = "";
|
||||
public string Body { get; set; } = "";
|
||||
public NotificationStatus Status { get; set; }
|
||||
}
|
||||
|
||||
public sealed class IncomingMessage
|
||||
{
|
||||
public string Channel { get; set; } = "";
|
||||
public string Title { get; set; } = "";
|
||||
public string Body { get; set; } = "";
|
||||
}
|
||||
Reference in New Issue
Block a user