|
@@ -0,0 +1,122 @@
|
|
|
+<script setup lang="ts">
|
|
|
+import * as api from "@/api/cache-flushed/cacheFlushed";
|
|
|
+import { CyJsonEditorDialog } from "@/components/cy/cy-monaco-editor/CyMonacoEditor";
|
|
|
+import { delByKey } from "@/api/cache-flushed/cacheFlushed";
|
|
|
+import { CyMessageBox } from "@/utils/cy-message-box";
|
|
|
+import XEUtils from "xe-utils";
|
|
|
+
|
|
|
+const store = reactive({
|
|
|
+ label: {},
|
|
|
+ currentLabelKey: "",
|
|
|
+ cacheAll: [],
|
|
|
+ search: "",
|
|
|
+});
|
|
|
+
|
|
|
+function allLabel() {
|
|
|
+ return api.getAllLabel().then(data => {
|
|
|
+ store.label = data;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function handleClickLabel(key) {
|
|
|
+ store.currentLabelKey = key;
|
|
|
+ api.getAllCacheByKey(key).then(data => {
|
|
|
+ store.cacheAll = data;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+async function handleClickRefresh() {
|
|
|
+ await allLabel();
|
|
|
+ handleClickLabel(store.currentLabelKey);
|
|
|
+}
|
|
|
+
|
|
|
+function handleDetails(row) {
|
|
|
+ CyJsonEditorDialog(row.value);
|
|
|
+}
|
|
|
+
|
|
|
+async function handleDelByKey(row, index) {
|
|
|
+ await CyMessageBox.confirm({
|
|
|
+ type: "delete",
|
|
|
+ message: "是否删除",
|
|
|
+ });
|
|
|
+ delByKey(store.currentLabelKey, row.key);
|
|
|
+ store.cacheAll.splice(index, 1);
|
|
|
+}
|
|
|
+
|
|
|
+const tmpData = computed(() => {
|
|
|
+ if (store.search !== "") {
|
|
|
+ return XEUtils.filter(store.cacheAll, i => {
|
|
|
+ return (i.key as string).includes(store.search);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return store.cacheAll;
|
|
|
+});
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ allLabel();
|
|
|
+});
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="layout_container">
|
|
|
+ <header class="layout_card">
|
|
|
+ <el-input style="width: 220px" v-model="store.search" clearable />
|
|
|
+ <el-button @click="handleClickRefresh">刷新</el-button>
|
|
|
+ </header>
|
|
|
+
|
|
|
+ <div class="layout_main">
|
|
|
+ <div class="layout_container layout-horizontal">
|
|
|
+ <aside style="overflow: auto; width: 190px" class="layout_card">
|
|
|
+ <div
|
|
|
+ v-for="(value, key) in store.label"
|
|
|
+ :key="key"
|
|
|
+ class="cache-flushed__label"
|
|
|
+ :class="{ 'is-select': key === store.currentLabelKey }"
|
|
|
+ @click="handleClickLabel(key)"
|
|
|
+ >
|
|
|
+ {{ value }}
|
|
|
+ </div>
|
|
|
+ </aside>
|
|
|
+
|
|
|
+ <div class="layout_main">
|
|
|
+ <el-table
|
|
|
+ border
|
|
|
+ :data="tmpData"
|
|
|
+ max-height="100%"
|
|
|
+ :row-style="{ height: '80px' }"
|
|
|
+ >
|
|
|
+ <el-table-column prop="key" label="key" width="100" />
|
|
|
+ <el-table-column prop="value" label="value" show-overflow-tooltip>
|
|
|
+ <template #default="scope">
|
|
|
+ {{ JSON.stringify(scope.row.value) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="200">
|
|
|
+ <template #default="{ row, $index }">
|
|
|
+ <el-button @click="handleDetails(row)">详情</el-button>
|
|
|
+ <el-button @click="handleDelByKey(row, $index)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style lang="scss">
|
|
|
+.cache-flushed__label {
|
|
|
+ font-size: 18px;
|
|
|
+ padding: 10px;
|
|
|
+ border: 1px solid var(--el-border-color);
|
|
|
+ border-radius: 10px;
|
|
|
+ margin: 5px 0;
|
|
|
+ cursor: pointer;
|
|
|
+ user-select: none;
|
|
|
+
|
|
|
+ &.is-select {
|
|
|
+ background-color: var(--el-color-primary);
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|