RuoYi
2025-04-27 2f8a257efd2b64dc40666b0d332edb7824a9768d
src/views/monitor/cache/list.vue
@@ -4,10 +4,11 @@
      <el-col :span="8">
        <el-card style="height: calc(100vh - 125px)">
          <template #header>
            <span>缓存列表</span>
            <Collection style="width: 1em; height: 1em; vertical-align: middle;" /> <span style="vertical-align: middle;">缓存列表</span>
            <el-button
              style="float: right; padding: 3px 0"
              type="text"
              link
              type="primary"
              icon="Refresh"
              @click="refreshCacheNames()"
            ></el-button>
@@ -48,7 +49,8 @@
            >
              <template #default="scope">
                <el-button
                  type="text"
                  link
                  type="primary"
                  icon="Delete"
                  @click="handleClearCacheName(scope.row)"
                ></el-button>
@@ -61,10 +63,11 @@
      <el-col :span="8">
        <el-card style="height: calc(100vh - 125px)">
          <template #header>
            <span>键名列表</span>
            <Key style="width: 1em; height: 1em; vertical-align: middle;" /> <span style="vertical-align: middle;">键名列表</span>
            <el-button
              style="float: right; padding: 3px 0"
              type="text"
              link
              type="primary"
              icon="Refresh"
              @click="refreshCacheKeys()"
            ></el-button>
@@ -97,7 +100,8 @@
            >
              <template #default="scope">
                <el-button
                  type="text"
                  link
                  type="primary"
                  icon="Delete"
                  @click="handleClearCacheKey(scope.row)"
                ></el-button>
@@ -110,10 +114,11 @@
      <el-col :span="8">
        <el-card :bordered="false" style="height: calc(100vh - 125px)">
          <template #header>
            <span>缓存内容</span>
            <Document style="width: 1em; height: 1em; vertical-align: middle;" /> <span style="vertical-align: middle;">缓存内容</span>
            <el-button
              style="float: right; padding: 3px 0"
              type="text"
              link
              type="primary"
              icon="Refresh"
              @click="handleClearCacheAll()"
              >清理全部</el-button
@@ -150,92 +155,92 @@
</template>
<script setup name="CacheList">
import { listCacheName, listCacheKey, getCacheValue, clearCacheName, clearCacheKey, clearCacheAll } from "@/api/monitor/cache";
import { listCacheName, listCacheKey, getCacheValue, clearCacheName, clearCacheKey, clearCacheAll } from "@/api/monitor/cache"
const { proxy } = getCurrentInstance();
const { proxy } = getCurrentInstance()
const cacheNames = ref([]);
const cacheKeys = ref([]);
const cacheForm = ref({});
const loading = ref(true);
const subLoading = ref(false);
const nowCacheName = ref("");
const tableHeight = ref(window.innerHeight - 200);
const cacheNames = ref([])
const cacheKeys = ref([])
const cacheForm = ref({})
const loading = ref(true)
const subLoading = ref(false)
const nowCacheName = ref("")
const tableHeight = ref(window.innerHeight - 200)
/** 查询缓存名称列表 */
function getCacheNames() {
  loading.value = true;
  loading.value = true
  listCacheName().then(response => {
    cacheNames.value = response.data;
    loading.value = false;
  });
    cacheNames.value = response.data
    loading.value = false
  })
}
/** 刷新缓存名称列表 */
function refreshCacheNames() {
  getCacheNames();
  proxy.$modal.msgSuccess("刷新缓存列表成功");
  getCacheNames()
  proxy.$modal.msgSuccess("刷新缓存列表成功")
}
/** 清理指定名称缓存 */
function handleClearCacheName(row) {
  clearCacheName(row.cacheName).then(response => {
    proxy.$modal.msgSuccess("清理缓存名称[" + nowCacheName.value + "]成功");
    getCacheKeys();
  });
    proxy.$modal.msgSuccess("清理缓存名称[" + row.cacheName + "]成功")
    getCacheKeys()
  })
}
/** 查询缓存键名列表 */
function getCacheKeys(row) {
  const cacheName = row !== undefined ? row.cacheName : nowCacheName.value;
  const cacheName = row !== undefined ? row.cacheName : nowCacheName.value
  if (cacheName === "") {
    return;
    return
  }
  subLoading.value = true;
  subLoading.value = true
  listCacheKey(cacheName).then(response => {
    cacheKeys.value = response.data;
    subLoading.value = false;
    nowCacheName.value = cacheName;
  });
    cacheKeys.value = response.data
    subLoading.value = false
    nowCacheName.value = cacheName
  })
}
/** 刷新缓存键名列表 */
function refreshCacheKeys() {
  getCacheKeys();
  proxy.$modal.msgSuccess("刷新键名列表成功");
  getCacheKeys()
  proxy.$modal.msgSuccess("刷新键名列表成功")
}
/** 清理指定键名缓存 */
function handleClearCacheKey(cacheKey) {
  clearCacheKey(cacheKey).then(response => {
    proxy.$modal.msgSuccess("清理缓存键名[" + cacheKey + "]成功");
    getCacheKeys();
  });
    proxy.$modal.msgSuccess("清理缓存键名[" + cacheKey + "]成功")
    getCacheKeys()
  })
}
/** 列表前缀去除 */
function nameFormatter(row) {
  return row.cacheName.replace(":", "");
  return row.cacheName.replace(":", "")
}
/** 键名前缀去除 */
function keyFormatter(cacheKey) {
  return cacheKey.replace(nowCacheName.value, "");
  return cacheKey.replace(nowCacheName.value, "")
}
/** 查询缓存内容详细 */
function handleCacheValue(cacheKey) {
  getCacheValue(nowCacheName.value, cacheKey).then(response => {
    cacheForm.value = response.data;
  });
    cacheForm.value = response.data
  })
}
/** 清理全部缓存 */
function handleClearCacheAll() {
  clearCacheAll().then(response => {
    proxy.$modal.msgSuccess("清理全部缓存成功");
  });
    proxy.$modal.msgSuccess("清理全部缓存成功")
  })
}
getCacheNames();
getCacheNames()
</script>