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 @@
diff --git a/frontend/src/components/new_value/NewListValue.vue b/frontend/src/components/new_value/NewListValue.vue
index ecbff64..8186467 100644
--- a/frontend/src/components/new_value/NewListValue.vue
+++ b/frontend/src/components/new_value/NewListValue.vue
@@ -1,6 +1,6 @@
diff --git a/frontend/src/components/new_value/NewSetValue.vue b/frontend/src/components/new_value/NewSetValue.vue
index 279be41..9ef2ae5 100644
--- a/frontend/src/components/new_value/NewSetValue.vue
+++ b/frontend/src/components/new_value/NewSetValue.vue
@@ -1,6 +1,6 @@
diff --git a/frontend/src/components/new_value/NewZSetValue.vue b/frontend/src/components/new_value/NewZSetValue.vue
index f45a62e..15a5005 100644
--- a/frontend/src/components/new_value/NewZSetValue.vue
+++ b/frontend/src/components/new_value/NewZSetValue.vue
@@ -29,9 +29,15 @@ const onUpdate = () => {
const val = reject(zset.value, (v) => v == null || isEmpty(v.value))
emit(
'update:value',
- flatMap(val, (item) => [item.value, item.score])
+ flatMap(val, (item) => [item.value, item.score.toString()])
)
}
+
+defineExpose({
+ validate: () => {
+ return !isEmpty(props.value)
+ },
+})
diff --git a/frontend/src/langs/en.json b/frontend/src/langs/en.json
index 85a1268..81217b2 100644
--- a/frontend/src/langs/en.json
+++ b/frontend/src/langs/en.json
@@ -128,7 +128,6 @@
"reload_succ": "Reload Success !",
"field_required": "This item should not be blank",
"spec_field_required": "\"{key}\" should not be blank",
- "no_connections": "No Connection",
"nonexist_tab_content": "The selected key does not exist. Please retry",
"empty_server_content": "Connect server from left list",
"reload_when_succ": "Reload immediately after success",
diff --git a/frontend/src/langs/zh-cn.json b/frontend/src/langs/zh-cn.json
index 0a43ecc..591e8bb 100644
--- a/frontend/src/langs/zh-cn.json
+++ b/frontend/src/langs/zh-cn.json
@@ -130,7 +130,6 @@
"reload_succ": "已重新载入",
"field_required": "此项不能为空",
"spec_field_required": "{key} 不能为空",
- "no_connections": "空空如也",
"nonexist_tab_content": "所选键不存在,请尝试刷新重试",
"empty_server_content": "可以从左边选择并打开连接",
"reload_when_succ": "操作成功后立即重新加载",