🎨 Add internal kernel API /api/filetree/upsertIndexes and /api/filetree/removeIndexes https://github.com/siyuan-note/siyuan/issues/10079

This commit is contained in:
Daniel 2024-01-05 20:54:46 +08:00
parent 318e570343
commit 286654cb00
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
5 changed files with 112 additions and 13 deletions

View file

@ -33,6 +33,40 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
func upsertIndexes(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
pathsArg := arg["paths"].([]interface{})
var paths []string
for _, p := range pathsArg {
paths = append(paths, p.(string))
}
model.UpsertIndexes(paths)
}
func removeIndexes(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
pathsArg := arg["paths"].([]interface{})
var paths []string
for _, p := range pathsArg {
paths = append(paths, p.(string))
}
model.RemoveIndexes(paths)
}
func refreshFiletree(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)

View file

@ -113,6 +113,8 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/filetree/heading2Doc", model.CheckAuth, model.CheckReadonly, heading2Doc)
ginServer.Handle("POST", "/api/filetree/li2Doc", model.CheckAuth, model.CheckReadonly, li2Doc)
ginServer.Handle("POST", "/api/filetree/refreshFiletree", model.CheckAuth, model.CheckReadonly, refreshFiletree)
ginServer.Handle("POST", "/api/filetree/upsertIndexes", model.CheckAuth, model.CheckReadonly, upsertIndexes)
ginServer.Handle("POST", "/api/filetree/removeIndexes", model.CheckAuth, model.CheckReadonly, removeIndexes)
ginServer.Handle("POST", "/api/format/autoSpace", model.CheckAuth, model.CheckReadonly, autoSpace)
ginServer.Handle("POST", "/api/format/netImg2LocalAssets", model.CheckAuth, model.CheckReadonly, netImg2LocalAssets)