Compare commits
2 Commits
66ac7194e2
...
ec7a7f18e9
Author | SHA1 | Date |
---|---|---|
tiny-craft | ec7a7f18e9 | |
tiny-craft | aad4bcf17b |
|
@ -662,11 +662,17 @@ func (c *connectionService) SetKeyValue(connName string, db int, key, keyType st
|
||||||
resp.Msg = "invalid hash value"
|
resp.Msg = "invalid hash value"
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
if len(strs) > 1 {
|
total := len(strs)
|
||||||
err = rdb.HSet(ctx, key, strs).Err()
|
if total > 1 {
|
||||||
if err == nil && expiration > 0 {
|
_, err = rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error {
|
||||||
rdb.Expire(ctx, key, expiration)
|
for i := 0; i < total; i += 2 {
|
||||||
|
pipe.HSet(ctx, key, strs[i], strs[i+1])
|
||||||
}
|
}
|
||||||
|
if expiration > 0 {
|
||||||
|
pipe.Expire(ctx, key, expiration)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "set":
|
case "set":
|
||||||
|
@ -795,11 +801,19 @@ func (c *connectionService) AddHashField(connName string, db int, key string, ac
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// overwrite duplicated fields
|
// overwrite duplicated fields
|
||||||
_, err = rdb.HSet(ctx, key, fieldItems...).Result()
|
total := len(fieldItems)
|
||||||
for i := 0; i < len(fieldItems); i += 2 {
|
if total > 1 {
|
||||||
|
_, err = rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error {
|
||||||
|
for i := 0; i < total; i += 2 {
|
||||||
|
rdb.HSet(ctx, key, fieldItems[i], fieldItems[i+1])
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
for i := 0; i < total; i += 2 {
|
||||||
updated[fieldItems[i].(string)] = fieldItems[i+1]
|
updated[fieldItems[i].(string)] = fieldItems[i+1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resp.Msg = err.Error()
|
resp.Msg = err.Error()
|
||||||
return
|
return
|
||||||
|
|
|
@ -126,6 +126,7 @@ const onSaveConnection = async () => {
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
generalForm.value = connectionStore.newDefaultConnection()
|
generalForm.value = connectionStore.newDefaultConnection()
|
||||||
generalFormRef.value?.restoreValidation()
|
generalFormRef.value?.restoreValidation()
|
||||||
|
testing.value = false
|
||||||
showTestResult.value = false
|
showTestResult.value = false
|
||||||
testResult.value = ''
|
testResult.value = ''
|
||||||
tab.value = 'general'
|
tab.value = 'general'
|
||||||
|
@ -135,6 +136,7 @@ watch(
|
||||||
() => dialogStore.connDialogVisible,
|
() => dialogStore.connDialogVisible,
|
||||||
(visible) => {
|
(visible) => {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
|
resetForm()
|
||||||
editName.value = get(dialogStore.connParam, 'name', '')
|
editName.value = get(dialogStore.connParam, 'name', '')
|
||||||
generalForm.value = dialogStore.connParam || connectionStore.newDefaultConnection()
|
generalForm.value = dialogStore.connParam || connectionStore.newDefaultConnection()
|
||||||
generalForm.value.ssh.loginType = generalForm.value.ssh.loginType || 'pwd'
|
generalForm.value.ssh.loginType = generalForm.value.ssh.loginType || 'pwd'
|
||||||
|
@ -286,7 +288,7 @@ const onClose = () => {
|
||||||
<n-form-item :label="$t('dialogue.connection.addr')" required>
|
<n-form-item :label="$t('dialogue.connection.addr')" required>
|
||||||
<n-input
|
<n-input
|
||||||
v-model:value="generalForm.ssh.addr"
|
v-model:value="generalForm.ssh.addr"
|
||||||
:placeholder="$t('dialogue.connection.addr_tip')" />
|
:placeholder="$t('dialogue.connection.ssh_addr_tip')" />
|
||||||
<n-text style="width: 40px; text-align: center">:</n-text>
|
<n-text style="width: 40px; text-align: center">:</n-text>
|
||||||
<n-input-number
|
<n-input-number
|
||||||
v-model:value="generalForm.ssh.port"
|
v-model:value="generalForm.ssh.port"
|
||||||
|
|
|
@ -187,7 +187,7 @@ const onClose = () => {
|
||||||
{{ $t('common.second') }}
|
{{ $t('common.second') }}
|
||||||
</template>
|
</template>
|
||||||
</n-input-number>
|
</n-input-number>
|
||||||
<n-button secondary type="primary" :focusable="false" @click="newForm.ttl = -1">
|
<n-button secondary type="primary" :focusable="false" @click="() => (newForm.ttl = -1)">
|
||||||
{{ $t('dialogue.key.persist_key') }}
|
{{ $t('dialogue.key.persist_key') }}
|
||||||
</n-button>
|
</n-button>
|
||||||
</n-input-group>
|
</n-input-group>
|
||||||
|
|
|
@ -139,6 +139,7 @@
|
||||||
"login_type": "Login Type",
|
"login_type": "Login Type",
|
||||||
"pkfile": "Private Key File",
|
"pkfile": "Private Key File",
|
||||||
"passphrase": "Passphrase",
|
"passphrase": "Passphrase",
|
||||||
|
"ssh_addr_tip": "SSH Server Host",
|
||||||
"ssh_usr_tip": "SSH Username",
|
"ssh_usr_tip": "SSH Username",
|
||||||
"ssh_pwd_tip": "SSH Password",
|
"ssh_pwd_tip": "SSH Password",
|
||||||
"pkfile_tip": "SSH Private Key File Path",
|
"pkfile_tip": "SSH Private Key File Path",
|
||||||
|
|
|
@ -139,6 +139,7 @@
|
||||||
"login_type": "登录类型",
|
"login_type": "登录类型",
|
||||||
"pkfile": "私钥文件",
|
"pkfile": "私钥文件",
|
||||||
"passphrase": "私钥密码",
|
"passphrase": "私钥密码",
|
||||||
|
"ssh_addr_tip": "SSH地址",
|
||||||
"ssh_usr_tip": "SSH登录用户名",
|
"ssh_usr_tip": "SSH登录用户名",
|
||||||
"ssh_pwd_tip": "SSH登录密码",
|
"ssh_pwd_tip": "SSH登录密码",
|
||||||
"pkfile_tip": "SSH私钥文件路径",
|
"pkfile_tip": "SSH私钥文件路径",
|
||||||
|
|
Loading…
Reference in New Issue