🎨 Supports multiple views for the database https://github.com/siyuan-note/siyuan/issues/9751

This commit is contained in:
Daniel 2023-12-01 10:57:28 +08:00
parent 0cf13cca8f
commit 1f130d4b1c
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 24 additions and 3 deletions

View file

@ -747,6 +747,29 @@ func (av *AttributeView) GetBlockKey() (ret *Key) {
return
}
func (av *AttributeView) GetDuplicateViewName(masterViewName string) string {
count := 1
ret := masterViewName + " (" + strconv.Itoa(count) + ")"
existViewByName := func(name string) bool {
for _, v := range av.Views {
if v.Name == name {
return true
}
}
return false
}
for i := 0; i < 32; i++ {
if !existViewByName(ret) {
return ret
}
count++
ret = masterViewName + " (" + strconv.Itoa(count) + ")"
}
return ret
}
func GetAttributeViewDataPath(avID string) (ret string) {
av := filepath.Join(util.DataDir, "storage", "av")
ret = filepath.Join(av, avID+".json")