首次提交: OnebotCatalog 项目代码与文档(含 NX 按需生成服务二期、后台、一键启动)

This commit is contained in:
wangruiguo
2026-09-03 17:55:45 +08:00
commit fafa86d3a6
241 changed files with 78656 additions and 0 deletions

38
tools/ui-diagnose.ps1 Normal file
View File

@@ -0,0 +1,38 @@
# UI 层诊断 (STA): 反射创建主窗口, 对每个系列执行 LoadSeries,
# 检查下拉框数据源是否为空 / 是否抛异常。
# 用法: powershell -STA -NoProfile -ExecutionPolicy Bypass -File tools\ui-diagnose.ps1
param(
[string]$Exe = (Join-Path $PSScriptRoot '..\bin\OnebotCatalog.exe'),
[string]$Opc = (Join-Path $PSScriptRoot '..\sample\OnebotCatalog_2026.08.opc')
)
$ErrorActionPreference = 'Stop'
Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName PresentationCore
Add-Type -AssemblyName WindowsBase
$asm = [Reflection.Assembly]::LoadFrom($Exe)
$pkgType = $asm.GetType('Ounibo.Catalog.Core.OpcPackage')
$pkg = $pkgType.GetMethod('Open').Invoke($null, @($Opc))
$mwType = $asm.GetType('Ounibo.Catalog.App.MainWindow')
$mw = [Activator]::CreateInstance($mwType, @($pkg, $false))
$ls = $mwType.GetMethod('LoadSeries', [Reflection.BindingFlags]'NonPublic,Instance')
$boxesField = $mwType.GetField('_boxes', [Reflection.BindingFlags]'NonPublic,Instance')
foreach ($s in $pkg.Catalog.series) {
try {
$ls.Invoke($mw, @($s)) | Out-Null
$boxes = $boxesField.GetValue($mw)
$parts = @()
foreach ($k in $boxes.Keys) {
$cb = $boxes[$k]
$count = 0
if ($cb.ItemsSource -ne $null) { $count = $cb.Items.Count }
$parts += ($k + '=' + $count)
}
Write-Output ("系列 " + $s.code + " 下拉数据源: " + ($parts -join ' '))
} catch {
Write-Output ("系列 " + $s.code + " 异常: " + $_.Exception.InnerException.Message)
}
}
$pkg.Dispose()