Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ on:
push:
workflow_dispatch:
pull_request:
types: [closed]


jobs:
build_app:
runs-on: windows-latest
name: Build
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install .NET Core
uses: actions/setup-dotnet@v4
with:
Expand All @@ -26,23 +25,26 @@ jobs:
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-

- name: Build
run: pwsh -ep bypass ./tools/publish.ps1

- name: Test
run: dotnet test Tests/Decibel_Monitor.Tests/Decibel_Monitor.Tests.csproj -c Release

- name: Md5Checksum
run: pwsh -ep bypass ./tools/generate-md5.ps1 cipx/

- name: Upload APP to release
uses: ncipollo/release-action@v1
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
artifacts: "./cipx/*.cipx"
draft: true
generateReleaseNotes: true
body: ./cipx/checksums.md
bodyFile: ./cipx/checksums.md
token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/IntegrationTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Integration Test

# 集成冒烟测试:用官方 Release 版 ClassIsland 启动并加载本插件,
# 验证插件入口 Initialize 能完整执行(注册组件/提醒提供方无异常)。
# 运行时功能(麦克风采样、UI 交互)在无头 CI 环境中无法验证。

on:
push:
workflow_dispatch:

jobs:
integration-test:
runs-on: windows-latest
name: Launch in ClassIsland
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x

- name: Publish plugin
shell: pwsh
run: dotnet publish Decibel_Monitor.csproj -c Release -o "$env:RUNNER_TEMP\plugin"

- name: Download & extract ClassIsland (official release 2.1.0.1)
shell: pwsh
run: |
$zip = Join-Path $env:RUNNER_TEMP "classisland.zip"
$dest = Join-Path $env:RUNNER_TEMP "classisland"
Invoke-WebRequest -Uri "https://github.com/ClassIsland/ClassIsland/releases/download/2.1.0.1/ClassIsland_app_windows_x64_full_folder.zip" -OutFile $zip
Expand-Archive -Path $zip -DestinationPath $dest -Force
$exe = Get-ChildItem -Path $dest -Recurse -Filter "ClassIsland.Desktop.exe" | Select-Object -First 1
if (-not $exe) { throw "未在解压目录中找到 ClassIsland.Desktop.exe" }
Write-Host "ClassIsland.Desktop.exe: $($exe.FullName)"
Add-Content -Path $env:GITHUB_ENV -Value "CI_CLASSISLAND_EXE=$($exe.FullName)"

- name: Launch ClassIsland with plugin & verify load marker
shell: pwsh
env:
DECIBEL_MONITOR_CI_MARKER: "1"
run: |
$exe = $env:CI_CLASSISLAND_EXE
$exeDir = Split-Path $exe
# folder 打包:AppPackageRoot = exeDir/.., AppRoot = AppPackageRoot/data,
# 插件配置目录 = AppRoot/Config/Plugins/<manifest.id>
$appRoot = (Resolve-Path (Join-Path $exeDir "..")).Path
$marker = Join-Path $appRoot "data\Config\Plugins\Decibel_Monitor\loaded.marker"
$pluginDir = Join-Path $env:RUNNER_TEMP "plugin"
Write-Host "插件目录: $pluginDir"
Write-Host "期望标记文件: $marker"

$proc = Start-Process -FilePath $exe -ArgumentList @("-epp", $pluginDir, "--skip-oobe", "--quiet") -PassThru -WindowStyle Hidden
try {
$deadline = (Get-Date).AddSeconds(150)
$found = $false
while ((Get-Date) -lt $deadline) {
if (Test-Path $marker) { $found = $true; break }
if ($proc.HasExited) {
Write-Host "ClassIsland 进程已退出, ExitCode=$($proc.ExitCode)"
break
}
Start-Sleep -Seconds 5
}
if (-not $found) {
Write-Host "ClassIsland 进程是否存活: $(-not $proc.HasExited)"
Write-Host "AppRoot 下内容:"
if (Test-Path $appRoot) { Get-ChildItem $appRoot -Recurse -Depth 3 | Select-Object -ExpandProperty FullName | Out-String | Write-Host }
throw "插件未能在 ClassIsland 中成功加载(标记文件不存在: $marker)"
}
Write-Host "✅ 插件加载成功,标记文件: $marker"
Get-Content $marker
} finally {
if (-not $proc.HasExited) { Stop-Process -Id $proc.Id -Force -ErrorAction SilentlyContinue }
}
34 changes: 8 additions & 26 deletions .github/workflows/Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ on:
push:
workflow_dispatch:
pull_request:
types: [closed]


jobs:
build_app:
test:
runs-on: windows-latest
name: Build
name: Test
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install .NET Core
uses: actions/setup-dotnet@v4
with:
Expand All @@ -26,26 +25,9 @@ jobs:
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-

- name: Build
run: pwsh -ep bypass ./tools/publish.ps1

- name: Checksum
run: pwsh -ep bypass ./tools/generate-md5.ps1 cipx/
- name: Build main project
run: dotnet build Decibel_Monitor.csproj -c Release

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
path: |
./cipx/*.cipx
./cipx/checksums.md
name: Decibel_Monitor-Actions

- name: Upload APP to release
uses: ncipollo/release-action@v1
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
artifacts: "./cipx/*.cipx"
draft: true
bodyFile: ./cipx/checksums.md
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run unit tests
run: dotnet test Tests/Decibel_Monitor.Tests/Decibel_Monitor.Tests.csproj -c Release
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ x86/
bld/
[Bb]in/
[Oo]bj/
# ClassIsland 插件打包产物
cipx/
[Oo]ut/
[Ll]og/
[Ll]ogs/
Expand Down
Empty file.
58 changes: 31 additions & 27 deletions Controls/ComponentSettings/DecibelComponentSettingsControl.axaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
<!--
<ci:ComponentBase> 是一个用户控件基类,用于定义组件设置界面。

参数:
x:Class - 指定该控件的完整类型名称,包括命名空间。
此处为 "Decibel_Monitor.Controls.ComponentSettings.DecibelComponentSettingsControl"
x:TypeArguments - 泛型参数,指定绑定的数据模型类型。
这里是 componentSettingsModel:DecibelComponentSettings

功能:
提供一个可滚动的设置面板,允许用户配置与分贝显示相关的组件设置,
包括图片路径和圆角半径两个选项。
-->

<ci:ComponentBase
x:Class="Decibel_Monitor.Controls.ComponentSettings.DecibelComponentSettingsControl"
x:TypeArguments="componentSettingsModel:DecibelComponentSettings"
Expand All @@ -20,31 +6,49 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ci="http://classisland.tech/schemas/xaml/core"
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:local="clr-namespace:Decibel_Monitor.Controls.ComponentSettings"
xmlns:componentSettingsModel="clr-namespace:Decibel_Monitor.Models.ComponentSettings"
mc:Ignorable="d">

<!-- 绑定到当前设置控件实例,便于访问 ReferenceDecibel 与 Settings -->
<!-- 本面板("小组件显示侧")仅包含该组件的显示偏好。
测量/校准(参考 dB、放大倍数)为全局设置,请到 设置 → Decibel_Monitor 页 校准;
提醒相关设置请到 设置 → 通知 → 分贝提醒。 -->
<ScrollViewer
DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:DecibelComponentSettingsControl}}}">
<StackPanel Classes="settings-container animated-intro" Margin="12" Spacing="8">
<TextBlock FontSize="14" FontWeight="Bold" Text="校准(Calibration)" Margin="0,0,0,4"/>

<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Spacing="8">
<TextBlock VerticalAlignment="Center" Width="88" Text="参考(dB)" />
<!-- 用户可输入物理/显示 dB(0~150),内部会转换为 dBFS -->
<Slider Width="260" Minimum="0" Maximum="150" Value="{Binding ReferenceDecibel, Mode=TwoWay}" TickFrequency="1" />
<TextBlock VerticalAlignment="Center" Width="64" Text="{Binding ReferenceDecibel, StringFormat='{}{0:F1} dB'}" />
<TextBlock VerticalAlignment="Center" Width="88" Text="组件内提示" />
<ToggleSwitch IsChecked="{Binding Settings.ShowAlertTextOnComponent, Mode=TwoWay}" />
</StackPanel>

<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Spacing="8">
<Button Click="On_Calibrate" Content="校准" Padding="8,6" />
<TextBlock VerticalAlignment="Center" Text="当前放大倍数:" />
<TextBlock VerticalAlignment="Center" Text="{Binding Settings.Magnification, Mode=OneWay, StringFormat='{}{0:F3}×'}" />
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Spacing="8">
<TextBlock VerticalAlignment="Center" Width="88" Text="分贝: 前缀" />
<ToggleSwitch IsChecked="{Binding Settings.ShowDecibelPrefix, Mode=TwoWay}" />
</StackPanel>

<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Spacing="8">
<TextBlock VerticalAlignment="Center" Width="88" Text="更新频率" />
<Slider Width="200" Minimum="100" Maximum="1000" TickFrequency="50"
Value="{Binding Settings.UpdateIntervalMs, Mode=TwoWay}"
IsSnapToTickEnabled="True" />
<TextBlock VerticalAlignment="Center" Width="110"
Text="{Binding Settings.UpdateIntervalMs, StringFormat='{}{0} ms'}" />
</StackPanel>

<TextBlock FontSize="12" Classes="muted" Text="说明:滑块为 dB(0..150)。校准时会把该 dB 转换为 dBFS(dBFS = dB - 150),再用于放大倍数计算。" TextWrapping="Wrap"/>
<TextBlock FontSize="12" Classes="muted"
Text="显示设置:开启“分贝: 前缀”时数值显示为“分贝: 70.0”形式;“更新频率”越小数值响应越快(建议 100–500 ms)。"
TextWrapping="Wrap"/>

<TextBlock FontSize="12" Classes="muted"
Text="开启“组件内提示”后,当分贝超过通知设置中的阈值时,会在本组件上显示红色提示文字(如“请保持安静”);关闭后仍会发送系统通知,但不再在组件上显示提示文字。"
TextWrapping="Wrap"/>

<TextBlock FontSize="12" Classes="muted"
Text="分贝数值由全局校准决定(同一麦克风所有组件显示一致)。校准与放大倍数请到 设置 → Decibel_Monitor 页 操作。"
TextWrapping="Wrap"/>
</StackPanel>
</ScrollViewer>
</ci:ComponentBase>
</ci:ComponentBase>


Loading