MCPcopy Create free account
hub / github.com/Monibuca/engine / schema

Method schema

config/formily.go:43–221  ·  view source on GitHub ↗
(index int)

Source from the content-addressed store, hash-verified

41}
42
43func (config *Config) schema(index int) (r any) {
44 defer func() {
45 err := recover()
46 if err != nil {
47 log.Error(err)
48 }
49 }()
50 if config.props != nil {
51 r := Card{
52 Type: "void",
53 Component: "Card",
54 Properties: make(map[string]any),
55 Index: index,
56 }
57 r.ComponentProps = map[string]any{
58 "title": config.name,
59 }
60 for i, v := range config.props {
61 if strings.HasPrefix(v.tag.Get("desc"), "废弃") {
62 continue
63 }
64 r.Properties[v.name] = v.schema(i)
65 }
66 return r
67 } else {
68 p := Property{
69 Title: config.name,
70 Default: config.GetValue(),
71 DecoratorProps: map[string]any{
72 "tooltip": config.tag.Get("desc"),
73 },
74 ComponentProps: map[string]any{},
75 Decorator: "FormItem",
76 Index: index,
77 }
78 if config.Modify != nil {
79 p.Description = "已动态修改"
80 } else if config.Env != nil {
81 p.Description = "使用环境变量中的值"
82 } else if config.File != nil {
83 p.Description = "使用配置文件中的值"
84 } else if config.Global != nil {
85 p.Description = "已使用全局配置中的值"
86 }
87 p.Enum = config.Enum
88 switch config.Ptr.Type() {
89 case regexpType:
90 p.Type = "string"
91 p.Component = "Input"
92 p.DecoratorProps["addonAfter"] = "正则表达式"
93 str := config.GetValue().(Regexp).String()
94 p.ComponentProps = map[string]any{
95 "placeholder": str,
96 }
97 p.Default = str
98 case durationType:
99 p.Type = "string"
100 p.Component = "Input"

Callers 1

GetFormilyMethod · 0.80

Calls 6

GetValueMethod · 0.95
ErrorFunction · 0.92
InterfaceMethod · 0.80
GetMethod · 0.45
StringMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected