Compare commits

..

No commits in common. "3367f13d80d331c7ca8aecfff64ce80bae2db722" and "ccb4bb85ae9cc6745f604ed53ca8cbd206592601" have entirely different histories.

7 changed files with 35 additions and 39 deletions

View File

@ -876,7 +876,6 @@ func (b *browserService) GetKeyDetail(param types.KeyDetailParam) (resp types.JS
continue continue
} }
items = append(items, types.ListEntryItem{ items = append(items, types.ListEntryItem{
Index: len(items),
Value: val, Value: val,
}) })
if doConvert { if doConvert {
@ -1615,11 +1614,10 @@ func (b *browserService) SetListItem(param types.SetListParam) (resp types.JSRes
client, ctx := item.client, item.ctx client, ctx := item.client, item.ctx
key := strutil.DecodeRedisKey(param.Key) key := strutil.DecodeRedisKey(param.Key)
str := strutil.DecodeRedisKey(param.Value) str := strutil.DecodeRedisKey(param.Value)
index := int64(param.Index)
var replaced, removed []types.ListReplaceItem var replaced, removed []types.ListReplaceItem
if len(str) <= 0 { if len(str) <= 0 {
// remove from list // remove from list
err = client.LSet(ctx, key, index, "---VALUE_REMOVED_BY_TINY_RDM---").Err() err = client.LSet(ctx, key, param.Index, "---VALUE_REMOVED_BY_TINY_RDM---").Err()
if err != nil { if err != nil {
resp.Msg = err.Error() resp.Msg = err.Error()
return return
@ -1641,7 +1639,7 @@ func (b *browserService) SetListItem(param types.SetListParam) (resp types.JSRes
resp.Msg = fmt.Sprintf(`save to type "%s" fail: %s`, param.Format, err.Error()) resp.Msg = fmt.Sprintf(`save to type "%s" fail: %s`, param.Format, err.Error())
return return
} }
err = client.LSet(ctx, key, index, saveStr).Err() err = client.LSet(ctx, key, param.Index, saveStr).Err()
if err != nil { if err != nil {
resp.Msg = err.Error() resp.Msg = err.Error()
return return

View File

@ -56,7 +56,7 @@ type SetListParam struct {
Server string `json:"server"` Server string `json:"server"`
DB int `json:"db"` DB int `json:"db"`
Key any `json:"key"` Key any `json:"key"`
Index int `json:"index"` Index int64 `json:"index"`
Value any `json:"value"` Value any `json:"value"`
Format string `json:"format,omitempty"` Format string `json:"format,omitempty"`
Decode string `json:"decode,omitempty"` Decode string `json:"decode,omitempty"`

View File

@ -1,13 +1,12 @@
package types package types
type ListEntryItem struct { type ListEntryItem struct {
Index int `json:"index"`
Value any `json:"v"` Value any `json:"v"`
DisplayValue string `json:"dv,omitempty"` DisplayValue string `json:"dv,omitempty"`
} }
type ListReplaceItem struct { type ListReplaceItem struct {
Index int `json:"index"` Index int64 `json:"index"`
Value any `json:"v,omitempty"` Value any `json:"v,omitempty"`
DisplayValue string `json:"dv,omitempty"` DisplayValue string `json:"dv,omitempty"`
} }

View File

@ -107,6 +107,27 @@ func Merge[M ~map[K]V, K Hashable, V any](mapArr ...M) M {
return result return result
} }
// DeepMerge 深度递归覆盖src值到dst中
// 将返回新的值
func DeepMerge[M ~map[K]any, K Hashable](src1, src2 M) M {
out := make(map[K]any, len(src1))
for k, v := range src1 {
out[k] = v
}
for k, v := range src2 {
if v1, ok := v.(map[K]any); ok {
if bv, ok := out[k]; ok {
if bv1, ok := bv.(map[K]any); ok {
out[k] = DeepMerge(bv1, v1)
continue
}
}
}
out[k] = v
}
return out
}
// Omit 根据条件省略指定元素 // Omit 根据条件省略指定元素
func Omit[M ~map[K]V, K Hashable, V any](m M, omitFunc func(k K, v V) bool) (M, []K) { func Omit[M ~map[K]V, K Hashable, V any](m M, omitFunc func(k K, v V) bool) (M, []K) {
result := M{} result := M{}

View File

@ -12,10 +12,6 @@ const props = defineProps({
}, },
icons: Array, icons: Array,
tTooltips: Array, tTooltips: Array,
tTooltipPlacement: {
type: String,
default: 'bottom',
},
iconSize: { iconSize: {
type: [Number, String], type: [Number, String],
default: 20, default: 20,
@ -49,7 +45,6 @@ const handleSwitch = (idx) => {
v-for="(icon, i) in props.icons" v-for="(icon, i) in props.icons"
:key="i" :key="i"
:disabled="!(props.tTooltips && props.tTooltips[i])" :disabled="!(props.tTooltips && props.tTooltips[i])"
:placement="props.tTooltipPlacement"
:show-arrow="false"> :show-arrow="false">
<template #trigger> <template #trigger>
<n-button :focusable="false" :size="props.size" :tertiary="i !== props.value" @click="handleSwitch(i)"> <n-button :focusable="false" :size="props.size" :tertiary="i !== props.value" @click="handleSwitch(i)">

View File

@ -150,7 +150,7 @@ const saveEdit = async (pos, value, decode, format) => {
server: props.name, server: props.name,
db: props.db, db: props.db,
key: keyName.value, key: keyName.value,
index: row.index, index,
value, value,
decode, decode,
format, format,
@ -180,16 +180,16 @@ const actionColumn = {
align: 'center', align: 'center',
titleAlign: 'center', titleAlign: 'center',
fixed: 'right', fixed: 'right',
render: ({ index, v }, _) => { render: (row, index) => {
return h(EditableTableColumn, { return h(EditableTableColumn, {
editing: false, editing: false,
bindKey: `#${index + 1}`, bindKey: `#${index + 1}`,
onCopy: async () => { onCopy: async () => {
copy(v) copy(row.v)
$message.success(i18n.t('interface.copy_succ')) $message.success(i18n.t('interface.copy_succ'))
}, },
onEdit: () => { onEdit: () => {
startEdit(index + 1, v) startEdit(index + 1, row.v)
}, },
onDelete: async () => { onDelete: async () => {
try { try {
@ -221,7 +221,7 @@ const columns = computed(() => {
width: 80, width: 80,
align: 'center', align: 'center',
titleAlign: 'center', titleAlign: 'center',
render: ({ index }, _) => { render: (row, index) => {
return index + 1 return index + 1
}, },
}, },
@ -236,7 +236,7 @@ const columns = computed(() => {
width: 80, width: 80,
align: 'center', align: 'center',
titleAlign: 'center', titleAlign: 'center',
render: ({ index }, _) => { render: (row, index) => {
if (index + 1 === currentEditRow.no) { if (index + 1 === currentEditRow.no) {
// editing row, show edit state // editing row, show edit state
return h(NIcon, { size: 16, color: 'red' }, () => h(Edit, { strokeWidth: 5 })) return h(NIcon, { size: 16, color: 'red' }, () => h(Edit, { strokeWidth: 5 }))
@ -250,12 +250,12 @@ const columns = computed(() => {
} }
}) })
const rowProps = ({ index, v }, _) => { const rowProps = (row, index) => {
return { return {
onClick: () => { onClick: () => {
// in edit mode, switch edit row by click // in edit mode, switch edit row by click
if (inEdit.value) { if (inEdit.value) {
startEdit(index + 1, v) startEdit(index + 1, row.v)
} }
}, },
} }

View File

@ -291,25 +291,9 @@ const useTabStore = defineStore('tab', {
case 'list': // {v:string, dv:[string]}[] case 'list': // {v:string, dv:[string]}[]
tab.value = tab.value || [] tab.value = tab.value || []
if (prepend === true) { if (prepend === true) {
const originList = tab.value tab.value = [...entries, ...tab.value]
const list = []
let starIndex = 0
for (const entry of entries) {
entry.index = starIndex++
list.push(entry)
}
for (const entry of originList) {
entry.index = starIndex++
list.push(entry)
}
tab.value = list
} else { } else {
const list = tab.value tab.value.push(...entries)
let starIndex = list.length
for (const entry of entries) {
entry.index = starIndex++
list.push(entry)
}
} }
tab.length += size(entries) tab.length += size(entries)
break break
@ -408,7 +392,6 @@ const useTabStore = defineStore('tab', {
for (const entry of entries) { for (const entry of entries) {
if (size(tab.value) > entry.index) { if (size(tab.value) > entry.index) {
tab.value[entry.index] = { tab.value[entry.index] = {
index: entry.index,
v: entry.v, v: entry.v,
dv: entry.dv, dv: entry.dv,
} }