fix: 修复配置导出工具无法忽略描述前缀为 # 的字段

This commit is contained in:
kercylan98 2023-11-13 12:01:14 +08:00
parent 274402e721
commit 5c180de118
3 changed files with 6 additions and 5 deletions

View File

@ -194,7 +194,7 @@ func (slf *Xlsx) checkFieldInvalid(field pce.DataField) bool {
return true
}
if strings.HasPrefix(field.Name, "#") || strings.HasPrefix(field.Type, "#") {
if strings.HasPrefix(field.Name, "#") || strings.HasPrefix(field.Type, "#") || strings.HasPrefix(field.Desc, "#") {
return true
}

Binary file not shown.

View File

@ -29,6 +29,7 @@ func (slf *Golang) Render(templates ...*pce.TmplStruct) (string, error) {
"github.com/kercylan98/minotaur/utils/log"
"github.com/kercylan98/minotaur/utils/hash"
"sync"
"sync/atomic"
)
type Sign string
@ -41,7 +42,7 @@ func (slf *Golang) Render(templates ...*pce.TmplStruct) (string, error) {
var (
json = jsonIter.ConfigCompatibleWithStandardLibrary
configs map[Sign]any
configs atomic.Pointer[map[Sign]any]
signs = []Sign{
{{- range .Templates}}
{{.Name}}Sign,
@ -188,14 +189,14 @@ func (slf *Golang) Render(templates ...*pce.TmplStruct) (string, error) {
cs[{{.Name}}Sign] = {{.Name}}
{{- end}}
configs = cs
configs.Store(&cs)
}
// GetConfigs 获取所有配置
func GetConfigs() map[Sign]any {
mutex.Lock()
defer mutex.Unlock()
return hash.Copy(configs)
return hash.Copy(*configs.Load())
}
// GetConfigSigns 获取所有配置的标识
@ -207,7 +208,7 @@ func (slf *Golang) Render(templates ...*pce.TmplStruct) (string, error) {
func Sync(handle func(configs map[Sign]any)) {
mutex.Lock()
defer mutex.Unlock()
handle(hash.Copy(configs))
handle(hash.Copy(*configs.Load()))
}
`, slf)
}