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