mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 00:00:38 +08:00
This commit is contained in:
parent
f887c88b1f
commit
72e966af84
@ -245,6 +245,7 @@ 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,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)
|
||||
|
47
kernel/conf/criterion.go
Normal file
47
kernel/conf/criterion.go
Normal file
@ -0,0 +1,47 @@
|
||||
// SiYuan - Build Your Eternal Digital Garden
|
||||
// Copyright (c) 2020-present, b3log.org
|
||||
//
|
||||
// This program is free software you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package conf
|
||||
|
||||
type Criterion struct {
|
||||
Name string `json:"name"`
|
||||
Sort int `json:"sort"` // 0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时)
|
||||
Group int `json:"group"` // 0:不分组,1:按文档分组
|
||||
Layout int `json:"layout"` // 0:上下,1:左右
|
||||
HasReplace bool `json:"hasReplace"` // 是否有替换
|
||||
Method int `json:"method"` // 0:文本,1:查询语法,2:SQL,3:正则表达式
|
||||
HPath string `json:"hPath"`
|
||||
IDPath []string `json:"idPath"`
|
||||
K string `json:"k"` // 搜索关键字
|
||||
R string `json:"r"` // 替换关键字
|
||||
ReplaceList []string `json:"replaceList"` // 替换候选列表
|
||||
List []string `json:"list"` // 搜索候选列表
|
||||
Types *CriterionTypes `json:"types"` // 类型过滤选项
|
||||
}
|
||||
|
||||
type CriterionTypes struct {
|
||||
mathBlock bool
|
||||
table bool
|
||||
blockquote bool
|
||||
superBlock bool
|
||||
paragraph bool
|
||||
document bool
|
||||
heading bool
|
||||
list bool
|
||||
listItem bool
|
||||
codeBlock bool
|
||||
htmlBlock bool
|
||||
}
|
@ -70,6 +70,7 @@ type AppConf struct {
|
||||
Api *conf.API `json:"api"` // API
|
||||
Repo *conf.Repo `json:"repo"` // 数据仓库
|
||||
Newbie bool `json:"newbie"` // 是否是安装后第一次启动
|
||||
Criteria []*conf.Criterion `json:"criteria"` // 搜索查询
|
||||
}
|
||||
|
||||
func InitConf() {
|
||||
|
Loading…
Reference in New Issue
Block a user