Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2024-01-01 00:50:39 +08:00
commit 4fcc7f1b4c
2 changed files with 53 additions and 19 deletions

View file

@ -597,5 +597,37 @@ func (r *ValueRollup) RenderContents(calc *RollupCalc) {
}
}
r.Contents = []string{strconv.FormatFloat(max-min, 'f', -1, 64)}
case CalcOperatorChecked:
countChecked := 0
for _, v := range r.Contents {
if "√" == v {
countChecked++
}
}
r.Contents = []string{strconv.Itoa(countChecked)}
case CalcOperatorUnchecked:
countUnchecked := 0
for _, v := range r.Contents {
if "√" != v {
countUnchecked++
}
}
r.Contents = []string{strconv.Itoa(countUnchecked)}
case CalcOperatorPercentChecked:
countChecked := 0
for _, v := range r.Contents {
if "√" == v {
countChecked++
}
}
r.Contents = []string{strconv.Itoa(countChecked*100/len(r.Contents)) + "%"}
case CalcOperatorPercentUnchecked:
countUnchecked := 0
for _, v := range r.Contents {
if "√" != v {
countUnchecked++
}
}
r.Contents = []string{strconv.Itoa(countUnchecked*100/len(r.Contents)) + "%"}
}
}

View file

@ -217,30 +217,32 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
newPath := filepath.Join(filepath.Dir(path), newAvID+".json")
renameAvPaths[path] = newPath
avIDs[oldAvID] = newAvID
// 将数据库文件中的块 ID 替换为新的块 ID
data, readErr := os.ReadFile(path)
if nil != readErr {
logging.LogErrorf("read av file [%s] failed: %s", path, readErr)
return nil
}
var newData []byte
newData = data
for oldID, newID := range avBlockIDs {
newData = bytes.ReplaceAll(newData, []byte(oldID), []byte(newID))
}
newData = bytes.ReplaceAll(newData, []byte(oldAvID), []byte(newAvID))
if !bytes.Equal(data, newData) {
if writeErr := os.WriteFile(path, newData, 0644); nil != writeErr {
logging.LogErrorf("write av file [%s] failed: %s", path, writeErr)
return nil
}
}
return nil
})
// 重命名数据库文件
for oldPath, newPath := range renameAvPaths {
data, readErr := os.ReadFile(oldPath)
if nil != readErr {
logging.LogErrorf("read av file [%s] failed: %s", oldPath, readErr)
return nil
}
// 将数据库文件中的块 ID 替换为新的块 ID
newData := data
for oldAvID, newAvID := range avIDs {
for oldID, newID := range avBlockIDs {
newData = bytes.ReplaceAll(newData, []byte(oldID), []byte(newID))
}
newData = bytes.ReplaceAll(newData, []byte(oldAvID), []byte(newAvID))
}
if !bytes.Equal(data, newData) {
if writeErr := os.WriteFile(oldPath, newData, 0644); nil != writeErr {
logging.LogErrorf("write av file [%s] failed: %s", oldPath, writeErr)
return nil
}
}
if err = os.Rename(oldPath, newPath); nil != err {
logging.LogErrorf("rename av file from [%s] to [%s] failed: %s", oldPath, newPath, err)
return