fix: can not display correct content with decoder after modified

This commit is contained in:
Lykin 2024-07-31 16:46:50 +08:00
parent 237b25086c
commit 70c38d9aa7
1 changed files with 6 additions and 3 deletions

View File

@ -1241,7 +1241,7 @@ func (b *browserService) SetKeyValue(param types.SetKeyParam) (resp types.JSResp
if len(param.Format) <= 0 { if len(param.Format) <= 0 {
param.Format = types.FORMAT_RAW param.Format = types.FORMAT_RAW
} }
var savedValue any var savedValue string
switch strings.ToLower(param.KeyType) { switch strings.ToLower(param.KeyType) {
case "string": case "string":
if str, ok := param.Value.(string); !ok { if str, ok := param.Value.(string); !ok {
@ -1339,7 +1339,10 @@ func (b *browserService) SetKeyValue(param types.SetKeyParam) (resp types.JSResp
if err == nil && expiration > 0 { if err == nil && expiration > 0 {
client.Expire(ctx, key, expiration) client.Expire(ctx, key, expiration)
} }
savedValue = param.Value var ok bool
if savedValue, ok = param.Value.(string); !ok {
savedValue = ""
}
} }
if err != nil { if err != nil {
@ -1348,7 +1351,7 @@ func (b *browserService) SetKeyValue(param types.SetKeyParam) (resp types.JSResp
} }
resp.Success = true resp.Success = true
resp.Data = map[string]any{ resp.Data = map[string]any{
"value": savedValue, "value": strutil.EncodeRedisKey(savedValue),
} }
return return
} }