Compare commits
3 Commits
d61eb1323f
...
77541ed371
Author | SHA1 | Date |
---|---|---|
tiny-craft | 77541ed371 | |
tiny-craft | e2a371ed14 | |
tiny-craft | 72144bc996 |
|
@ -4,3 +4,5 @@ const DEFAULT_FONT_SIZE = 14
|
|||
const DEFAULT_ASIDE_WIDTH = 300
|
||||
const DEFAULT_WINDOW_WIDTH = 1024
|
||||
const DEFAULT_WINDOW_HEIGHT = 768
|
||||
const MIN_WINDOW_WIDTH = 960
|
||||
const MIN_WINDOW_HEIGHT = 640
|
||||
|
|
|
@ -1343,22 +1343,36 @@ func (c *connectionService) DeleteKey(connName string, db int, k any, async bool
|
|||
// delete by prefix
|
||||
var mutex sync.Mutex
|
||||
del := func(ctx context.Context, cli redis.UniversalClient) error {
|
||||
iter := cli.Scan(ctx, 0, key, 10000).Iterator()
|
||||
var fn func(c context.Context, ks ...string) *redis.IntCmd
|
||||
handleDel := func(ks []string) error {
|
||||
pipe := cli.Pipeline()
|
||||
for _, k2 := range ks {
|
||||
if async {
|
||||
fn = cli.Unlink
|
||||
cli.Unlink(ctx, k2)
|
||||
} else {
|
||||
fn = cli.Del
|
||||
cli.Del(ctx, k2)
|
||||
}
|
||||
for iter.Next(ctx) {
|
||||
subKey := iter.Val()
|
||||
if err = fn(ctx, subKey).Err(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
}
|
||||
pipe.Exec(ctx)
|
||||
|
||||
mutex.Lock()
|
||||
deletedKeys = append(deletedKeys, subKey)
|
||||
deletedKeys = append(deletedKeys, ks...)
|
||||
mutex.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
iter := cli.Scan(ctx, 0, key, 10000).Iterator()
|
||||
resultKeys := make([]string, 0, 100)
|
||||
for iter.Next(ctx) {
|
||||
resultKeys = append(resultKeys, iter.Val())
|
||||
if len(resultKeys) >= 3 {
|
||||
handleDel(resultKeys)
|
||||
resultKeys = resultKeys[:0:cap(resultKeys)]
|
||||
}
|
||||
}
|
||||
|
||||
if len(resultKeys) > 0 {
|
||||
handleDel(resultKeys)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ func (p *preferencesService) GetAppVersion() (resp types.JSResp) {
|
|||
}
|
||||
|
||||
func (p *preferencesService) SaveWindowSize(width, height int) {
|
||||
if width >= consts.DEFAULT_WINDOW_WIDTH && height >= consts.DEFAULT_WINDOW_HEIGHT {
|
||||
if width >= consts.MIN_WINDOW_WIDTH && height >= consts.MIN_WINDOW_HEIGHT {
|
||||
p.UpdatePreferences(map[string]any{
|
||||
"behavior.windowWidth": width,
|
||||
"behavior.windowHeight": height,
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"log"
|
||||
"sync"
|
||||
"time"
|
||||
"tinyrdm/backend/consts"
|
||||
"tinyrdm/backend/types"
|
||||
)
|
||||
|
||||
|
@ -28,6 +29,18 @@ func System() *systemService {
|
|||
|
||||
func (s *systemService) Start(ctx context.Context) {
|
||||
s.ctx = ctx
|
||||
|
||||
// maximize the window if screen size is lower than the minimum window size
|
||||
if screen, err := runtime.ScreenGetAll(ctx); err == nil && len(screen) > 0 {
|
||||
for _, sc := range screen {
|
||||
if sc.IsCurrent {
|
||||
if sc.Size.Width < consts.MIN_WINDOW_WIDTH || sc.Size.Height < consts.MIN_WINDOW_HEIGHT {
|
||||
runtime.WindowMaximise(ctx)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SelectFile open file dialog to select a file
|
||||
|
|
|
@ -47,8 +47,8 @@ func (p *PreferencesStorage) GetPreferences() (ret types.Preferences) {
|
|||
|
||||
ret = p.getPreferences()
|
||||
ret.Behavior.AsideWidth = max(ret.Behavior.AsideWidth, consts.DEFAULT_ASIDE_WIDTH)
|
||||
ret.Behavior.WindowWidth = max(ret.Behavior.WindowWidth, consts.DEFAULT_WINDOW_WIDTH)
|
||||
ret.Behavior.WindowHeight = max(ret.Behavior.WindowHeight, consts.DEFAULT_WINDOW_HEIGHT)
|
||||
ret.Behavior.WindowWidth = max(ret.Behavior.WindowWidth, consts.MIN_WINDOW_WIDTH)
|
||||
ret.Behavior.WindowHeight = max(ret.Behavior.WindowHeight, consts.MIN_WINDOW_HEIGHT)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -529,7 +529,7 @@ const getValueMenu = () => {
|
|||
|
||||
// render menu function icon
|
||||
const renderSuffix = ({ option }) => {
|
||||
if (includes(selectedKeys.value, option.key)) {
|
||||
if ((option.type === ConnectionType.RedisDB && option.opened) || includes(selectedKeys.value, option.key)) {
|
||||
switch (option.type) {
|
||||
case ConnectionType.RedisDB:
|
||||
return renderIconMenu(getDatabaseMenu(option.opened))
|
||||
|
|
4
main.go
4
main.go
|
@ -44,8 +44,8 @@ func main() {
|
|||
Title: "Tiny RDM",
|
||||
Width: windowWidth,
|
||||
Height: windowHeight,
|
||||
MinWidth: consts.DEFAULT_WINDOW_WIDTH,
|
||||
MinHeight: consts.DEFAULT_WINDOW_HEIGHT,
|
||||
MinWidth: consts.MIN_WINDOW_WIDTH,
|
||||
MinHeight: consts.MIN_WINDOW_HEIGHT,
|
||||
Frameless: runtime.GOOS != "darwin",
|
||||
Menu: appMenu,
|
||||
AssetServer: &assetserver.Options{
|
||||
|
|
Loading…
Reference in New Issue