mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 08:00:13 +01:00
🎨 Improve Add to Database https://github.com/siyuan-note/siyuan/issues/10659
This commit is contained in:
parent
d684bb41b1
commit
dcefed26eb
1 changed files with 29 additions and 43 deletions
|
|
@ -1263,7 +1263,12 @@ func SearchAttributeView(keyword string, excludeAvIDs []string) (ret []*AvSearch
|
||||||
logging.LogErrorf("read directory [%s] failed: %s", avDir, err)
|
logging.LogErrorf("read directory [%s] failed: %s", avDir, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
avBlockRels := av.GetBlockRels()
|
avBlockRels := av.GetBlockRels()
|
||||||
|
if 1 > len(avBlockRels) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
if entry.IsDir() {
|
if entry.IsDir() {
|
||||||
continue
|
continue
|
||||||
|
|
@ -1322,48 +1327,29 @@ func SearchAttributeView(keyword string, excludeAvIDs []string) (ret []*AvSearch
|
||||||
if 12 <= len(avSearchTmpResults) {
|
if 12 <= len(avSearchTmpResults) {
|
||||||
avSearchTmpResults = avSearchTmpResults[:12]
|
avSearchTmpResults = avSearchTmpResults[:12]
|
||||||
}
|
}
|
||||||
var avIDs []string
|
|
||||||
for _, a := range avSearchTmpResults {
|
|
||||||
avIDs = append(avIDs, a.AvID)
|
|
||||||
}
|
|
||||||
|
|
||||||
var blockIDs []string
|
for _, tmpResult := range avSearchTmpResults {
|
||||||
for _, bIDs := range avBlockRels {
|
bIDs := avBlockRels[tmpResult.AvID]
|
||||||
blockIDs = append(blockIDs, bIDs...)
|
var node *ast.Node
|
||||||
}
|
for _, bID := range bIDs {
|
||||||
blockIDs = gulu.Str.RemoveDuplicatedElem(blockIDs)
|
tree, _ := LoadTreeByBlockID(bID)
|
||||||
|
if nil == tree {
|
||||||
trees := filesys.LoadTrees(blockIDs)
|
continue
|
||||||
hitAttrViews := map[string]bool{}
|
|
||||||
for _, blockID := range blockIDs {
|
|
||||||
tree := trees[blockID]
|
|
||||||
if nil == tree {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
node := treenode.GetNodeInTree(tree, blockID)
|
|
||||||
if nil == node || "" == node.AttributeViewID {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
avID := node.AttributeViewID
|
|
||||||
var existAv *AvSearchTempResult
|
|
||||||
for _, tmpResult := range avSearchTmpResults {
|
|
||||||
if tmpResult.AvID == avID {
|
|
||||||
existAv = tmpResult
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
node = treenode.GetNodeInTree(tree, bID)
|
||||||
|
if nil == node || "" == node.AttributeViewID {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
}
|
}
|
||||||
if nil == existAv || gulu.Str.Contains(avID, excludeAvIDs) {
|
|
||||||
|
if nil == node {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if hitAttrViews[avID] {
|
attrView, _ := av.ParseAttributeView(tmpResult.AvID)
|
||||||
continue
|
|
||||||
}
|
|
||||||
hitAttrViews[avID] = true
|
|
||||||
|
|
||||||
attrView, _ := av.ParseAttributeView(avID)
|
|
||||||
if nil == attrView {
|
if nil == attrView {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -1378,27 +1364,27 @@ func SearchAttributeView(keyword string, excludeAvIDs []string) (ret []*AvSearch
|
||||||
hPath = box.Name + hPath
|
hPath = box.Name + hPath
|
||||||
}
|
}
|
||||||
|
|
||||||
name := existAv.AvName
|
name := tmpResult.AvName
|
||||||
if "" == name {
|
if "" == name {
|
||||||
name = Conf.language(267)
|
name = Conf.language(267)
|
||||||
}
|
}
|
||||||
|
|
||||||
parent := &AvSearchResult{
|
parent := &AvSearchResult{
|
||||||
AvID: avID,
|
AvID: tmpResult.AvID,
|
||||||
AvName: existAv.AvName,
|
AvName: tmpResult.AvName,
|
||||||
BlockID: blockID,
|
BlockID: node.ID,
|
||||||
HPath: hPath,
|
HPath: hPath,
|
||||||
}
|
}
|
||||||
ret = append(ret, parent)
|
ret = append(ret, parent)
|
||||||
|
|
||||||
for _, view := range attrView.Views {
|
for _, view := range attrView.Views {
|
||||||
child := &AvSearchResult{
|
child := &AvSearchResult{
|
||||||
AvID: avID,
|
AvID: tmpResult.AvID,
|
||||||
AvName: existAv.AvName,
|
AvName: tmpResult.AvName,
|
||||||
ViewName: view.Name,
|
ViewName: view.Name,
|
||||||
ViewID: view.ID,
|
ViewID: view.ID,
|
||||||
ViewLayout: view.LayoutType,
|
ViewLayout: view.LayoutType,
|
||||||
BlockID: blockID,
|
BlockID: node.ID,
|
||||||
HPath: hPath,
|
HPath: hPath,
|
||||||
}
|
}
|
||||||
parent.Children = append(parent.Children, child)
|
parent.Children = append(parent.Children, child)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue