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/gzip"
"github.com/klauspost/compress/zstd" "github.com/klauspost/compress/zstd"
"io" "io"
"regexp"
"strconv" "strconv"
"strings" "strings"
"tinyrdm/backend/types" "tinyrdm/backend/types"
"unicode/utf8"
) )
// ConvertTo convert string to specified type // ConvertTo convert string to specified type
@ -215,11 +215,13 @@ func decodeJson(str string) (string, bool) {
} }
func decodeBase64(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 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 s, true
} }
} }
}
return str, false return str, false
} }

View File

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

View File

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

View File

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

View File

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

View File

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