mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-31 05:48:49 +01:00
This commit is contained in:
parent
c86b209fbe
commit
87f22f72e2
7 changed files with 284 additions and 203 deletions
|
|
@ -58,6 +58,8 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/storage/getLocalStorage", model.CheckAuth, getLocalStorage)
|
||||
ginServer.Handle("POST", "/api/storage/setLocalStorageVal", model.CheckAuth, setLocalStorageVal)
|
||||
ginServer.Handle("POST", "/api/storage/removeLocalStorageVal", model.CheckAuth, removeLocalStorageVal)
|
||||
ginServer.Handle("POST", "/api/storage/setCriterion", model.CheckAuth, setCriterion)
|
||||
ginServer.Handle("POST", "/api/storage/getCriteria", model.CheckAuth, getCriteria)
|
||||
|
||||
ginServer.Handle("POST", "/api/account/login", model.CheckAuth, login)
|
||||
ginServer.Handle("POST", "/api/account/checkActivationcode", model.CheckAuth, checkActivationcode)
|
||||
|
|
@ -245,7 +247,6 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/setting/setExport", model.CheckAuth, setExport)
|
||||
ginServer.Handle("POST", "/api/setting/setFiletree", model.CheckAuth, setFiletree)
|
||||
ginServer.Handle("POST", "/api/setting/setSearch", model.CheckAuth, setSearch)
|
||||
ginServer.Handle("POST", "/api/setting/setCriterion", model.CheckAuth, setCriterion)
|
||||
ginServer.Handle("POST", "/api/setting/setKeymap", model.CheckAuth, setKeymap)
|
||||
ginServer.Handle("POST", "/api/setting/setAppearance", model.CheckAuth, setAppearance)
|
||||
ginServer.Handle("POST", "/api/setting/getCloudUser", model.CheckAuth, getCloudUser)
|
||||
|
|
|
|||
|
|
@ -219,43 +219,6 @@ 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)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,50 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
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 := &model.Criterion{}
|
||||
if err = gulu.JSON.UnmarshalJSON(param, criterion); nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
err = model.SetCriterion(criterion)
|
||||
if nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func getCriteria(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
data, err := model.GetCriteria()
|
||||
if nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
ret.Data = data
|
||||
}
|
||||
|
||||
func removeLocalStorageVal(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue