Compare commits
8 Commits
3c7003291c
...
edaef2a78c
Author | SHA1 | Date |
---|---|---|
Lykin | edaef2a78c | |
Lykin | d75635bf70 | |
Lykin | 0b37b89f9b | |
Lykin | cdac3c4496 | |
Lykin | 655cd539ca | |
Lykin | 76783c36fb | |
Lykin | 4cbc0b98e7 | |
Lykin | a679858478 |
|
@ -2093,40 +2093,33 @@ func (b *browserService) DeleteKeys(server string, db int, ks []any, serialNo st
|
|||
defer cancelFunc()
|
||||
|
||||
cancelEvent := "delete:stop:" + serialNo
|
||||
runtime.EventsOnce(ctx, cancelEvent, func(data ...any) {
|
||||
cancelStopEvent := runtime.EventsOnce(ctx, cancelEvent, func(data ...any) {
|
||||
cancelFunc()
|
||||
})
|
||||
processEvent := "deleting:" + serialNo
|
||||
total := len(ks)
|
||||
var failed atomic.Int64
|
||||
var canceled bool
|
||||
var deletedKeys = make([]any, 0, total)
|
||||
var mutex sync.Mutex
|
||||
del := func(ctx context.Context, cli redis.UniversalClient) error {
|
||||
startTime := time.Now().Add(-10 * time.Second)
|
||||
for i, k := range ks {
|
||||
// emit progress per second
|
||||
if i >= total-1 || time.Now().Sub(startTime).Milliseconds() > 100 {
|
||||
startTime = time.Now()
|
||||
param := map[string]any{
|
||||
"total": total,
|
||||
"progress": i + 1,
|
||||
"processing": k,
|
||||
const batchSize = 1000
|
||||
for i := 0; i < total; i += batchSize {
|
||||
pipe := cli.Pipeline()
|
||||
for j := 0; j < batchSize; j++ {
|
||||
if i+j < total {
|
||||
pipe.Del(ctx, strutil.DecodeRedisKey(ks[i+j]))
|
||||
}
|
||||
runtime.EventsEmit(b.ctx, processEvent, param)
|
||||
// do some sleep to prevent blocking the Redis server
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
|
||||
key := strutil.DecodeRedisKey(k)
|
||||
delErr := cli.Del(ctx, key).Err()
|
||||
if err != nil {
|
||||
failed.Add(1)
|
||||
} else {
|
||||
// save deleted key
|
||||
mutex.Lock()
|
||||
deletedKeys = append(deletedKeys, k)
|
||||
mutex.Unlock()
|
||||
cmders, delErr := pipe.Exec(ctx)
|
||||
for j, cmder := range cmders {
|
||||
if cmder.(*redis.IntCmd).Val() != 1 {
|
||||
failed.Add(1)
|
||||
} else {
|
||||
// save deleted key
|
||||
mutex.Lock()
|
||||
deletedKeys = append(deletedKeys, ks[i+j])
|
||||
mutex.Unlock()
|
||||
}
|
||||
}
|
||||
if errors.Is(delErr, context.Canceled) || canceled {
|
||||
canceled = true
|
||||
|
@ -2145,7 +2138,7 @@ func (b *browserService) DeleteKeys(server string, db int, ks []any, serialNo st
|
|||
err = del(ctx, client)
|
||||
}
|
||||
|
||||
runtime.EventsOff(ctx, cancelEvent)
|
||||
cancelStopEvent()
|
||||
resp.Success = true
|
||||
resp.Data = struct {
|
||||
Canceled bool `json:"canceled"`
|
||||
|
@ -2189,8 +2182,7 @@ func (b *browserService) ExportKey(server string, db int, ks []any, path string,
|
|||
writer := csv.NewWriter(file)
|
||||
defer writer.Flush()
|
||||
|
||||
cancelEvent := "export:stop:" + path
|
||||
runtime.EventsOnce(ctx, cancelEvent, func(data ...any) {
|
||||
cancelStopEvent := runtime.EventsOnce(ctx, "export:stop:"+path, func(data ...any) {
|
||||
cancelFunc()
|
||||
})
|
||||
processEvent := "exporting:" + path
|
||||
|
@ -2206,7 +2198,7 @@ func (b *browserService) ExportKey(server string, db int, ks []any, path string,
|
|||
"progress": i + 1,
|
||||
"processing": k,
|
||||
}
|
||||
runtime.EventsEmit(b.ctx, processEvent, param)
|
||||
runtime.EventsEmit(ctx, processEvent, param)
|
||||
}
|
||||
|
||||
key := strutil.DecodeRedisKey(k)
|
||||
|
@ -2230,7 +2222,7 @@ func (b *browserService) ExportKey(server string, db int, ks []any, path string,
|
|||
}
|
||||
}
|
||||
|
||||
runtime.EventsOff(ctx, cancelEvent)
|
||||
cancelStopEvent()
|
||||
resp.Success = true
|
||||
resp.Data = struct {
|
||||
Canceled bool `json:"canceled"`
|
||||
|
@ -2274,7 +2266,7 @@ func (b *browserService) ImportCSV(server string, db int, path string, conflict
|
|||
reader := csv.NewReader(file)
|
||||
|
||||
cancelEvent := "import:stop:" + path
|
||||
runtime.EventsOnce(ctx, cancelEvent, func(data ...any) {
|
||||
cancelStopEvent := runtime.EventsOnce(ctx, cancelEvent, func(data ...any) {
|
||||
cancelFunc()
|
||||
})
|
||||
processEvent := "importing:" + path
|
||||
|
@ -2349,7 +2341,7 @@ func (b *browserService) ImportCSV(server string, db int, path string, conflict
|
|||
}
|
||||
}
|
||||
|
||||
runtime.EventsOff(ctx, cancelEvent)
|
||||
cancelStopEvent()
|
||||
resp.Success = true
|
||||
resp.Data = struct {
|
||||
Canceled bool `json:"canceled"`
|
||||
|
|
|
@ -6,6 +6,7 @@ type Preferences struct {
|
|||
Behavior PreferencesBehavior `json:"behavior" yaml:"behavior"`
|
||||
General PreferencesGeneral `json:"general" yaml:"general"`
|
||||
Editor PreferencesEditor `json:"editor" yaml:"editor"`
|
||||
Cli PreferencesCli `json:"cli" yaml:"cli"`
|
||||
}
|
||||
|
||||
func NewPreferences() Preferences {
|
||||
|
@ -28,6 +29,10 @@ func NewPreferences() Preferences {
|
|||
ShowLineNum: true,
|
||||
ShowFolding: true,
|
||||
},
|
||||
Cli: PreferencesCli{
|
||||
FontSize: consts.DEFAULT_FONT_SIZE,
|
||||
CursorStyle: "block",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,21 +46,29 @@ type PreferencesBehavior struct {
|
|||
}
|
||||
|
||||
type PreferencesGeneral struct {
|
||||
Theme string `json:"theme" yaml:"theme"`
|
||||
Language string `json:"language" yaml:"language"`
|
||||
Font string `json:"font" yaml:"font,omitempty"`
|
||||
FontSize int `json:"fontSize" yaml:"font_size"`
|
||||
ScanSize int `json:"scanSize" yaml:"scan_size"`
|
||||
KeyIconStyle int `json:"keyIconStyle" yaml:"key_icon_style"`
|
||||
UseSysProxy bool `json:"useSysProxy" yaml:"use_sys_proxy,omitempty"`
|
||||
UseSysProxyHttp bool `json:"useSysProxyHttp" yaml:"use_sys_proxy_http,omitempty"`
|
||||
CheckUpdate bool `json:"checkUpdate" yaml:"check_update"`
|
||||
SkipVersion string `json:"skipVersion" yaml:"skip_version,omitempty"`
|
||||
Theme string `json:"theme" yaml:"theme"`
|
||||
Language string `json:"language" yaml:"language"`
|
||||
Font string `json:"font" yaml:"font,omitempty"`
|
||||
FontFamily []string `json:"fontFamily" yaml:"font_family,omitempty"`
|
||||
FontSize int `json:"fontSize" yaml:"font_size"`
|
||||
ScanSize int `json:"scanSize" yaml:"scan_size"`
|
||||
KeyIconStyle int `json:"keyIconStyle" yaml:"key_icon_style"`
|
||||
UseSysProxy bool `json:"useSysProxy" yaml:"use_sys_proxy,omitempty"`
|
||||
UseSysProxyHttp bool `json:"useSysProxyHttp" yaml:"use_sys_proxy_http,omitempty"`
|
||||
CheckUpdate bool `json:"checkUpdate" yaml:"check_update"`
|
||||
SkipVersion string `json:"skipVersion" yaml:"skip_version,omitempty"`
|
||||
}
|
||||
|
||||
type PreferencesEditor struct {
|
||||
Font string `json:"font" yaml:"font,omitempty"`
|
||||
FontSize int `json:"fontSize" yaml:"font_size"`
|
||||
ShowLineNum bool `json:"showLineNum" yaml:"show_line_num"`
|
||||
ShowFolding bool `json:"showFolding" yaml:"show_folding"`
|
||||
Font string `json:"font" yaml:"font,omitempty"`
|
||||
FontFamily []string `json:"fontFamily" yaml:"font_family,omitempty"`
|
||||
FontSize int `json:"fontSize" yaml:"font_size"`
|
||||
ShowLineNum bool `json:"showLineNum" yaml:"show_line_num"`
|
||||
ShowFolding bool `json:"showFolding" yaml:"show_folding"`
|
||||
}
|
||||
|
||||
type PreferencesCli struct {
|
||||
FontFamily []string `json:"fontFamily" yaml:"font_family,omitempty"`
|
||||
FontSize int `json:"fontSize" yaml:"font_size"`
|
||||
CursorStyle string `json:"cursorStyle" yaml:"cursor_style,omitempty"`
|
||||
}
|
||||
|
|
|
@ -32,9 +32,12 @@ let fitAddonInst = null
|
|||
* @return {{fitAddon: xterm-addon-fit.FitAddon, term: Terminal}}
|
||||
*/
|
||||
const newTerm = () => {
|
||||
const { fontSize = 14, fontFamily = 'Courier New' } = prefStore.cliFont
|
||||
const term = new Terminal({
|
||||
allowProposedApi: true,
|
||||
fontSize: prefStore.general.fontSize || 14,
|
||||
fontFamily,
|
||||
fontSize,
|
||||
cursorStyle: prefStore.cli.cursorStyle || 'block',
|
||||
cursorBlink: true,
|
||||
disableStdin: false,
|
||||
screenReaderMode: true,
|
||||
|
@ -90,10 +93,21 @@ defineExpose({
|
|||
})
|
||||
|
||||
watch(
|
||||
() => prefStore.general.fontSize,
|
||||
(fontSize) => {
|
||||
() => prefStore.cliFont,
|
||||
({ fontSize = 14, fontFamily = 'Courier New' }) => {
|
||||
if (termInst != null) {
|
||||
termInst.options.fontSize = fontSize
|
||||
termInst.options.fontFamily = fontFamily
|
||||
}
|
||||
resizeTerm()
|
||||
},
|
||||
)
|
||||
|
||||
watch(
|
||||
() => prefStore.cli.cursorStyle,
|
||||
(style) => {
|
||||
if (termInst != null) {
|
||||
termInst.options.cursorStyle = style || 'block'
|
||||
}
|
||||
resizeTerm()
|
||||
},
|
||||
|
|
|
@ -58,7 +58,7 @@ const readonlyValue = computed(() => {
|
|||
const pref = usePreferencesStore()
|
||||
onMounted(async () => {
|
||||
if (editorRef.value != null) {
|
||||
const { fontSize, fontFamily = undefined } = pref.editorFont
|
||||
const { fontSize, fontFamily = ['monaco'] } = pref.editorFont
|
||||
editorNode = monaco.editor.create(editorRef.value, {
|
||||
// value: props.content,
|
||||
theme: pref.isDark ? 'rdm-dark' : 'rdm-light',
|
||||
|
@ -151,21 +151,11 @@ watch(
|
|||
)
|
||||
|
||||
watch(
|
||||
() => pref.editorFont.fontSize,
|
||||
(fontSize) => {
|
||||
() => pref.editorFont,
|
||||
({ fontSize, fontFamily }) => {
|
||||
if (editorNode != null) {
|
||||
editorNode.updateOptions({
|
||||
fontSize,
|
||||
})
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
watch(
|
||||
() => pref.editorFont.fontFamily,
|
||||
(fontFamily = undefined) => {
|
||||
if (editorNode != null) {
|
||||
editorNode.updateOptions({
|
||||
fontFamily,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ onMounted(() => {
|
|||
pageState.refreshInterval = interval === 0 ? 5 : interval
|
||||
onToggleRefresh(true)
|
||||
} else {
|
||||
setTimeout(refreshInfo, 5000)
|
||||
setTimeout(refreshInfo, 3000)
|
||||
// setTimeout(_mockChart, 1000)
|
||||
}
|
||||
refreshInfo()
|
||||
|
|
|
@ -115,11 +115,9 @@ const onClose = () => {
|
|||
required>
|
||||
<n-input v-model:value="deleteForm.key" placeholder="" @input="resetAffected" />
|
||||
</n-form-item>
|
||||
<!-- <n-form-item :label="$t('dialogue.key.async_delete')" required>-->
|
||||
<!-- <n-checkbox v-model:checked="deleteForm.async">-->
|
||||
<!-- {{ $t('dialogue.key.async_delete_title') }}-->
|
||||
<!-- </n-checkbox>-->
|
||||
<!-- </n-form-item>-->
|
||||
<!-- <n-checkbox v-model:checked="deleteForm.async">-->
|
||||
<!-- {{ $t('dialogue.key.silent') }}-->
|
||||
<!-- </n-checkbox>-->
|
||||
<n-card
|
||||
v-if="deleteForm.showAffected"
|
||||
:title="$t('dialogue.key.affected_key') + `(${size(deleteForm.affectedKeys)})`"
|
||||
|
|
|
@ -5,6 +5,7 @@ import useDialog from 'stores/dialog'
|
|||
import usePreferencesStore from 'stores/preferences.js'
|
||||
import { map, sortBy } from 'lodash'
|
||||
import { typesIconStyle } from '@/consts/support_redis_type.js'
|
||||
import Help from '@/components/icons/Help.vue'
|
||||
|
||||
const prefStore = usePreferencesStore()
|
||||
|
||||
|
@ -92,14 +93,27 @@ const onClose = () => {
|
|||
:render-label="({ label, value }) => (value === 'auto' ? $t(label) : label)"
|
||||
filterable />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="$t('preferences.general.font')" :span="12" required>
|
||||
<n-form-item-gi :span="24" required>
|
||||
<template #label>
|
||||
{{ $t('preferences.general.font') }}
|
||||
<n-tooltip trigger="hover">
|
||||
<template #trigger>
|
||||
<n-icon :component="Help" />
|
||||
</template>
|
||||
<div class="text-block">
|
||||
{{ $t('preferences.font_tip') }}
|
||||
</div>
|
||||
</n-tooltip>
|
||||
</template>
|
||||
<n-select
|
||||
v-model:value="prefStore.general.font"
|
||||
v-model:value="prefStore.general.fontFamily"
|
||||
:options="prefStore.fontOption"
|
||||
:render-label="({ label, value }) => (value === '' ? $t(label) : label)"
|
||||
filterable />
|
||||
filterable
|
||||
multiple
|
||||
tag />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="$t('preferences.general.font_size')" :span="12">
|
||||
<n-form-item-gi :label="$t('preferences.general.font_size')" :span="24">
|
||||
<n-input-number v-model:value="prefStore.general.fontSize" :max="65535" :min="1" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="$t('preferences.general.scan_size')" :span="12">
|
||||
|
@ -115,16 +129,16 @@ const onClose = () => {
|
|||
:options="keyOptions"
|
||||
:render-label="({ label }) => $t(label)" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="$t('preferences.general.proxy')" :span="24">
|
||||
<n-space>
|
||||
<n-checkbox v-model:checked="prefStore.general.useSysProxy">
|
||||
{{ $t('preferences.general.use_system_proxy') }}
|
||||
</n-checkbox>
|
||||
<n-checkbox v-model:checked="prefStore.general.useSysProxyHttp">
|
||||
{{ $t('preferences.general.use_system_proxy_http') }}
|
||||
</n-checkbox>
|
||||
</n-space>
|
||||
</n-form-item-gi>
|
||||
<!-- <n-form-item-gi :label="$t('preferences.general.proxy')" :span="24">-->
|
||||
<!-- <n-space>-->
|
||||
<!-- <n-checkbox v-model:checked="prefStore.general.useSysProxy">-->
|
||||
<!-- {{ $t('preferences.general.use_system_proxy') }}-->
|
||||
<!-- </n-checkbox>-->
|
||||
<!-- <n-checkbox v-model:checked="prefStore.general.useSysProxyHttp">-->
|
||||
<!-- {{ $t('preferences.general.use_system_proxy_http') }}-->
|
||||
<!-- </n-checkbox>-->
|
||||
<!-- </n-space>-->
|
||||
<!-- </n-form-item-gi>-->
|
||||
<n-form-item-gi :label="$t('preferences.general.update')" :span="24">
|
||||
<n-checkbox v-model:checked="prefStore.general.checkUpdate">
|
||||
{{ $t('preferences.general.auto_check_update') }}
|
||||
|
@ -137,14 +151,27 @@ const onClose = () => {
|
|||
<n-tab-pane :tab="$t('preferences.editor.name')" display-directive="show" name="editor">
|
||||
<n-form :disabled="loading" :model="prefStore.editor" :show-require-mark="false" label-placement="top">
|
||||
<n-grid :x-gap="10">
|
||||
<n-form-item-gi :label="$t('preferences.general.font')" :span="12" required>
|
||||
<n-form-item-gi :span="24" required>
|
||||
<template #label>
|
||||
{{ $t('preferences.general.font') }}
|
||||
<n-tooltip trigger="hover">
|
||||
<template #trigger>
|
||||
<n-icon :component="Help" />
|
||||
</template>
|
||||
<div class="text-block">
|
||||
{{ $t('preferences.font_tip') }}
|
||||
</div>
|
||||
</n-tooltip>
|
||||
</template>
|
||||
<n-select
|
||||
v-model:value="prefStore.editor.font"
|
||||
v-model:value="prefStore.editor.fontFamily"
|
||||
:options="prefStore.fontOption"
|
||||
:render-label="({ label, value }) => value || $t(label)"
|
||||
filterable />
|
||||
filterable
|
||||
multiple
|
||||
tag />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="$t('preferences.general.font_size')" :span="12">
|
||||
<n-form-item-gi :label="$t('preferences.general.font_size')" :span="24">
|
||||
<n-input-number v-model:value="prefStore.editor.fontSize" :max="65535" :min="1" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :show-feedback="false" :show-label="false" :span="24">
|
||||
|
@ -160,6 +187,46 @@ const onClose = () => {
|
|||
</n-grid>
|
||||
</n-form>
|
||||
</n-tab-pane>
|
||||
|
||||
<n-tab-pane :tab="$t('preferences.cli.name')" display-directive="show" name="cli">
|
||||
<n-form :disabled="loading" :model="prefStore.cli" :show-require-mark="false" label-placement="top">
|
||||
<n-grid :x-gap="10">
|
||||
<n-form-item-gi :span="24" required>
|
||||
<template #label>
|
||||
{{ $t('preferences.general.font') }}
|
||||
<n-tooltip trigger="hover">
|
||||
<template #trigger>
|
||||
<n-icon :component="Help" />
|
||||
</template>
|
||||
<div class="text-block">
|
||||
{{ $t('preferences.font_tip') }}
|
||||
</div>
|
||||
</n-tooltip>
|
||||
</template>
|
||||
<n-select
|
||||
v-model:value="prefStore.cli.fontFamily"
|
||||
:options="prefStore.fontOption"
|
||||
:render-label="({ label, value }) => value || $t(label)"
|
||||
filterable
|
||||
multiple
|
||||
tag />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="$t('preferences.general.font_size')" :span="24">
|
||||
<n-input-number v-model:value="prefStore.cli.fontSize" :max="65535" :min="1" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="$t('preferences.cli.cursor_style')" :span="24">
|
||||
<n-radio-group v-model:value="prefStore.cli.cursorStyle" name="theme" size="medium">
|
||||
<n-radio-button
|
||||
v-for="opt in prefStore.cliCursorStyleOption"
|
||||
:key="opt.value"
|
||||
:value="opt.value">
|
||||
{{ $t(opt.label) }}
|
||||
</n-radio-button>
|
||||
</n-radio-group>
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
</n-form>
|
||||
</n-tab-pane>
|
||||
</n-tabs>
|
||||
<!-- </n-spin> -->
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
<script setup>
|
||||
const props = defineProps({
|
||||
inverse: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
strokeWidth: {
|
||||
type: [Number, String],
|
||||
default: 3,
|
||||
|
@ -10,9 +14,9 @@ const props = defineProps({
|
|||
<template>
|
||||
<svg fill="none" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
:fill="props.inverse ? 'currentColor' : 'none'"
|
||||
:stroke-width="props.strokeWidth"
|
||||
d="M24 28.6292C26.5104 28.6292 28.5455 26.6004 28.5455 24.0979C28.5455 21.5954 26.5104 19.5667 24 19.5667C21.4897 19.5667 19.4546 21.5954 19.4546 24.0979C19.4546 26.6004 21.4897 28.6292 24 28.6292Z"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-linejoin="round" />
|
||||
<path
|
||||
|
|
|
@ -46,15 +46,15 @@ const onSelectOptions = async (select) => {
|
|||
<icon-button
|
||||
:button-class="['nav-pane-func-btn']"
|
||||
:icon="AddLink"
|
||||
size="20"
|
||||
:stroke-width="3.5"
|
||||
size="20"
|
||||
t-tooltip="interface.new_conn"
|
||||
@click="dialogStore.openNewDialog()" />
|
||||
<icon-button
|
||||
:button-class="['nav-pane-func-btn']"
|
||||
:icon="AddGroup"
|
||||
size="20"
|
||||
:stroke-width="3.5"
|
||||
size="20"
|
||||
t-tooltip="interface.new_group"
|
||||
@click="dialogStore.openNewGroupDialog()" />
|
||||
<n-divider vertical />
|
||||
|
|
|
@ -152,8 +152,8 @@ const exThemeVars = computed(() => {
|
|||
:options="preferencesOptions"
|
||||
:render-icon="({ icon }) => render.renderIcon(icon)"
|
||||
:render-label="({ label }) => render.renderLabel($t(label), { class: 'context-menu-item' })"
|
||||
trigger="click"
|
||||
content-class="nav-menu-button"
|
||||
trigger="click"
|
||||
@select="onSelectPreferenceMenu">
|
||||
<icon-button :icon="Config" :size="iconSize" :stroke-width="3" />
|
||||
</n-dropdown>
|
||||
|
@ -161,8 +161,8 @@ const exThemeVars = computed(() => {
|
|||
v-if="prefStore.currentLanguage === 'zh'"
|
||||
:icon="QRCode"
|
||||
:size="iconSize"
|
||||
t-tooltip="ribbon.wechat_official"
|
||||
class="nav-menu-button"
|
||||
t-tooltip="ribbon.wechat_official"
|
||||
@click="showWechat = true" />
|
||||
<icon-button
|
||||
v-else
|
||||
|
@ -176,8 +176,8 @@ const exThemeVars = computed(() => {
|
|||
<icon-button
|
||||
:icon="Github"
|
||||
:size="iconSize"
|
||||
t-tooltip="ribbon.github"
|
||||
class="nav-menu-button"
|
||||
t-tooltip="ribbon.github"
|
||||
@click="openGithub" />
|
||||
</div>
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
"preferences": {
|
||||
"name": "Preferences",
|
||||
"restore_defaults": "Restore Defaults",
|
||||
"font_tip": "Supports multiple selection. You can manually input the font name if it is not list below.",
|
||||
"general": {
|
||||
"name": "General",
|
||||
"theme": "Theme",
|
||||
|
@ -35,7 +36,6 @@
|
|||
"theme_auto": "Auto",
|
||||
"language": "Language",
|
||||
"system_lang": "Use System Language",
|
||||
"default": "Default",
|
||||
"font": "Font",
|
||||
"font_size": "Font Size",
|
||||
"scan_size": "Default Size for SCAN Command",
|
||||
|
@ -54,6 +54,13 @@
|
|||
"name": "Editor",
|
||||
"show_linenum": "Show Line Numbers",
|
||||
"show_folding": "Enable Code Folding"
|
||||
},
|
||||
"cli": {
|
||||
"name": "Command Line",
|
||||
"cursor_style": "Cursor Style",
|
||||
"cursor_style_block": "Block",
|
||||
"cursor_style_underline": "Underline",
|
||||
"cursor_style_bar": "Bar"
|
||||
}
|
||||
},
|
||||
"interface": {
|
||||
|
@ -268,6 +275,7 @@
|
|||
},
|
||||
"delete": {
|
||||
"success": "\"{key}\" has been deleted",
|
||||
"deleting": "Deleting",
|
||||
"doing": "Deleting key({index}/{count})",
|
||||
"completed": "Deletion process has been completed, {success} successed, {fail} failed"
|
||||
},
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
"theme_auto": "Automático",
|
||||
"language": "Idioma",
|
||||
"system_lang": "Usar Idioma do Sistema",
|
||||
"default": "Padrão",
|
||||
"font": "Fonte",
|
||||
"font_size": "Tamanho da Fonte",
|
||||
"scan_size": "Tamanho Padrão para Comando SCAN",
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
"preferences": {
|
||||
"name": "偏好设置",
|
||||
"restore_defaults": "重置为默认",
|
||||
"font_tip": "支持多选,如列表没有已安装的字体,可自行手动输入",
|
||||
"general": {
|
||||
"name": "常规配置",
|
||||
"theme": "主题",
|
||||
|
@ -35,7 +36,6 @@
|
|||
"theme_auto": "自动",
|
||||
"language": "语言",
|
||||
"system_lang": "使用系统语言",
|
||||
"default": "默认",
|
||||
"font": "字体",
|
||||
"font_size": "字体尺寸",
|
||||
"scan_size": "SCAN命令默认数量",
|
||||
|
@ -54,6 +54,13 @@
|
|||
"name": "编辑器",
|
||||
"show_linenum": "显示行号",
|
||||
"show_folding": "启用代码折叠"
|
||||
},
|
||||
"cli": {
|
||||
"name": "命令行",
|
||||
"cursor_style": "光标样式",
|
||||
"cursor_style_block": "方块",
|
||||
"cursor_style_underline": "下划线",
|
||||
"cursor_style_bar": "竖线"
|
||||
}
|
||||
},
|
||||
"interface": {
|
||||
|
@ -268,6 +275,7 @@
|
|||
},
|
||||
"delete": {
|
||||
"success": "{key} 已被删除",
|
||||
"deleting": "正在删除",
|
||||
"doing": "正在删除键({index}/{count})",
|
||||
"completed": "已完成删除操作,成功{success}个,失败{fail}个"
|
||||
},
|
||||
|
|
|
@ -36,7 +36,7 @@ import {
|
|||
UpdateZSetValue,
|
||||
} from 'wailsjs/go/services/browserService.js'
|
||||
import useTabStore from 'stores/tab.js'
|
||||
import { decodeRedisKey, nativeRedisKey } from '@/utils/key_convert.js'
|
||||
import { nativeRedisKey } from '@/utils/key_convert.js'
|
||||
import { BrowserTabType } from '@/consts/browser_tab_type.js'
|
||||
import { KeyViewType } from '@/consts/key_view_type.js'
|
||||
import { ConnectionType } from '@/consts/connection_type.js'
|
||||
|
@ -44,7 +44,7 @@ import useConnectionStore from 'stores/connections.js'
|
|||
import { decodeTypes, formatTypes } from '@/consts/value_view_type.js'
|
||||
import { isRedisGlob } from '@/utils/glob_pattern.js'
|
||||
import { i18nGlobal } from '@/utils/i18n.js'
|
||||
import { EventsEmit, EventsOff, EventsOn } from 'wailsjs/runtime/runtime.js'
|
||||
import { EventsEmit, EventsOn } from 'wailsjs/runtime/runtime.js'
|
||||
import { RedisNodeItem } from '@/objects/redisNodeItem.js'
|
||||
import { RedisServerState } from '@/objects/redisServerState.js'
|
||||
import { RedisDatabaseItem } from '@/objects/redisDatabaseItem.js'
|
||||
|
@ -1568,7 +1568,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
// $message.error(i18nGlobal.t('dialogue.delete.completed', { success: deletedCount, fail: failCount }))
|
||||
// } else {
|
||||
// // some fail
|
||||
// $message.warn(i18nGlobal.t('dialogue.delete.completed', { success: deletedCount, fail: failCount }))
|
||||
// $message.warning(i18nGlobal.t('dialogue.delete.completed', { success: deletedCount, fail: failCount }))
|
||||
// }
|
||||
},
|
||||
|
||||
|
@ -1617,31 +1617,16 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @return {Promise<void>}
|
||||
*/
|
||||
async deleteKeys(server, db, keys) {
|
||||
const msgRef = $message.loading('', { duration: 0, closable: true })
|
||||
const msgRef = $message.loading(i18nGlobal.t('dialogue.delete.deleting'), { duration: 0, closable: true })
|
||||
let deleted = []
|
||||
let failCount = 0
|
||||
let canceled = false
|
||||
const serialNo = Date.now().valueOf().toString()
|
||||
const eventName = 'deleting:' + serialNo
|
||||
const cancelEvent = 'delete:stop:' + serialNo
|
||||
msgRef.onClose = () => {
|
||||
EventsEmit('delete:stop:' + serialNo)
|
||||
}
|
||||
try {
|
||||
let maxProgress = 0
|
||||
EventsOn(eventName, ({ total, progress, processing }) => {
|
||||
// update delete progress
|
||||
if (progress > maxProgress) {
|
||||
maxProgress = progress
|
||||
}
|
||||
const k = decodeRedisKey(processing)
|
||||
msgRef.content = i18nGlobal.t('dialogue.delete.doing', {
|
||||
key: k,
|
||||
index: maxProgress,
|
||||
count: total,
|
||||
})
|
||||
})
|
||||
msgRef.onClose = () => {
|
||||
EventsEmit(cancelEvent)
|
||||
}
|
||||
const { data, success, msg } = await DeleteKeys(server, db, keys, serialNo)
|
||||
const { success, msg, data } = await DeleteKeys(server, db, keys, serialNo)
|
||||
if (success) {
|
||||
canceled = get(data, 'canceled', false)
|
||||
deleted = get(data, 'deleted', [])
|
||||
|
@ -1651,7 +1636,6 @@ const useBrowserStore = defineStore('browser', {
|
|||
}
|
||||
} finally {
|
||||
msgRef.destroy()
|
||||
EventsOff(eventName)
|
||||
// clear checked keys
|
||||
const tab = useTabStore()
|
||||
tab.setCheckedKeys(server)
|
||||
|
@ -1668,7 +1652,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
$message.error(i18nGlobal.t('dialogue.delete.completed', { success: deletedCount, fail: failCount }))
|
||||
} else {
|
||||
// some fail
|
||||
$message.warn(i18nGlobal.t('dialogue.delete.completed', { success: deletedCount, fail: failCount }))
|
||||
$message.warning(i18nGlobal.t('dialogue.delete.completed', { success: deletedCount, fail: failCount }))
|
||||
}
|
||||
// update ui
|
||||
timeout(100).then(async () => {
|
||||
|
@ -1703,19 +1687,18 @@ const useBrowserStore = defineStore('browser', {
|
|||
let exported = 0
|
||||
let failCount = 0
|
||||
let canceled = false
|
||||
const eventName = 'exporting:' + path
|
||||
try {
|
||||
EventsOn(eventName, ({ total, progress, processing }) => {
|
||||
// update export progress
|
||||
msgRef.content = i18nGlobal.t('dialogue.export.exporting', {
|
||||
// key: decodeRedisKey(processing),
|
||||
index: progress,
|
||||
count: total,
|
||||
})
|
||||
const cancelEventFn = EventsOn('exporting:' + path, ({ total, progress, processing }) => {
|
||||
// update export progress
|
||||
msgRef.content = i18nGlobal.t('dialogue.export.exporting', {
|
||||
// key: decodeRedisKey(processing),
|
||||
index: progress,
|
||||
count: total,
|
||||
})
|
||||
msgRef.onClose = () => {
|
||||
EventsEmit('export:stop:' + path)
|
||||
}
|
||||
})
|
||||
msgRef.onClose = () => {
|
||||
EventsEmit('export:stop:' + path)
|
||||
}
|
||||
try {
|
||||
const { data, success, msg } = await ExportKey(server, db, keys, path, expire)
|
||||
if (success) {
|
||||
canceled = get(data, 'canceled', false)
|
||||
|
@ -1726,7 +1709,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
}
|
||||
} finally {
|
||||
msgRef.destroy()
|
||||
EventsOff(eventName)
|
||||
cancelEventFn()
|
||||
}
|
||||
if (canceled) {
|
||||
$message.info(i18nGlobal.t('dialogue.handle_cancel'))
|
||||
|
@ -1740,7 +1723,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
$message.error(i18nGlobal.t('dialogue.export.export_completed', { success: exported, fail: failCount }))
|
||||
} else {
|
||||
// some fail
|
||||
$message.warn(i18nGlobal.t('dialogue.export.export_completed', { success: exported, fail: failCount }))
|
||||
$message.warning(
|
||||
i18nGlobal.t('dialogue.export.export_completed', {
|
||||
success: exported,
|
||||
fail: failCount,
|
||||
}),
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1759,19 +1747,18 @@ const useBrowserStore = defineStore('browser', {
|
|||
let imported = 0
|
||||
let ignored = 0
|
||||
let canceled = false
|
||||
const eventName = 'importing:' + path
|
||||
try {
|
||||
EventsOn(eventName, ({ imported = 0, ignored = 0 }) => {
|
||||
// update export progress
|
||||
msgRef.content = i18nGlobal.t('dialogue.import.importing', {
|
||||
// key: decodeRedisKey(processing),
|
||||
imported,
|
||||
conflict: ignored,
|
||||
})
|
||||
const cancelEventFn = EventsOn('importing:' + path, ({ imported = 0, ignored = 0 }) => {
|
||||
// update export progress
|
||||
msgRef.content = i18nGlobal.t('dialogue.import.importing', {
|
||||
// key: decodeRedisKey(processing),
|
||||
imported,
|
||||
conflict: ignored,
|
||||
})
|
||||
msgRef.onClose = () => {
|
||||
EventsEmit('import:stop:' + path)
|
||||
}
|
||||
})
|
||||
msgRef.onClose = () => {
|
||||
EventsEmit('import:stop:' + path)
|
||||
}
|
||||
try {
|
||||
const { data, success, msg } = await ImportCSV(server, db, path, conflict, ttl)
|
||||
if (success) {
|
||||
canceled = get(data, 'canceled', false)
|
||||
|
@ -1781,8 +1768,8 @@ const useBrowserStore = defineStore('browser', {
|
|||
$message.error(msg)
|
||||
}
|
||||
} finally {
|
||||
cancelEventFn()
|
||||
msgRef.destroy()
|
||||
EventsOff(eventName)
|
||||
}
|
||||
if (canceled) {
|
||||
$message.info(i18nGlobal.t('dialogue.handle_cancel'))
|
||||
|
|
|
@ -105,7 +105,7 @@ const useConnectionStore = defineStore('connections', {
|
|||
defaultFilter: item.defaultFilter,
|
||||
keySeparator: item.keySeparator,
|
||||
markColor: item.markColor,
|
||||
refreshInterval: conn.refreshInterval,
|
||||
refreshInterval: item.refreshInterval,
|
||||
}
|
||||
}
|
||||
conns.push({
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { defineStore } from 'pinia'
|
||||
import { lang } from '@/langs/index.js'
|
||||
import { cloneDeep, find, get, isEmpty, map, pick, set, split } from 'lodash'
|
||||
import { cloneDeep, get, isEmpty, join, map, pick, set, split } from 'lodash'
|
||||
import {
|
||||
CheckForUpdate,
|
||||
GetFontList,
|
||||
|
@ -43,6 +43,7 @@ const usePreferencesStore = defineStore('preferences', {
|
|||
theme: 'auto',
|
||||
language: 'auto',
|
||||
font: '',
|
||||
fontFamily: [],
|
||||
fontSize: 14,
|
||||
scanSize: 3000,
|
||||
keyIconStyle: 0,
|
||||
|
@ -53,10 +54,16 @@ const usePreferencesStore = defineStore('preferences', {
|
|||
},
|
||||
editor: {
|
||||
font: '',
|
||||
fontFamily: [],
|
||||
fontSize: 14,
|
||||
showLineNum: true,
|
||||
showFolding: true,
|
||||
},
|
||||
cli: {
|
||||
fontFamily: [],
|
||||
fontSize: 14,
|
||||
cursorStyle: 'block',
|
||||
},
|
||||
lastPref: {},
|
||||
fontList: [],
|
||||
}),
|
||||
|
@ -103,17 +110,11 @@ const usePreferencesStore = defineStore('preferences', {
|
|||
* @returns {{path: string, label: string, value: string}[]}
|
||||
*/
|
||||
fontOption() {
|
||||
const option = map(this.fontList, (font) => ({
|
||||
return map(this.fontList, (font) => ({
|
||||
value: font.name,
|
||||
label: font.name,
|
||||
path: font.path,
|
||||
}))
|
||||
option.splice(0, 0, {
|
||||
value: '',
|
||||
label: 'preferences.general.default',
|
||||
path: '',
|
||||
})
|
||||
return option
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -124,12 +125,21 @@ const usePreferencesStore = defineStore('preferences', {
|
|||
const fontStyle = {
|
||||
fontSize: this.general.fontSize + 'px',
|
||||
}
|
||||
if (!isEmpty(this.general.font) && this.general.font !== 'none') {
|
||||
const font = find(this.fontList, { name: this.general.font })
|
||||
if (font != null) {
|
||||
fontStyle['fontFamily'] = `${font.name}`
|
||||
}
|
||||
if (!isEmpty(this.general.fontFamily)) {
|
||||
fontStyle['fontFamily'] = join(
|
||||
map(this.general.fontFamily, (f) => `"${f}"`),
|
||||
',',
|
||||
)
|
||||
}
|
||||
// compatible with old preferences
|
||||
// if (isEmpty(fontStyle['fontFamily'])) {
|
||||
// if (!isEmpty(this.general.font) && this.general.font !== 'none') {
|
||||
// const font = find(this.fontList, { name: this.general.font })
|
||||
// if (font != null) {
|
||||
// fontStyle['fontFamily'] = `${font.name}`
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return fontStyle
|
||||
},
|
||||
|
||||
|
@ -141,16 +151,64 @@ const usePreferencesStore = defineStore('preferences', {
|
|||
const fontStyle = {
|
||||
fontSize: (this.editor.fontSize || 14) + 'px',
|
||||
}
|
||||
if (!isEmpty(this.editor.font) && this.editor.font !== 'none') {
|
||||
const font = find(this.fontList, { name: this.editor.font })
|
||||
if (font != null) {
|
||||
fontStyle['fontFamily'] = `${font.name}`
|
||||
}
|
||||
if (!isEmpty(this.editor.fontFamily)) {
|
||||
fontStyle['fontFamily'] = join(
|
||||
map(this.editor.fontFamily, (f) => `"${f}"`),
|
||||
',',
|
||||
)
|
||||
}
|
||||
// compatible with old preferences
|
||||
// if (isEmpty(fontStyle['fontFamily'])) {
|
||||
// if (!isEmpty(this.editor.font) && this.editor.font !== 'none') {
|
||||
// const font = find(this.fontList, { name: this.editor.font })
|
||||
// if (font != null) {
|
||||
// fontStyle['fontFamily'] = `${font.name}`
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (isEmpty(fontStyle['fontFamily'])) {
|
||||
fontStyle['fontFamily'] = ['monaco']
|
||||
}
|
||||
fontStyle['fontFamily'] = fontStyle['fontFamily'] || 'monaco'
|
||||
return fontStyle
|
||||
},
|
||||
|
||||
/**
|
||||
* current cli font
|
||||
* @return {{fontSize: string, fontFamily?: string}}
|
||||
*/
|
||||
cliFont() {
|
||||
const fontStyle = {
|
||||
fontSize: this.cli.fontSize || 14,
|
||||
}
|
||||
if (!isEmpty(this.cli.fontFamily)) {
|
||||
fontStyle['fontFamily'] = join(
|
||||
map(this.cli.fontFamily, (f) => `"${f}"`),
|
||||
',',
|
||||
)
|
||||
}
|
||||
if (isEmpty(fontStyle['fontFamily'])) {
|
||||
fontStyle['fontFamily'] = ['Courier New']
|
||||
}
|
||||
return fontStyle
|
||||
},
|
||||
|
||||
cliCursorStyleOption() {
|
||||
return [
|
||||
{
|
||||
value: 'block',
|
||||
label: 'preferences.cli.cursor_style_block',
|
||||
},
|
||||
{
|
||||
value: 'underline',
|
||||
label: 'preferences.cli.cursor_style_underline',
|
||||
},
|
||||
{
|
||||
value: 'bar',
|
||||
label: 'preferences.cli.cursor_style_bar',
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
/**
|
||||
* get current language setting
|
||||
* @return {string}
|
||||
|
@ -248,7 +306,7 @@ const usePreferencesStore = defineStore('preferences', {
|
|||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
async savePreferences() {
|
||||
const pf = pick(this, ['behavior', 'general', 'editor'])
|
||||
const pf = pick(this, ['behavior', 'general', 'editor', 'cli'])
|
||||
const { success, msg } = await SetPreferences(pf)
|
||||
return success === true
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue