浏览代码

fix: models should have icon equals to model name defaultly

Yeuoly 8 月之前
父节点
当前提交
243384527e
共有 1 个文件被更改,包括 16 次插入0 次删除
  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