Browse Source

fix: models should have icon equals to model name defaultly

Yeuoly 8 months ago
parent
commit
243384527e
1 changed files with 16 additions and 0 deletions
  1. 16 0
      internal/types/entities/plugin_entities/model_declaration.go

+ 16 - 0
internal/types/entities/plugin_entities/model_declaration.go

@@ -370,6 +370,22 @@ func (m *ModelDeclaration) UnmarshalJSON(data []byte) error {
 	return nil
 }
 
+func (m *ModelDeclaration) MarshalJSON() ([]byte, error) {
+	type alias ModelDeclaration
+
+	temp := &struct {
+		*alias `json:",inline"`
+	}{
+		alias: (*alias)(m),
+	}
+
+	if temp.Label.EnUS == "" {
+		temp.Label.EnUS = temp.Model
+	}
+
+	return json.Marshal(temp)
+}
+
 func (m *ModelDeclaration) UnmarshalYAML(value *yaml.Node) error {
 	type alias ModelDeclaration