Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2023-12-15 12:05:01 +08:00
commit 7414dc960f
5 changed files with 22 additions and 1 deletions

View file

@ -37,7 +37,7 @@ func serveSnippets(c *gin.Context) {
name := strings.TrimSuffix(filePath, ext)
confSnippets, err := model.LoadSnippets()
if nil != err {
logging.LogErrorf("load snippets failed: %s", name, err)
logging.LogErrorf("load snippets failed: %s", err)
c.Status(404)
return
}

View file

@ -16,6 +16,18 @@
package conf
type Snpt struct {
EnabledCSS bool `json:"enabledCSS"`
EnabledJS bool `json:"enabledJS"`
}
func NewSnpt() *Snpt {
return &Snpt{
EnabledCSS: true,
EnabledJS: true,
}
}
type Snippet struct {
ID string `json:"id"`
Name string `json:"name"`

View file

@ -450,6 +450,8 @@ func renderTemplateCol(ial map[string]string, tplContent string, rowValues []*av
v := rowValue.Values[0]
if av.KeyTypeNumber == v.Type {
dataModel[rowValue.Key.Name] = v.Number.Content
} else if av.KeyTypeDate == v.Type {
dataModel[rowValue.Key.Name] = time.UnixMilli(v.Date.Content)
} else {
dataModel[rowValue.Key.Name] = v.String()
}

View file

@ -80,6 +80,7 @@ type AppConf struct {
OpenHelp bool `json:"openHelp"` // 启动后是否需要打开用户指南
ShowChangelog bool `json:"showChangelog"` // 是否显示版本更新日志
CloudRegion int `json:"cloudRegion"` // 云端区域0中国大陆1北美
Snippet *conf.Snpt `json:"snippet"` // 代码片段
m *sync.Mutex
}
@ -300,6 +301,10 @@ func InitConf() {
Conf.System.Name = util.GetDeviceName()
}
if nil == Conf.Snippet {
Conf.Snippet = conf.NewSnpt()
}
Conf.System.AppDir = util.WorkingDir
Conf.System.ConfDir = util.ConfDir
Conf.System.HomeDir = util.HomeDir

View file

@ -863,6 +863,8 @@ func renderTemplateCol(ial map[string]string, tplContent string, rowValues []*av
v := rowValue.Values[0]
if av.KeyTypeNumber == v.Type {
dataModel[rowValue.Key.Name] = v.Number.Content
} else if av.KeyTypeDate == v.Type {
dataModel[rowValue.Key.Name] = time.UnixMilli(v.Date.Content)
} else {
dataModel[rowValue.Key.Name] = v.String()
}