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 "目录状态:未知" } }