67
67
</el-row >
68
68
69
69
<el-table
70
- v-loading =" keyListLoad"
71
- :data =" keyList"
72
- row-key =" id"
70
+ v-loading =" keyListLoad"
71
+ :data =" keyList"
72
+ row-key =" id"
73
+ @row-click =" openCacheInfo"
73
74
>
74
75
<el-table-column prop =" keyTemplate" label =" Key 模板" width =" 200" />
75
76
<el-table-column prop =" keyType" label =" Key 类型" width =" 100" />
76
77
<el-table-column prop =" valueType" label =" Value 类型" />
77
78
<el-table-column prop =" timeoutType" label =" 超时时间" width =" 200" >
78
79
<template slot-scope="scope">
79
- <dict-tag :type =" DICT_TYPE.INFRA_REDIS_TIMEOUT_TYPE" :value =" scope.row.timeoutType" />
80
- <span v-if =" scope.row.timeout > 0" >({{ scope.row.timeout / 1000 }} 秒)</span >
80
+ <dict-tag
81
+ :type =" DICT_TYPE.INFRA_REDIS_TIMEOUT_TYPE"
82
+ :value =" scope.row.timeoutType"
83
+ />
84
+ <span v-if =" scope.row.timeout > 0"
85
+ >({{ scope.row.timeout / 1000 }} 秒)</span
86
+ >
81
87
</template >
82
88
</el-table-column >
83
89
<el-table-column prop =" memo" label =" 备注" />
84
90
</el-table >
85
- </div >
86
91
92
+ <!-- 缓存模块信息框 -->
93
+ <el-dialog
94
+ :title =" keyTemplate + '模块'"
95
+ :visible.sync =" open"
96
+ width =" 60vw"
97
+ append-to-body
98
+ >
99
+ <el-row :gutter =" 10" >
100
+ <el-col :span =" 10" class =" card-box" >
101
+ <el-card style =" height : 70vh " >
102
+ <div slot =" header" >
103
+ <span >键名列表</span >
104
+ <el-button
105
+ style =" float : right ; padding : 3px 0 "
106
+ type =" text"
107
+ icon =" el-icon-refresh-right"
108
+ @click =" refreshCacheKeys"
109
+ ></el-button >
110
+ </div >
111
+ <el-table
112
+ :data =" cachekeys"
113
+ style =" width : 100% "
114
+ @row-click =" handleCacheValue"
115
+ >
116
+ <el-table-column
117
+ label =" 序号"
118
+ width =" 60"
119
+ type =" index"
120
+ ></el-table-column >
121
+ <el-table-column
122
+ label =" 缓存键名"
123
+ align =" center"
124
+ :show-overflow-tooltip =" true"
125
+ :formatter =" keyFormatter"
126
+ >
127
+ </el-table-column >
128
+ <el-table-column
129
+ label =" 操作"
130
+ width =" 60"
131
+ align =" center"
132
+ class-name =" small-padding fixed-width"
133
+ >
134
+ <template slot-scope="scope">
135
+ <el-button
136
+ size =" mini"
137
+ type =" text"
138
+ icon =" el-icon-delete"
139
+ @click =" handleClearCacheKey(scope.row)"
140
+ ></el-button >
141
+ </template >
142
+ </el-table-column >
143
+ </el-table >
144
+ </el-card >
145
+ </el-col >
146
+
147
+ <el-col :span =" 14" >
148
+ <el-card :bordered =" false" style =" height : 70vh " >
149
+ <div slot =" header" >
150
+ <span >缓存内容</span >
151
+ <!-- <el-button
152
+ style="float: right; padding: 3px 0"
153
+ type="text"
154
+ icon="el-icon-refresh-right"
155
+ @click="handleClearCacheAll()"
156
+ >清理全部</el-button>
157
+ -->
158
+ </div >
159
+ <el-form :model =" cacheForm" >
160
+ <el-row :gutter =" 32" >
161
+ <el-col :offset =" 1" :span =" 22" >
162
+ <el-form-item label =" 缓存名称:" prop =" keyTemplate" >
163
+ <el-input v-model =" cacheForm.keyTemplate" :readOnly =" true" />
164
+ </el-form-item >
165
+ </el-col >
166
+ <el-col :offset =" 1" :span =" 22" >
167
+ <el-form-item label =" 缓存键名:" prop =" key" >
168
+ <el-input v-model =" cacheForm.key" :readOnly =" true" />
169
+ </el-form-item >
170
+ </el-col >
171
+ <el-col :offset =" 1" :span =" 22" >
172
+ <el-form-item label =" 缓存内容:" prop =" value" >
173
+ <el-input
174
+ v-model =" cacheForm.value"
175
+ type =" textarea"
176
+ :rows =" 12"
177
+ :readOnly =" true"
178
+ />
179
+ </el-form-item >
180
+ </el-col >
181
+ </el-row >
182
+ </el-form >
183
+ </el-card >
184
+ </el-col >
185
+ </el-row >
186
+ </el-dialog >
187
+ </div >
87
188
</template >
88
189
89
190
<script >
90
- import { getCache , getKeyList } from " @/api/infra/redis" ;
191
+ import { getCache , getKeyList , getKeyDefines , getKeyValue , deleteKeyValue } from " @/api/infra/redis" ;
91
192
import echarts from " echarts" ;
92
193
93
194
export default {
94
195
name: " Server" ,
95
- data () {
196
+ data () {
96
197
return {
97
198
// 统计命令信息
98
199
commandstats: null ,
@@ -103,15 +204,20 @@ export default {
103
204
// key 列表
104
205
keyListLoad: true ,
105
206
keyList: [],
207
+ // 模块弹出框
208
+ open: false ,
209
+ keyTemplate: " " ,
210
+ cachekeys: [],
211
+ cacheForm: {}
106
212
};
107
213
},
108
- created () {
214
+ created () {
109
215
this .getList ();
110
216
this .openLoading ();
111
217
},
112
218
methods: {
113
219
/** 查缓存询信息 */
114
- getList () {
220
+ getList () {
115
221
// 查询 Redis 监控信息
116
222
getCache ().then ((response ) => {
117
223
this .cache = response .data ;
@@ -174,10 +280,55 @@ export default {
174
280
this .keyListLoad = false ;
175
281
});
176
282
},
283
+
177
284
// 打开加载层
178
- openLoading () {
285
+ openLoading () {
179
286
this .$modal .loading (" 正在加载缓存监控数据,请稍后!" );
180
287
},
288
+
289
+ // 打开缓存弹窗
290
+ openCacheInfo (e ) {
291
+ this .open = true ;
292
+ let keyDefine = e .keyTemplate .substring (0 , e .keyTemplate .length - 2 );
293
+ this .keyTemplate = keyDefine;
294
+ // 加载键名列表
295
+ this .handleCacheKeys (keyDefine);
296
+ },
297
+
298
+ /** 键名前缀去除 */
299
+ keyFormatter (cacheKey ) {
300
+ return cacheKey .replace (this .keyTemplate , " " );
301
+ },
302
+
303
+ // 获取键名列表
304
+ handleCacheKeys (keyDefine ){
305
+ const cacheName = keyDefine !== undefined ? keyDefine : this .keyTemplate ;
306
+ getKeyDefines (cacheName).then (response => {
307
+ this .cachekeys = response .data
308
+ this .cacheForm = {}
309
+ })
310
+ },
311
+
312
+ // 获取缓存值
313
+ handleCacheValue (e ){
314
+ getKeyValue (this .keyTemplate , e).then (response => {
315
+ this .cacheForm = response .data
316
+ })
317
+ },
318
+
319
+ // 刷新键名列表
320
+ refreshCacheKeys (){
321
+ this .$modal .msgSuccess (" 刷新键名列表成功" );
322
+ this .handleCacheKeys ();
323
+ },
324
+
325
+ // 删除缓存
326
+ handleClearCacheKey (key ){
327
+ deleteKeyValue (key).then (response => {
328
+ this .$modal .msgSuccess (" 清理缓存键名[" + key + " ]成功" );
329
+ this .handleCacheKeys ();
330
+ })
331
+ },
181
332
},
182
333
};
183
334
</script >
0 commit comments