@@ -4,7 +4,7 @@ import app from './modules/app.js'
44import host from './modules/host.js'
55import hostView from './modules/hostView.js'
66import newKey from './modules/newKey.js'
7- import redis from './modules/redis .js'
7+ import send from '../lib/channel/send .js'
88import { NO_AUTH , PASSWD_ERROR , CONNECT_TIMEOUT , FAIL , STRING , PARAM_INVALID } from '../../lib/redis/singal'
99
1010Vue . use ( Vuex )
@@ -22,7 +22,6 @@ const appStore = new Vuex.Store({
2222 app,
2323 host,
2424 hostView,
25- redis,
2625 newKey
2726 }
2827} )
@@ -79,9 +78,30 @@ if (window.ipcRenderer) {
7978 window . ipcRenderer . on ( 'removeKey' , ( event , data ) => {
8079 for ( let i = 0 ; i < hostView . state . all . length ; i ++ ) {
8180 if ( hostView . state . all [ i ] . time === data . time ) {
82- if ( data . keys ) hostView . state . all [ i ] . dbData = data . keys
81+ if ( data . keys ) {
82+ hostView . state . all [ i ] . dbData = data . keys ;
83+ } else {
84+ hostView . state . all [ i ] . dbData = hostView . state . all [ i ] . dbData . filter ( v => {
85+ return data . k !== v
86+ } ) ;
87+ }
8388 hostView . state . all [ i ] . dbLoading = false
8489 hostView . state . all [ i ] . deleteKeyOK = 1
90+ if ( hostView . state . all [ i ] . keyDetail . ttlTimer ) {
91+ // 删除ttl定时器
92+ clearInterval ( hostView . state . all [ i ] . keyDetail . ttlTimer ) ;
93+ }
94+ // 重制key详情组件数据
95+ hostView . state . all [ i ] . keyDetailShow = false
96+ hostView . state . all [ i ] . keyDetail = {
97+ keyName : '' ,
98+ type : '-' ,
99+ ttl : - 1 ,
100+ value : '' ,
101+ rename : false ,
102+ renameStatus : 0 ,
103+ newKeyName : ''
104+ } ;
85105 break
86106 }
87107 }
@@ -132,7 +152,11 @@ if (window.ipcRenderer) {
132152 * 接收key详情数据
133153 */
134154 window . ipcRenderer . on ( 'keyDetail' , ( event , data ) => {
135- if ( hostView . state . current . keyDetail . ttlTimer ) clearInterval ( hostView . state . current . keyDetail . ttlTimer ) // 打开新key详情,清除上一次key可能存在的ttl定时器
155+ if ( hostView . state . current . keyDetail . ttlTimer ) {
156+ // 打开新key详情,清除上一次key可能存在的ttl定时器
157+ clearInterval ( hostView . state . current . keyDetail . ttlTimer )
158+ hostView . state . current . keyDetail . ttl = 0
159+ }
136160 for ( let i = 0 ; i < hostView . state . all . length ; i ++ ) {
137161 if ( hostView . state . all [ i ] . time === data . time ) {
138162 if ( data . keys ) { // 是否热更新数据
@@ -165,7 +189,7 @@ if (window.ipcRenderer) {
165189 // 刷新key列表
166190 current . dbLoading = true
167191 current . keyDetailShow = false // 关闭key详情窗口
168- redis . mutations . getAllKey ( redis . state , { index : current . selectDB , time : current . time } )
192+ send . sendEvent ( 'getAllKey' , { index : current . selectDB , time : current . time } )
169193 current . keyDetail . ttlTimer = null
170194 }
171195 } , 1000 )
@@ -241,7 +265,7 @@ if (window.ipcRenderer) {
241265 // 刷新key列表
242266 current . dbLoading = true
243267 current . keyDetailShow = false // 关闭key详情窗口
244- redis . mutations . getAllKey ( redis . state , { index : current . selectDB , time : current . time } )
268+ send . sendEvent ( 'getAllKey' , { index : current . selectDB , time : current . time } )
245269 current . keyDetail . ttlTimer = null
246270 }
247271 } , 1000 )
0 commit comments