mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 增加批量移除本地 kv 存储接口
This commit is contained in:
parent
f36a8721e9
commit
a5d0a6afae
3 changed files with 35 additions and 3 deletions
|
|
@ -95,6 +95,35 @@ func getCriteria(c *gin.Context) {
|
|||
ret.Data = data
|
||||
}
|
||||
|
||||
func removeLocalStorageVals(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
var keys []string
|
||||
keysArg := arg["keys"].([]interface{})
|
||||
for _, key := range keysArg {
|
||||
keys = append(keys, key.(string))
|
||||
}
|
||||
|
||||
err := model.RemoveLocalStorageVals(keys)
|
||||
if nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
app := arg["app"].(string)
|
||||
evt := util.NewCmdResult("removeLocalStorageVal", 0, util.PushModeBroadcastMainExcludeSelfApp)
|
||||
evt.AppId = app
|
||||
evt.Data = map[string]interface{}{"keys": keys}
|
||||
util.PushEvent(evt)
|
||||
}
|
||||
|
||||
func removeLocalStorageVal(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
@ -105,7 +134,7 @@ func removeLocalStorageVal(c *gin.Context) {
|
|||
}
|
||||
|
||||
key := arg["key"].(string)
|
||||
err := model.RemoveLocalStorageVal(key)
|
||||
err := model.RemoveLocalStorageVals([]string{key})
|
||||
if nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue