Compare commits

...

3 Commits

Author SHA1 Message Date
Lykin 0038092193 fix: add window shadow on Windows 2024-07-31 23:25:14 +08:00
Lykin 0739cb8b68 feat: add `LZ4` encoder/decoder 2024-07-31 16:49:52 +08:00
Lykin 70c38d9aa7 fix: can not display correct content with decoder after modified 2024-07-31 16:46:50 +08:00
10 changed files with 71 additions and 5 deletions

View File

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

View File

@ -13,6 +13,7 @@ const DECODE_BASE64 = "Base64"
const DECODE_GZIP = "GZip"
const DECODE_DEFLATE = "Deflate"
const DECODE_ZSTD = "ZStd"
const DECODE_LZ4 = "LZ4"
const DECODE_BROTLI = "Brotli"
const DECODE_MSGPACK = "Msgpack"
const DECODE_PHP = "PHP"

View File

@ -24,6 +24,7 @@ var (
gzipConv GZipConvert
deflateConv DeflateConvert
zstdConv ZStdConvert
lz4Conv LZ4Convert
brotliConv BrotliConvert
msgpackConv MsgpackConvert
phpConv = NewPhpConvert()
@ -44,6 +45,7 @@ var BuildInDecoders = map[string]DataConvert{
types.DECODE_GZIP: gzipConv,
types.DECODE_DEFLATE: deflateConv,
types.DECODE_ZSTD: zstdConv,
types.DECODE_LZ4: lz4Conv,
types.DECODE_BROTLI: brotliConv,
types.DECODE_MSGPACK: msgpackConv,
types.DECODE_PHP: phpConv,
@ -138,6 +140,11 @@ func autoDecode(str string, customDecoder []CmdConvert) (value, resultDecode str
return
}
if value, ok = lz4Conv.Decode(str); ok {
resultDecode = types.DECODE_LZ4
return
}
// FIXME: skip decompress with brotli due to incorrect format checking
//if value, ok = decodeBrotli(str); ok {
// resultDecode = types.DECODE_BROTLI

View File

@ -0,0 +1,39 @@
package convutil
import (
"bytes"
"github.com/pierrec/lz4/v4"
"io"
)
type LZ4Convert struct{}
func (LZ4Convert) Enable() bool {
return true
}
func (LZ4Convert) Encode(str string) (string, bool) {
var compress = func(b []byte) (string, error) {
var buf bytes.Buffer
writer := lz4.NewWriter(&buf)
if _, err := writer.Write([]byte(str)); err != nil {
writer.Close()
return "", err
}
writer.Close()
return string(buf.Bytes()), nil
}
if gzipStr, err := compress([]byte(str)); err == nil {
return gzipStr, true
}
return str, false
}
func (LZ4Convert) Decode(str string) (string, bool) {
reader := lz4.NewReader(bytes.NewReader([]byte(str)))
if decompressed, err := io.ReadAll(reader); err == nil {
return string(decompressed), true
}
return str, false
}

View File

@ -13,7 +13,7 @@ import ContentLogPane from './components/content/ContentLogPane.vue'
import ContentValueTab from '@/components/content/ContentValueTab.vue'
import ToolbarControlWidget from '@/components/common/ToolbarControlWidget.vue'
import { EventsOn, WindowIsFullscreen, WindowIsMaximised, WindowToggleMaximise } from 'wailsjs/runtime/runtime.js'
import { isMacOS } from '@/utils/platform.js'
import { isMacOS, isWindows } from '@/utils/platform.js'
import iconUrl from '@/assets/images/icon.png'
import ResizeableWrapper from '@/components/common/ResizeableWrapper.vue'
import { extraTheme } from '@/utils/extra_theme.js'
@ -57,6 +57,9 @@ const logoPaddingLeft = ref(10)
const maximised = ref(false)
const hideRadius = ref(false)
const wrapperStyle = computed(() => {
if (isWindows()) {
return {}
}
return hideRadius.value
? {}
: {
@ -65,6 +68,11 @@ const wrapperStyle = computed(() => {
}
})
const spinStyle = computed(() => {
if (isWindows()) {
return {
backgroundColor: themeVars.value.bodyColor,
}
}
return hideRadius.value
? {
backgroundColor: themeVars.value.bodyColor,

View File

@ -22,6 +22,7 @@ export const decodeTypes = {
GZIP: 'GZip',
DEFLATE: 'Deflate',
ZSTD: 'ZStd',
LZ4: 'LZ4',
BROTLI: 'Brotli',
MSGPACK: 'Msgpack',
PHP: 'PHP',

View File

@ -10,3 +10,7 @@ export async function loadEnvironment() {
export function isMacOS() {
return os === 'darwin'
}
export function isWindows() {
return os === 'windows'
}

1
go.mod
View File

@ -7,6 +7,7 @@ require (
github.com/andybalholm/brotli v1.1.0
github.com/google/uuid v1.6.0
github.com/klauspost/compress v1.17.9
github.com/pierrec/lz4/v4 v4.1.21
github.com/redis/go-redis/v9 v9.6.1
github.com/vmihailenco/msgpack/v5 v5.4.1
github.com/vrischmann/userdir v0.0.0-20151206171402-20f291cebd68

2
go.sum
View File

@ -60,6 +60,8 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=

View File

@ -114,7 +114,7 @@ func main() {
Windows: &windows.Options{
WebviewIsTransparent: true,
WindowIsTranslucent: true,
DisableFramelessWindowDecorations: true,
DisableFramelessWindowDecorations: false,
},
Linux: &linux.Options{
ProgramName: "Tiny RDM",