Compare commits
No commits in common. "3367f13d80d331c7ca8aecfff64ce80bae2db722" and "ccb4bb85ae9cc6745f604ed53ca8cbd206592601" have entirely different histories.
3367f13d80
...
ccb4bb85ae
|
@ -876,7 +876,6 @@ func (b *browserService) GetKeyDetail(param types.KeyDetailParam) (resp types.JS
|
|||
continue
|
||||
}
|
||||
items = append(items, types.ListEntryItem{
|
||||
Index: len(items),
|
||||
Value: val,
|
||||
})
|
||||
if doConvert {
|
||||
|
@ -1615,11 +1614,10 @@ func (b *browserService) SetListItem(param types.SetListParam) (resp types.JSRes
|
|||
client, ctx := item.client, item.ctx
|
||||
key := strutil.DecodeRedisKey(param.Key)
|
||||
str := strutil.DecodeRedisKey(param.Value)
|
||||
index := int64(param.Index)
|
||||
var replaced, removed []types.ListReplaceItem
|
||||
if len(str) <= 0 {
|
||||
// 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 {
|
||||
resp.Msg = err.Error()
|
||||
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())
|
||||
return
|
||||
}
|
||||
err = client.LSet(ctx, key, index, saveStr).Err()
|
||||
err = client.LSet(ctx, key, param.Index, saveStr).Err()
|
||||
if err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
|
|
|
@ -56,7 +56,7 @@ type SetListParam struct {
|
|||
Server string `json:"server"`
|
||||
DB int `json:"db"`
|
||||
Key any `json:"key"`
|
||||
Index int `json:"index"`
|
||||
Index int64 `json:"index"`
|
||||
Value any `json:"value"`
|
||||
Format string `json:"format,omitempty"`
|
||||
Decode string `json:"decode,omitempty"`
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package types
|
||||
|
||||
type ListEntryItem struct {
|
||||
Index int `json:"index"`
|
||||
Value any `json:"v"`
|
||||
DisplayValue string `json:"dv,omitempty"`
|
||||
}
|
||||
|
||||
type ListReplaceItem struct {
|
||||
Index int `json:"index"`
|
||||
Index int64 `json:"index"`
|
||||
Value any `json:"v,omitempty"`
|
||||
DisplayValue string `json:"dv,omitempty"`
|
||||
}
|
||||
|
|
|
@ -107,6 +107,27 @@ func Merge[M ~map[K]V, K Hashable, V any](mapArr ...M) M {
|
|||
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 根据条件省略指定元素
|
||||
func Omit[M ~map[K]V, K Hashable, V any](m M, omitFunc func(k K, v V) bool) (M, []K) {
|
||||
result := M{}
|
||||
|
|
|
@ -12,10 +12,6 @@ const props = defineProps({
|
|||
},
|
||||
icons: Array,
|
||||
tTooltips: Array,
|
||||
tTooltipPlacement: {
|
||||
type: String,
|
||||
default: 'bottom',
|
||||
},
|
||||
iconSize: {
|
||||
type: [Number, String],
|
||||
default: 20,
|
||||
|
@ -49,7 +45,6 @@ const handleSwitch = (idx) => {
|
|||
v-for="(icon, i) in props.icons"
|
||||
:key="i"
|
||||
:disabled="!(props.tTooltips && props.tTooltips[i])"
|
||||
:placement="props.tTooltipPlacement"
|
||||
:show-arrow="false">
|
||||
<template #trigger>
|
||||
<n-button :focusable="false" :size="props.size" :tertiary="i !== props.value" @click="handleSwitch(i)">
|
||||
|
|
|
@ -150,7 +150,7 @@ const saveEdit = async (pos, value, decode, format) => {
|
|||
server: props.name,
|
||||
db: props.db,
|
||||
key: keyName.value,
|
||||
index: row.index,
|
||||
index,
|
||||
value,
|
||||
decode,
|
||||
format,
|
||||
|
@ -180,16 +180,16 @@ const actionColumn = {
|
|||
align: 'center',
|
||||
titleAlign: 'center',
|
||||
fixed: 'right',
|
||||
render: ({ index, v }, _) => {
|
||||
render: (row, index) => {
|
||||
return h(EditableTableColumn, {
|
||||
editing: false,
|
||||
bindKey: `#${index + 1}`,
|
||||
onCopy: async () => {
|
||||
copy(v)
|
||||
copy(row.v)
|
||||
$message.success(i18n.t('interface.copy_succ'))
|
||||
},
|
||||
onEdit: () => {
|
||||
startEdit(index + 1, v)
|
||||
startEdit(index + 1, row.v)
|
||||
},
|
||||
onDelete: async () => {
|
||||
try {
|
||||
|
@ -221,7 +221,7 @@ const columns = computed(() => {
|
|||
width: 80,
|
||||
align: 'center',
|
||||
titleAlign: 'center',
|
||||
render: ({ index }, _) => {
|
||||
render: (row, index) => {
|
||||
return index + 1
|
||||
},
|
||||
},
|
||||
|
@ -236,7 +236,7 @@ const columns = computed(() => {
|
|||
width: 80,
|
||||
align: 'center',
|
||||
titleAlign: 'center',
|
||||
render: ({ index }, _) => {
|
||||
render: (row, index) => {
|
||||
if (index + 1 === currentEditRow.no) {
|
||||
// editing row, show edit state
|
||||
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 {
|
||||
onClick: () => {
|
||||
// in edit mode, switch edit row by click
|
||||
if (inEdit.value) {
|
||||
startEdit(index + 1, v)
|
||||
startEdit(index + 1, row.v)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -291,25 +291,9 @@ const useTabStore = defineStore('tab', {
|
|||
case 'list': // {v:string, dv:[string]}[]
|
||||
tab.value = tab.value || []
|
||||
if (prepend === true) {
|
||||
const originList = 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
|
||||
tab.value = [...entries, ...tab.value]
|
||||
} else {
|
||||
const list = tab.value
|
||||
let starIndex = list.length
|
||||
for (const entry of entries) {
|
||||
entry.index = starIndex++
|
||||
list.push(entry)
|
||||
}
|
||||
tab.value.push(...entries)
|
||||
}
|
||||
tab.length += size(entries)
|
||||
break
|
||||
|
@ -408,7 +392,6 @@ const useTabStore = defineStore('tab', {
|
|||
for (const entry of entries) {
|
||||
if (size(tab.value) > entry.index) {
|
||||
tab.value[entry.index] = {
|
||||
index: entry.index,
|
||||
v: entry.v,
|
||||
dv: entry.dv,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue