diff --git a/backend/services/connection_service.go b/backend/services/connection_service.go index cd61630..f78dc0e 100644 --- a/backend/services/connection_service.go +++ b/backend/services/connection_service.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "github.com/redis/go-redis/v9" + "log" "strconv" "strings" "sync" @@ -567,12 +568,8 @@ func (c *connectionService) SetKeyValue(connName string, db int, key, keyType st return } else { _, err = rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error { - if len(strs) > 1 { - for _, str := range strs { - pipe.SAdd(ctx, key, str.(string)) - } - } else { - pipe.SAdd(ctx, key) + for _, str := range strs { + pipe.SAdd(ctx, key, str.(string)) } if expiration > 0 { pipe.Expire(ctx, key, expiration) @@ -585,11 +582,13 @@ func (c *connectionService) SetKeyValue(connName string, db int, key, keyType st resp.Msg = "invalid zset value" return } else { + log.Println(strs) _, err = rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error { var members []redis.Z for i := 0; i < len(strs); i += 2 { + score, _ := strconv.ParseFloat(strs[i].(string), 64) members = append(members, redis.Z{ - Score: strs[i].(float64), + Score: score, Member: strs[i+1], }) } diff --git a/frontend/src/components/dialogs/NewKeyDialog.vue b/frontend/src/components/dialogs/NewKeyDialog.vue index b5f53b5..a4fa3c3 100644 --- a/frontend/src/components/dialogs/NewKeyDialog.vue +++ b/frontend/src/components/dialogs/NewKeyDialog.vue @@ -10,6 +10,7 @@ import NewZSetValue from '../new_value/NewZSetValue.vue' import NewSetValue from '../new_value/NewSetValue.vue' import { useI18n } from 'vue-i18n' import useConnectionStore from '../../stores/connections.js' +import { useMessage } from 'naive-ui' const i18n = useI18n() const newForm = reactive({ @@ -35,6 +36,7 @@ const dbOptions = computed(() => })) ) const newFormRef = ref(null) +const subFormRef = ref(null) const formLabelWidth = '100px' const options = computed(() => { @@ -74,8 +76,15 @@ watch( ) const connectionStore = useConnectionStore() +const message = useMessage() const onAdd = async () => { - await newFormRef.value?.validate() + await newFormRef.value?.validate().catch((err) => { + message.error(err.message) + }) + if (subFormRef.value?.validate && !subFormRef.value?.validate()) { + message.error(i18n.t('spec_field_required', { key: i18n.t('element') })) + return false + } try { const { server, db, key, type, ttl } = newForm let { value } = newForm @@ -145,7 +154,7 @@ const onClose = () => { {{ $t('persist_key') }} - + diff --git a/frontend/src/components/new_value/NewHashValue.vue b/frontend/src/components/new_value/NewHashValue.vue index cfbd46b..63d6572 100644 --- a/frontend/src/components/new_value/NewHashValue.vue +++ b/frontend/src/components/new_value/NewHashValue.vue @@ -1,6 +1,6 @@