fix: edit state does not revert when switching keys

fix: some digits are incorrectly recognized as base64-encoded text
This commit is contained in:
tiny-craft 2023-11-10 23:24:01 +08:00
parent 21c63e2ac2
commit a2ad85627e
6 changed files with 39 additions and 16 deletions

View File

@ -12,10 +12,10 @@ import (
"github.com/klauspost/compress/gzip"
"github.com/klauspost/compress/zstd"
"io"
"regexp"
"strconv"
"strings"
"tinyrdm/backend/types"
"unicode/utf8"
)
// ConvertTo convert string to specified type
@ -215,11 +215,13 @@ func decodeJson(str string) (string, bool) {
}
func decodeBase64(str string) (string, bool) {
if match, _ := regexp.MatchString(`^\d+$`, str); !match {
if decodedStr, err := base64.StdEncoding.DecodeString(str); err == nil {
if s := string(decodedStr); utf8.ValidString(s) {
if s := string(decodedStr); !containsBinary(s) {
return s, true
}
}
}
return str, false
}

View File

@ -131,6 +131,11 @@ const valueColumn = reactive({
}
},
})
const cancelEdit = () => {
currentEditRow.value.no = 0
}
const actionColumn = {
key: 'action',
title: i18n.t('interface.action'),
@ -185,9 +190,7 @@ const actionColumn = {
currentEditRow.value.no = 0
}
},
onCancel: () => {
currentEditRow.value.no = 0
},
onCancel: cancelEdit,
})
},
}
@ -265,6 +268,7 @@ const onUpdateFilter = (filters, sourceColumn) => {
defineExpose({
reset: () => {
clearFilter()
cancelEdit()
},
})
</script>

View File

@ -89,6 +89,10 @@ const valueColumn = reactive({
},
})
const cancelEdit = () => {
currentEditRow.value.no = 0
}
const actionColumn = {
key: 'action',
title: i18n.t('interface.action'),
@ -141,9 +145,7 @@ const actionColumn = {
currentEditRow.value.no = 0
}
},
onCancel: () => {
currentEditRow.value.no = 0
},
onCancel: cancelEdit,
})
},
}
@ -198,6 +200,7 @@ const onUpdateFilter = (filters, sourceColumn) => {
defineExpose({
reset: () => {
clearFilter()
cancelEdit()
},
})
</script>

View File

@ -89,6 +89,11 @@ const valueColumn = reactive({
}
},
})
const cancelEdit = () => {
currentEditRow.value.no = 0
}
const actionColumn = {
key: 'action',
title: i18n.t('interface.action'),
@ -142,9 +147,7 @@ const actionColumn = {
currentEditRow.value.no = 0
}
},
onCancel: () => {
currentEditRow.value.no = 0
},
onCancel: cancelEdit,
})
},
}
@ -199,6 +202,7 @@ const onUpdateFilter = (filters, sourceColumn) => {
defineExpose({
reset: () => {
clearFilter()
cancelEdit()
},
})
</script>

View File

@ -143,6 +143,12 @@ const onSaveValue = async () => {
saving.value = false
}
}
defineExpose({
reset: () => {
inEdit.value = false
},
})
</script>
<template>

View File

@ -160,6 +160,11 @@ const valueColumn = reactive({
}
},
})
const cancelEdit = () => {
currentEditRow.value.no = 0
}
const actionColumn = {
key: 'action',
title: i18n.t('interface.action'),
@ -219,9 +224,7 @@ const actionColumn = {
currentEditRow.value.no = 0
}
},
onCancel: () => {
currentEditRow.value.no = 0
},
onCancel: cancelEdit,
})
},
}
@ -303,6 +306,7 @@ const onUpdateFilter = (filters, sourceColumn) => {
defineExpose({
reset: () => {
clearFilter()
cancelEdit()
},
})
</script>