feat: 应用图标 + 浅色/深色主题 + 消息复制 + 详情可选中复制
实现 4 个用户需求:
1. 应用图标(Gotify Ducker 吉祥物)
- Assets/gotify-mascot.png:用户提供的 PNG(196x196)
- Assets/Build-Icon.ps1:用 System.Drawing 高质量缩放生成多分辨率 ICO(16/24/32/48/64/128/196),PNG 数据嵌入 ICO 容器(Win10+ 原生支持)
- Assets/gotify-mascot.ico:7 个分辨率的 PNG-in-ICO,41KB
- WindowsGotify.csproj 加 <ApplicationIcon> 让 EXE 资源带这个图标
- csproj 加 <None Update=Assets\gotify-mascot.ico><CopyToOutputDirectory> 发布时一并拷
- TrayIconService 加 LoadMascotIcon() 静态方法,优先从 EXE 同目录 Assets\ 下找,找不到回退到 SystemIcons.Application
- Windows 通知中心的 toast 会自动用 ApplicationIcon(无需单独设)
2. 浅色/深色主题
- AppConfig 新增 UiConfig { Theme: "Light"|"Dark"|"System" }
- Themes/Light.xaml + Themes/Dark.xaml:两个 ResourceDictionary,定义 WindowBackground/CardBackground/CardAltBackground/BorderColor/PrimaryText/SecondaryText/MutedText/AccentBrush/SuccessDot/ErrorDot/PendingDot/PriorityUrgent/High/Normal/Low 等
- Services/ThemeService.cs:静态类,Apply(name) 卸载旧主题字典 + 加载新主题字典到 Application.Resources.MergedDictionaries,Changed 事件,Toggle() 切换
- MainWindow.xaml 所有颜色全部改用 {DynamicResource Xxx},主题切换时立刻刷新
- PriorityToBrushConverter 改用 Application.Current.TryFindResource("PriorityXxx") 拿色,跟着主题走
- 主窗右上角加 ☼/☾ 切换按钮,点一下切主题并自动写回 config.json
3. 消息正文复制按钮
- 详情面板"消息正文"标签右侧加 [复制] 按钮
- CopyMessageButton_Click:用 System.Windows.Clipboard.SetText 把全文(应用名/标题/时间/优先级/正文/URL)写进剪贴板
- 按钮反馈:复制后短暂显示"已复制"1.5 秒再恢复
- BuildFullMessageText 静态方法统一格式化
4. 详情面板可选中复制
- DetailMessage 从 TextBlock 改成 TextBox(IsReadOnly=True, BorderThickness=0, Background=Transparent, IsReadOnlyCaretVisible=True)
- DetailTitle / DetailUrl 也改成 TextBox IsReadOnly,用户能 Ctrl+A 全选、鼠标拉黑
- DetailUrl 双击打开(之前是单击,TextBlock 没法选中;TextBox 单击会进入文字选择模式影响双击识别,所以改成双击)
WPF+WinForms 双开:Application/Brush/Color/Clipboard/Button 多个类型两个命名空间都有,ThemeService/ValueConverters/MainWindow.xaml.cs 都加 using alias 固定走 WPF 的;TrayIconService 加 using System.IO 补 Path/File。
实测:新进程跑起来后 ApplicationCache refreshed count=6(用户新建了一个 app),WebSocket connected,真实消息流处理正常(短信号码 19999999999/15889931832),通知弹出。
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
# 从 Assets/gotify-mascot.png 生成多分辨率 ICO
|
||||
# 输出:Assets/gotify-mascot.ico
|
||||
param(
|
||||
[string]$Png = "$PSScriptRoot\gotify-mascot.png",
|
||||
[string]$Ico = "$PSScriptRoot\gotify-mascot.ico"
|
||||
)
|
||||
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
|
||||
$src = [System.Drawing.Image]::FromFile((Resolve-Path $Png))
|
||||
$srcW = $src.Width
|
||||
$srcH = $src.Height
|
||||
|
||||
# 多分辨率列表(像素) — 包含原始尺寸
|
||||
$sizes = @(16, 24, 32, 48, 64, 128, 196) | Where-Object { $_ -le [math]::Max($srcW, $srcH) }
|
||||
if (($srcW, $srcH) -notin $sizes) { $sizes += ,($srcW, $srcH) | Out-Null }
|
||||
$sizes = $sizes | Sort-Object -Unique
|
||||
|
||||
# 1) 把每个分辨率的位图渲染成 PNG 字节
|
||||
$entries = @()
|
||||
foreach ($sz in $sizes) {
|
||||
$bmp = New-Object System.Drawing.Bitmap $sz, $sz, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
|
||||
$g = [System.Drawing.Graphics]::FromImage($bmp)
|
||||
$g.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
|
||||
$g.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::HighQuality
|
||||
$g.PixelOffsetMode = [System.Drawing.Drawing2D.PixelOffsetMode]::HighQuality
|
||||
$g.Clear([System.Drawing.Color]::Transparent)
|
||||
$g.DrawImage($src, 0, 0, $sz, $sz)
|
||||
$g.Dispose()
|
||||
|
||||
$ms = New-Object System.IO.MemoryStream
|
||||
$bmp.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)
|
||||
$pngBytes = $ms.ToArray()
|
||||
$ms.Dispose()
|
||||
$bmp.Dispose()
|
||||
|
||||
$entries += [pscustomobject]@{
|
||||
Width = $sz
|
||||
Height = $sz
|
||||
Bytes = $pngBytes
|
||||
}
|
||||
}
|
||||
$src.Dispose()
|
||||
|
||||
# 2) 组装 ICO 文件
|
||||
# ICONDIR (6 bytes)
|
||||
# ICONDIRENTRY * N (16 bytes each)
|
||||
# Image data
|
||||
|
||||
$out = New-Object System.IO.MemoryStream
|
||||
$bw = New-Object System.IO.BinaryWriter $out
|
||||
|
||||
# ICONDIR
|
||||
$bw.Write([uint16]0) # Reserved
|
||||
$bw.Write([uint16]1) # Type: 1 = ICO
|
||||
$bw.Write([uint16]$entries.Count) # Count
|
||||
|
||||
# ICONDIRENTRY (16 bytes each)
|
||||
$dataOffset = 6 + 16 * $entries.Count
|
||||
foreach ($e in $entries) {
|
||||
$w = if ($e.Width -ge 256) { 0 } else { $e.Width }
|
||||
$h = if ($e.Height -ge 256) { 0 } else { $e.Height }
|
||||
$bw.Write([byte]$w) # Width
|
||||
$bw.Write([byte]$h) # Height
|
||||
$bw.Write([byte]0) # Color count (0 = >256 colors)
|
||||
$bw.Write([byte]0) # Reserved
|
||||
$bw.Write([uint16]1) # Color planes
|
||||
$bw.Write([uint16]32) # Bits per pixel
|
||||
$bw.Write([uint32]$e.Bytes.Length)
|
||||
$bw.Write([uint32]$dataOffset)
|
||||
$dataOffset += $e.Bytes.Length
|
||||
}
|
||||
|
||||
# Image data
|
||||
foreach ($e in $entries) {
|
||||
$bw.Write($e.Bytes)
|
||||
}
|
||||
|
||||
$bw.Flush()
|
||||
[System.IO.File]::WriteAllBytes($Ico, $out.ToArray())
|
||||
$bw.Dispose()
|
||||
$out.Dispose()
|
||||
|
||||
Write-Host "ICO built: $Ico ($((Get-Item $Ico).Length) bytes, $($entries.Count) sizes: $($sizes -join ','))"
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Reference in New Issue
Block a user