mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package homepage
|
|
|
|
type (
|
|
HomePageConfig map[string]HomePageCategory
|
|
HomePageCategory []*HomePageItem
|
|
|
|
HomePageItem struct {
|
|
Show bool `yaml:"show" json:"show"`
|
|
Name string `yaml:"name" json:"name"`
|
|
Icon string `yaml:"icon" json:"icon"`
|
|
URL string `yaml:"url" json:"url"` // alias + domain
|
|
Category string `yaml:"category" json:"category"`
|
|
Description string `yaml:"description" json:"description"`
|
|
WidgetConfig map[string]any `yaml:",flow" json:"widget_config"`
|
|
|
|
SourceType string `yaml:"-" json:"source_type"`
|
|
AltURL string `yaml:"-" json:"alt_url"` // original proxy target
|
|
}
|
|
)
|
|
|
|
func (item *HomePageItem) IsEmpty() bool {
|
|
return item == nil || (item.Name == "" &&
|
|
item.Icon == "" &&
|
|
item.URL == "" &&
|
|
item.Category == "" &&
|
|
item.Description == "" &&
|
|
len(item.WidgetConfig) == 0)
|
|
}
|
|
|
|
func NewHomePageConfig() HomePageConfig {
|
|
return HomePageConfig(make(map[string]HomePageCategory))
|
|
}
|
|
|
|
func (c *HomePageConfig) Clear() {
|
|
*c = make(HomePageConfig)
|
|
}
|
|
|
|
func (c HomePageConfig) Add(item *HomePageItem) {
|
|
if c[item.Category] == nil {
|
|
c[item.Category] = make(HomePageCategory, 0)
|
|
}
|
|
c[item.Category] = append(c[item.Category], item)
|
|
}
|