index.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <div style="padding: 8px">
  3. <el-card shadow="never">
  4. <el-table v-loading="state.loading" :data="state.cacheListData" row-key="id" style="width: 100%">
  5. <el-table-column type="index" width="80" label="#" />
  6. <el-table-column prop="description" label="缓存名" />
  7. <el-table-column prop="name" label="键名" />
  8. <el-table-column prop="value" label="键值" />
  9. <el-table-column label="操作" width="180" fixed="right" header-align="center" align="center">
  10. <template #default="{ row }">
  11. <el-button v-auth="'api:admin:cache:clear'" icon="ele-Brush" size="small" text type="danger" @click="onClear(row)">清除</el-button>
  12. </template>
  13. </el-table-column>
  14. </el-table>
  15. </el-card>
  16. </div>
  17. </template>
  18. <script lang="ts" setup name="admin/cache">
  19. import { reactive, onMounted, getCurrentInstance } from 'vue'
  20. import { CacheApi } from '/@/api/admin/Cache'
  21. const { proxy } = getCurrentInstance() as any
  22. defineProps({
  23. title: {
  24. type: String,
  25. default: '',
  26. },
  27. })
  28. const state = reactive({
  29. loading: false,
  30. cacheListData: [] as any,
  31. })
  32. onMounted(() => {
  33. onQuery()
  34. })
  35. const onQuery = async () => {
  36. state.loading = true
  37. const res = await new CacheApi().getList().catch(() => {
  38. state.loading = false
  39. })
  40. state.cacheListData = res?.data ?? []
  41. state.loading = false
  42. }
  43. const onClear = (row: any) => {
  44. proxy.$modal
  45. .confirmDelete(`确定要清除【${row.description}】缓存?`, { icon: 'ele-Brush' })
  46. .then(async () => {
  47. await new CacheApi().clear({ cacheKey: row.value }, { loading: true, showSuccessMessage: true })
  48. onQuery()
  49. })
  50. .catch(() => {})
  51. }
  52. </script>
  53. <style scoped lang="scss"></style>