diff --git a/src/components/FormatViewer.vue b/src/components/FormatViewer.vue index ae80ac692..13994c8ff 100644 --- a/src/components/FormatViewer.vue +++ b/src/components/FormatViewer.vue @@ -9,13 +9,14 @@ :value="item.value"> - Hex + Hex
@@ -25,6 +26,7 @@ + + diff --git a/src/components/KeyContentHash.vue b/src/components/KeyContentHash.vue index 4926b14ad..6de2ce2f0 100644 --- a/src/components/KeyContentHash.vue +++ b/src/components/KeyContentHash.vue @@ -12,12 +12,10 @@ - Hex - + - Hex @@ -43,7 +41,7 @@ width="150"> import PaginationTable from '@/components/PaginationTable'; import FormatViewer from '@/components/FormatViewer'; +import InputBinary from '@/components/InputBinary'; export default { data() { @@ -110,7 +109,7 @@ export default { loadMoreDisable: false, }; }, - components: {PaginationTable, FormatViewer}, + components: {PaginationTable, FormatViewer, InputBinary}, props: ['client', 'redisKey'], computed: { dialogTitle() { @@ -160,10 +159,10 @@ export default { for (let i = 0; i < reply.length; i += 2) { hashData.push({ - key: this.$util.bufToString(reply[i]), - value: this.$util.bufToString(reply[i + 1]), - binaryK: !this.$util.bufVisible(reply[i]), - binaryV: !this.$util.bufVisible(reply[i + 1]), + key: reply[i], + keyDisplay: this.$util.bufToString(reply[i]), + value: reply[i + 1], + valueDisplay: this.$util.bufToString(reply[i + 1]), }); } @@ -191,7 +190,7 @@ export default { }, showEditDialog(row) { this.editLineItem = row; - this.beforeEditItem = JSON.parse(JSON.stringify(row)); + this.beforeEditItem = this.$util.cloneObjWithBuff(row); this.editDialog = true; }, editLine() { @@ -208,14 +207,14 @@ export default { client.hset( key, - before.binaryK ? this.$util.xToBuffer(after.key) : after.key, - before.binaryV ? this.$util.xToBuffer(after.value) : after.value + after.key, + after.value ).then((reply) => { // edit key && key changed - if (before.key && before.key !== after.key) { + if (before.key && !before.key.equals(after.key)) { client.hdel( key, - before.binaryK ? this.$util.xToBuffer(before.key) : before.key + before.key ).then((reply) => { this.initShow(); }); @@ -239,7 +238,7 @@ export default { ).then(() => { this.client.hdel( this.redisKey, - row.binaryK ? this.$util.xToBuffer(row.key) : row.key + row.key ).then((reply) => { if (reply === 1) { this.$message.success({ diff --git a/src/components/KeyContentList.vue b/src/components/KeyContentList.vue index e2db8f85d..6cdac95e2 100644 --- a/src/components/KeyContentList.vue +++ b/src/components/KeyContentList.vue @@ -12,7 +12,6 @@ - Hex @@ -38,7 +37,7 @@ width="150"> { // reply return list length if success if (reply > 0) { @@ -168,7 +167,7 @@ export default { client.lrem( key, 1, - before.binary ? this.$util.xToBuffer(before.value) : before.value + before.value ).then((reply) => { this.initShow(); }); @@ -193,7 +192,7 @@ export default { this.client.lrem( this.redisKey, 1, - row.binary ? this.$util.xToBuffer(row.value) : row.value + row.value ).then((reply) => { if (reply === 1) { this.$message.success({ diff --git a/src/components/KeyContentSet.vue b/src/components/KeyContentSet.vue index 465765570..a4ff73028 100644 --- a/src/components/KeyContentSet.vue +++ b/src/components/KeyContentSet.vue @@ -9,11 +9,10 @@ - + - Hex - + @@ -38,7 +37,7 @@ width="150"> import PaginationTable from '@/components/PaginationTable'; +import FormatViewer from '@/components/FormatViewer'; export default { data() { @@ -96,7 +96,7 @@ export default { }; }, props: ['client', 'redisKey'], - components: {PaginationTable}, + components: {PaginationTable, FormatViewer}, computed: { dialogTitle() { return this.beforeEditItem.value ? this.$t('message.edit_line') : @@ -145,8 +145,8 @@ export default { for (const i of reply) { setData.push({ - value: this.$util.bufToString(i), - binary: !this.$util.bufVisible(i), + value: i, + valueDisplay: this.$util.bufToString(i), }); } @@ -167,9 +167,14 @@ export default { getScanMatch() { return this.filterValue ? `*${this.filterValue}*` : '*'; }, + openDialog() { + this.$nextTick(() => { + this.$refs.formatViewer.autoFormat(); + }); + }, showEditDialog(row) { this.editLineItem = row; - this.beforeEditItem = JSON.parse(JSON.stringify(row)); + this.beforeEditItem = this.$util.cloneObjWithBuff(row); this.editDialog = true; }, editLine() { @@ -180,13 +185,13 @@ export default { this.editDialog = false; - if (!after.value || before.value == after.value) { + if (!after.value || (before.value && before.value.equals(after.value))) { return; } client.sadd( key, - before.binary ? this.$util.xToBuffer(after.value) : after.value + after.value ).then((reply) => { // add success if (reply === 1) { @@ -194,7 +199,7 @@ export default { if (before.value) { client.srem( key, - before.binary ? this.$util.xToBuffer(before.value) : before.value + before.value ).then((reply) => { this.initShow(); }); @@ -226,7 +231,7 @@ export default { ).then(() => { this.client.srem( this.redisKey, - row.binary ? this.$util.xToBuffer(row.value) : row.value + row.value ).then((reply) => { if (reply === 1) { this.$message.success({ diff --git a/src/components/KeyContentString.vue b/src/components/KeyContentString.vue index d7af2d8cd..a6ce4caf5 100644 --- a/src/components/KeyContentString.vue +++ b/src/components/KeyContentString.vue @@ -6,7 +6,7 @@ ref='formatViewer' :content.sync='content' :binary='binary' - float='left' + float='' :textrows=12> @@ -24,7 +24,7 @@ import FormatViewer from '@/components/FormatViewer'; export default { data() { return { - content: '', + content: Buffer.from(''), binary: false, }; }, @@ -33,9 +33,7 @@ export default { methods: { initShow() { this.client.getBuffer(this.redisKey).then((reply) => { - this.content = this.$util.bufToString(reply); - this.binary = !this.$util.bufVisible(reply); - + this.content = reply; this.$refs.formatViewer.autoFormat(); }); }, @@ -44,7 +42,7 @@ export default { this.client.set( key, - this.binary ? this.$util.xToBuffer(this.content) : this.content + this.content ).then((reply) => { if (reply === 'OK') { this.initShow() diff --git a/src/components/KeyContentZset.vue b/src/components/KeyContentZset.vue index 33b9ae1fc..b77deee19 100644 --- a/src/components/KeyContentZset.vue +++ b/src/components/KeyContentZset.vue @@ -9,15 +9,14 @@ - + - - Hex - - + + +