Skip to content

Commit 75c6688

Browse files
author
dalgurak
committed
da copu
1 parent a7784be commit 75c6688

File tree

14 files changed

+103
-138
lines changed

14 files changed

+103
-138
lines changed

front/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</template>
66
<script>
77
import Home from '@/front/views/Home.vue'
8-
8+
import send from '@/front/lib/channel/send.js'
99
export default {
1010
components: {
1111
Home
@@ -50,7 +50,7 @@ export default {
5050
this.$store.state.hostView.current.keyDetailShow = false // 关闭key详情窗口
5151
// 刷新key列表
5252
this.$store.state.hostView.current.dbLoading = true
53-
this.$store.commit('redis/getAllKey', {
53+
send.sendEvent('getAllKey', {
5454
index: this.$store.state.hostView.current.selectDB,
5555
time: this.$store.state.hostView.current.time
5656
})

front/components/common/li-table.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<template>
22
<div :class="['table-box', customClass]">
33
<div class="item-box radio-kgt bgdColor" v-for="(o, i) of data" :key="i">
4-
<!-- <i class="el-icon-info"></i> -->
5-
<span class="left">{{i}}</span>
6-
<span class="right brand-color" v-html="o"></span>
4+
<i v-if="o.i" :class="[o.i, 'brand-color']"></i>
5+
<span class="left fontColor3">{{o.k}}</span>
6+
<span class="right greenColor" v-html="o.v"></span>
77
</div>
88
</div>
99
</template>
@@ -41,6 +41,7 @@ export default {
4141
.item-box {
4242
i {
4343
margin-right: 5px;
44+
// color: red;
4445
}
4546
box-sizing: border-box;
4647
width: 49%;

front/components/host/ServerInfo.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<div class="pading-cu bgkColor radio-kgt">
33
<el-tabs class="el-tab-cls" v-model="activeName" @tab-click="handleClick" :stretch="true">
44
<el-tab-pane label="Server" name="server">
5-
<LiTable customClass="li-table" :key="current.serverInfoKey" :data="current.serverInfo ? current.serverInfo.s : { 'User suas asa': '1\r\n999922222222299999922222', name: '111', age: 2222222, age15: 2222222, age14: 2222222, age13: 2222222, age12: 2222222, age11: 2222222, age10: 2222222, age9: 2222222, age8: 2222222, age7: 2222222, age6: 2222222, age5: 2222222, age4: 2222222, age3: 2222222, age2: 2222222}"/>
5+
<LiTable customClass="li-table" :key="current.serverInfoKey" :data="current.serverInfo ? current.serverInfo.s : [{k: 'saaasa', v: 'sasaa', i: 'el-icon-coin'}]"/>
66
</el-tab-pane>
77
<el-tab-pane label="Clients" name="second">
8-
<LiTable customClass="li-table" :key="current.serverInfoKey" :data="current.serverInfo ? current.serverInfo.c : { 'nam': 1, aa: 2, 'ccc': 3}"/>
8+
<LiTable customClass="li-table" :key="current.serverInfoKey" :data="current.serverInfo ? current.serverInfo.c : []"/>
99
</el-tab-pane>
1010
<el-tab-pane label="DB" name="four">
11-
<LiTable customClass="li-table" :key="current.serverInfoKey" :data="current.serverInfo ? current.serverInfo.o : {}"/>
11+
<LiTable customClass="li-table" :key="current.serverInfoKey" :data="current.serverInfo ? current.serverInfo.o : []"/>
1212
</el-tab-pane>
1313
</el-tabs>
1414
</div>

front/components/host/keyDetail.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export default {
191191
},
192192
// 重加载key详情
193193
reload() {
194-
this.$store.commit('redis/keyDetail', {
194+
send.sendEvent('keyDetail', {
195195
time: this.current.time,
196196
key: this.current.keyDetail.keyName,
197197
index: this.current.selectDB
@@ -216,7 +216,7 @@ export default {
216216
},
217217
renameKey() { // 重命名key,新名字不能已存在
218218
this.current.dbLoading = true
219-
this.$store.commit('redis/rename', {
219+
send.sendEvent('rename', {
220220
time: this.current.time,
221221
key: this.current.keyDetail.keyName,
222222
newKey: this.current.keyDetail.newKeyName,

front/components/host/newKey.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
</template>
7676
<script>
7777
import { STRING, LIST, HASH, SET, ZSET } from '../../../lib/redis/singal'
78+
import send from '@/front/lib/channel/send.js'
7879
export default {
7980
name: 'NewKey',
8081
computed: {
@@ -144,7 +145,7 @@ export default {
144145
default:
145146
break
146147
}
147-
this.$store.commit('redis/setKey', data) // 提交保存key
148+
send.sendEvent('setKey', data) // 提交保存key
148149
this.current.dbLoading = true
149150
this.drawer = false
150151
this.$refs.key.resetFields()

front/components/host/terminal.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Terminal } from 'xterm'
1616
import { FitAddon } from 'xterm-addon-fit'
1717
import { WebLinksAddon } from 'xterm-addon-web-links'
1818
import { SearchAddon } from 'xterm-addon-search'
19+
import send from '@/front/lib/channel/send.js'
1920
export default {
2021
name: 'Terminal',
2122
props: {
@@ -84,7 +85,7 @@ export default {
8485
this.input = this.input.trim()
8586
if (this.input) {
8687
// 发送到后端
87-
this.$store.commit('redis/sendCommand', { time: this.current.time, command: this.input, index: this.selectDB })
88+
send.sendEvent('sendCommand', { time: this.current.time, command: this.input, index: this.selectDB })
8889
// 记录历史命令
8990
this.histCommandList.push(this.input)
9091
this.histIndex = this.histCommandList.length
@@ -258,14 +259,14 @@ export default {
258259
// ctrl+v
259260
if (ev.keyCode === 86 && (ev.ctrlKey || ev.metaKey) && ev.type === 'keydown') {
260261
// 从主进程获取系统剪切板内容
261-
this.$store.commit('redis/getClipboard', { time: this.current.time })
262+
send.sendEvent('getClipboard', { time: this.current.time })
262263
}
263264
// ctrl+c
264265
if (ev.keyCode === 67 && (ev.ctrlKey || ev.metaKey) && ev.type === 'keydown') {
265266
if (term.hasSelection()) {
266267
console.log('---', term.getSelection())
267268
// 设置系统剪切板内容
268-
this.$store.commit('redis/setClipboard', { text: term.getSelection() })
269+
send.sendEvent('setClipboard', { text: term.getSelection() })
269270
}
270271
}
271272
})

front/lib/channel/send.js

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,6 @@ export default {
1717
window.ipcRenderer.send('closeConnect', time)
1818
}
1919
},
20-
getAllKey(data) {
21-
if (window.ipcRenderer) {
22-
window.ipcRenderer.send('getAllKey', data)
23-
}
24-
},
25-
setKey(data) {
26-
if (window.ipcRenderer) {
27-
window.ipcRenderer.send('setKey', data)
28-
}
29-
},
30-
sendCommand(data) {
31-
if (window.ipcRenderer) {
32-
window.ipcRenderer.send('sendCommand', data)
33-
}
34-
},
35-
keyDetail(data) {
36-
if (window.ipcRenderer) {
37-
window.ipcRenderer.send('keyDetail', data)
38-
}
39-
},
40-
rename(data) {
41-
if (window.ipcRenderer) {
42-
window.ipcRenderer.send('rename', data)
43-
}
44-
},
45-
getClipboard(data) {
46-
if (window.ipcRenderer) {
47-
window.ipcRenderer.send('getClipboard', data)
48-
}
49-
},
50-
setClipboard(data) {
51-
if (window.ipcRenderer) {
52-
window.ipcRenderer.send('setClipboard', data)
53-
}
54-
},
5520
windowsOpertion(event) {
5621
if (window.ipcRenderer) window.ipcRenderer.send(event)
5722
},

front/store/index.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import app from './modules/app.js'
44
import host from './modules/host.js'
55
import hostView from './modules/hostView.js'
66
import newKey from './modules/newKey.js'
7-
import redis from './modules/redis.js'
7+
import send from '../lib/channel/send.js'
88
import { NO_AUTH, PASSWD_ERROR, CONNECT_TIMEOUT, FAIL, STRING, PARAM_INVALID } from '../../lib/redis/singal'
99

1010
Vue.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)

front/store/modules/redis.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

front/style/common.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
.fontColor3 {
3737
color: #E6A23C;
3838
}
39+
.colorDanger {
40+
color: #F56C6C;
41+
}
3942

4043
.pageColor {
4144
background-color: #dedfe6;

0 commit comments

Comments
 (0)