mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 08:48:49 +01:00
♻️ 一些工具函数移动到 gulu 项目中
This commit is contained in:
parent
afbe434239
commit
705f34ccd1
10 changed files with 20 additions and 65 deletions
|
|
@ -267,7 +267,7 @@ func uploadCloud(sqlAssets []*sql.Asset) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
uploadAbsAssets = util.RemoveDuplicatedElem(uploadAbsAssets)
|
||||
uploadAbsAssets = gulu.Str.RemoveDuplicatedElem(uploadAbsAssets)
|
||||
|
||||
util.LogInfof("uploading [%d] assets", len(uploadAbsAssets))
|
||||
if loadErr := LoadUploadToken(); nil != loadErr {
|
||||
|
|
@ -357,7 +357,7 @@ func saveWorkspaceAssets(assets []string) {
|
|||
}
|
||||
confPath := filepath.Join(confDir, "assets.json")
|
||||
|
||||
assets = util.RemoveDuplicatedElem(assets)
|
||||
assets = gulu.Str.RemoveDuplicatedElem(assets)
|
||||
sort.Strings(assets)
|
||||
data, err := gulu.JSON.MarshalIndentJSON(assets, "", " ")
|
||||
if nil != err {
|
||||
|
|
|
|||
|
|
@ -531,11 +531,11 @@ func GetDoc(id string, index int, keyword string, mode int, size int) (blockCoun
|
|||
tmp = append(tmp, e)
|
||||
}
|
||||
excludes = tmp
|
||||
virtualBlockRefKeywords = util.ExcludeElem(virtualBlockRefKeywords, excludes)
|
||||
virtualBlockRefKeywords = gulu.Str.ExcludeElem(virtualBlockRefKeywords, excludes)
|
||||
}
|
||||
|
||||
// 虚拟引用排除当前文档名 https://github.com/siyuan-note/siyuan/issues/4537
|
||||
virtualBlockRefKeywords = util.ExcludeElem(virtualBlockRefKeywords, []string{tree.Root.IALAttr("title")})
|
||||
virtualBlockRefKeywords = gulu.Str.ExcludeElem(virtualBlockRefKeywords, []string{tree.Root.IALAttr("title")})
|
||||
|
||||
if 0 < len(virtualBlockRefKeywords) {
|
||||
var tmp []string
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ func FindReplace(keyword, replacement string, ids []string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
ids = util.RemoveDuplicatedElem(ids)
|
||||
ids = gulu.Str.RemoveDuplicatedElem(ids)
|
||||
var renameRoots []*ast.Node
|
||||
renameRootTitles := map[string]string{}
|
||||
for _, id := range ids {
|
||||
|
|
@ -403,7 +403,7 @@ func markSearch(text string, keyword string, beforeLen int) (marked string, scor
|
|||
}
|
||||
|
||||
keywords := gulu.Str.SubstringsBetween(marked, "__@mark__", "__mark@__")
|
||||
keywords = util.RemoveDuplicatedElem(keywords)
|
||||
keywords = gulu.Str.RemoveDuplicatedElem(keywords)
|
||||
keyword = strings.Join(keywords, search.TermSep)
|
||||
marked = strings.ReplaceAll(marked, "__@mark__", "")
|
||||
marked = strings.ReplaceAll(marked, "__mark@__", "")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue