mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
This commit is contained in:
parent
f887c88b1f
commit
72e966af84
4 changed files with 110 additions and 24 deletions
|
|
@ -219,6 +219,43 @@ func setSearch(c *gin.Context) {
|
|||
ret.Data = s
|
||||
}
|
||||
|
||||
func setCriterion(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
param, err := gulu.JSON.MarshalJSON(arg["criterion"])
|
||||
if nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
criterion := &conf.Criterion{}
|
||||
if err = gulu.JSON.UnmarshalJSON(param, criterion); nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
update := false
|
||||
for i, criteria := range model.Conf.Criteria {
|
||||
if criteria.Name == criterion.Name {
|
||||
model.Conf.Criteria[i] = criterion
|
||||
update = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !update {
|
||||
model.Conf.Criteria = append(model.Conf.Criteria, criterion)
|
||||
}
|
||||
model.Conf.Save()
|
||||
}
|
||||
|
||||
func setKeymap(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue