list.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10">
  4. <el-col :span="8">
  5. <el-card style="height: calc(100vh - 125px)">
  6. <div slot="header">
  7. <span><i class="el-icon-collection"></i> 缓存列表</span>
  8. <el-button
  9. style="float: right; padding: 3px 0"
  10. type="text"
  11. icon="el-icon-refresh-right"
  12. @click="refreshCacheNames()"
  13. ></el-button>
  14. </div>
  15. <el-table
  16. v-loading="loading"
  17. :data="cacheNames"
  18. :height="tableHeight"
  19. highlight-current-row
  20. @row-click="getCacheKeys"
  21. style="width: 100%"
  22. >
  23. <el-table-column
  24. label="序号"
  25. width="60"
  26. type="index"
  27. ></el-table-column>
  28. <el-table-column
  29. label="缓存名称"
  30. align="center"
  31. prop="cacheName"
  32. :show-overflow-tooltip="true"
  33. :formatter="nameFormatter"
  34. ></el-table-column>
  35. <el-table-column
  36. label="备注"
  37. align="center"
  38. prop="remark"
  39. :show-overflow-tooltip="true"
  40. />
  41. <el-table-column
  42. label="操作"
  43. width="60"
  44. align="center"
  45. class-name="small-padding fixed-width"
  46. >
  47. <template slot-scope="scope">
  48. <el-button
  49. size="mini"
  50. type="text"
  51. icon="el-icon-delete"
  52. @click="handleClearCacheName(scope.row)"
  53. ></el-button>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. </el-card>
  58. </el-col>
  59. <el-col :span="8">
  60. <el-card style="height: calc(100vh - 125px)">
  61. <div slot="header">
  62. <span><i class="el-icon-key"></i> 键名列表</span>
  63. <el-button
  64. style="float: right; padding: 3px 0"
  65. type="text"
  66. icon="el-icon-refresh-right"
  67. @click="refreshCacheKeys()"
  68. ></el-button>
  69. </div>
  70. <el-table
  71. v-loading="subLoading"
  72. :data="cacheKeys"
  73. :height="tableHeight"
  74. highlight-current-row
  75. @row-click="handleCacheValue"
  76. style="width: 100%"
  77. >
  78. <el-table-column
  79. label="序号"
  80. width="60"
  81. type="index"
  82. ></el-table-column>
  83. <el-table-column
  84. label="缓存键名"
  85. align="center"
  86. :show-overflow-tooltip="true"
  87. :formatter="keyFormatter"
  88. >
  89. </el-table-column>
  90. <el-table-column
  91. label="操作"
  92. width="60"
  93. align="center"
  94. class-name="small-padding fixed-width"
  95. >
  96. <template slot-scope="scope">
  97. <el-button
  98. size="mini"
  99. type="text"
  100. icon="el-icon-delete"
  101. @click="handleClearCacheKey(scope.row)"
  102. ></el-button>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. </el-card>
  107. </el-col>
  108. <el-col :span="8">
  109. <el-card :bordered="false" style="height: calc(100vh - 125px)">
  110. <div slot="header">
  111. <span><i class="el-icon-document"></i> 缓存内容</span>
  112. <el-button
  113. style="float: right; padding: 3px 0"
  114. type="text"
  115. icon="el-icon-refresh-right"
  116. @click="handleClearCacheAll()"
  117. >清理全部</el-button
  118. >
  119. </div>
  120. <el-form :model="cacheForm">
  121. <el-row :gutter="32">
  122. <el-col :offset="1" :span="22">
  123. <el-form-item label="缓存名称:" prop="cacheName">
  124. <el-input v-model="cacheForm.cacheName" :readOnly="true" />
  125. </el-form-item>
  126. </el-col>
  127. <el-col :offset="1" :span="22">
  128. <el-form-item label="缓存键名:" prop="cacheKey">
  129. <el-input v-model="cacheForm.cacheKey" :readOnly="true" />
  130. </el-form-item>
  131. </el-col>
  132. <el-col :offset="1" :span="22">
  133. <el-form-item label="缓存内容:" prop="cacheValue">
  134. <el-input
  135. v-model="cacheForm.cacheValue"
  136. type="textarea"
  137. :rows="8"
  138. :readOnly="true"
  139. />
  140. </el-form-item>
  141. </el-col>
  142. </el-row>
  143. </el-form>
  144. </el-card>
  145. </el-col>
  146. </el-row>
  147. </div>
  148. </template>
  149. <script>
  150. import { listCacheName, listCacheKey, getCacheValue, clearCacheName, clearCacheKey, clearCacheAll } from "@/api/monitor/cache";
  151. export default {
  152. name: "CacheList",
  153. data() {
  154. return {
  155. cacheNames: [],
  156. cacheKeys: [],
  157. cacheForm: {},
  158. loading: true,
  159. subLoading: false,
  160. nowCacheName: "",
  161. tableHeight: window.innerHeight - 200
  162. };
  163. },
  164. created() {
  165. this.getCacheNames();
  166. },
  167. methods: {
  168. /** 查询缓存名称列表 */
  169. getCacheNames() {
  170. this.loading = true;
  171. listCacheName().then(response => {
  172. this.cacheNames = response.data;
  173. this.loading = false;
  174. });
  175. },
  176. /** 刷新缓存名称列表 */
  177. refreshCacheNames() {
  178. this.getCacheNames();
  179. this.$modal.msgSuccess("刷新缓存列表成功");
  180. },
  181. /** 清理指定名称缓存 */
  182. handleClearCacheName(row) {
  183. clearCacheName(row.cacheName).then(response => {
  184. this.$modal.msgSuccess("清理缓存名称[" + row.cacheName + "]成功");
  185. this.getCacheKeys();
  186. });
  187. },
  188. /** 查询缓存键名列表 */
  189. getCacheKeys(row) {
  190. const cacheName = row !== undefined ? row.cacheName : this.nowCacheName;
  191. if (cacheName === "") {
  192. return;
  193. }
  194. this.subLoading = true;
  195. listCacheKey(cacheName).then(response => {
  196. this.cacheKeys = response.data;
  197. this.subLoading = false;
  198. this.nowCacheName = cacheName;
  199. });
  200. },
  201. /** 刷新缓存键名列表 */
  202. refreshCacheKeys() {
  203. this.getCacheKeys();
  204. this.$modal.msgSuccess("刷新键名列表成功");
  205. },
  206. /** 清理指定键名缓存 */
  207. handleClearCacheKey(cacheKey) {
  208. clearCacheKey(cacheKey).then(response => {
  209. this.$modal.msgSuccess("清理缓存键名[" + cacheKey + "]成功");
  210. this.getCacheKeys();
  211. });
  212. },
  213. /** 列表前缀去除 */
  214. nameFormatter(row) {
  215. return row.cacheName.replace(":", "");
  216. },
  217. /** 键名前缀去除 */
  218. keyFormatter(cacheKey) {
  219. return cacheKey.replace(this.nowCacheName, "");
  220. },
  221. /** 查询缓存内容详细 */
  222. handleCacheValue(cacheKey) {
  223. getCacheValue(this.nowCacheName, cacheKey).then(response => {
  224. this.cacheForm = response.data;
  225. });
  226. },
  227. /** 清理全部缓存 */
  228. handleClearCacheAll() {
  229. clearCacheAll().then(response => {
  230. this.$modal.msgSuccess("清理全部缓存成功");
  231. });
  232. }
  233. },
  234. };
  235. </script>