Implement catalog startup diagnostics (T-616)

This commit is contained in:
ila
2026-07-19 22:22:46 +08:00
parent 06234e11bf
commit 2c561894fd
28 changed files with 715 additions and 23 deletions
+46
View File
@@ -0,0 +1,46 @@
package gio
import "softbox.local/core/application"
type catalogPresentationState string
const (
catalogStateLoading catalogPresentationState = "loading"
catalogStateReady catalogPresentationState = "ready"
catalogStateUnconfigured catalogPresentationState = "unconfigured"
catalogStateLoadFailed catalogPresentationState = "load_failed"
)
func (shell *AppShell) applyCatalogEvent(event application.Event) (bool, error) {
payload, handled, err := application.ParseCatalogEvent(event)
if err != nil || !handled {
return handled, err
}
switch payload.Type {
case application.EventCatalogRefreshed:
shell.SetItems(payload.Items)
case application.EventCatalogRejected:
switch payload.FailureCode {
case application.CatalogFailureSourceUnconfigured:
shell.catalogState = catalogStateUnconfigured
case application.CatalogFailureLoadFailed:
shell.catalogState = catalogStateLoadFailed
}
}
return true, nil
}
func (shell *AppShell) catalogStatusText() string {
switch shell.catalogState {
case catalogStateLoading:
return "目录状态:正在加载已验证 Catalog"
case catalogStateUnconfigured:
return "目录状态:Catalog 来源尚未配置"
case catalogStateLoadFailed:
return "目录状态:Catalog 加载失败"
case catalogStateReady:
return "目录状态:已加载已验证 Catalog"
default:
return "目录状态:未知"
}
}