list.vue 7.5 KB

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