超管权限,缓存管理

This commit is contained in:
陈红丽 2024-08-02 16:34:44 +08:00
parent c34dfa5cf8
commit 3ee85454a6
4 changed files with 191 additions and 7 deletions

31
src/api/monitor/cache.ts Normal file
View File

@ -0,0 +1,31 @@
import { http } from '@/utils/http/axios';
/**
* @description:
*/
export function getCacheNames(params?) {
return http.request({
url: '/cache/getNames',
method: 'GET',
params,
});
}
/**
* @description: key列表
*/
export function getCacheKeys(cacheName) {
return http.request({
url: '/cache/getKeys/'+cacheName,
method: 'get',
});
}
/**
* @description: value列表
*/
export function getCacheValue(params?) {
return http.request({
url: '/cache/getValue',
method: 'get',
params
});
}

View File

@ -9,6 +9,9 @@ export function usePermission() {
*/ */
function _somePermissions(accesses: string[]) { function _somePermissions(accesses: string[]) {
const permissionsList = userStore.getPermissions; const permissionsList = userStore.getPermissions;
if(permissionsList[0]=='*:*:*') {
return true
}
return accesses.some((item) => { return accesses.some((item) => {
return permissionsList.includes(item); return permissionsList.includes(item);
}); });
@ -29,6 +32,9 @@ export function usePermission() {
*/ */
function hasEveryPermission(accesses: string[]): boolean { function hasEveryPermission(accesses: string[]): boolean {
const permissionsList = userStore.getPermissions; const permissionsList = userStore.getPermissions;
if(permissionsList[0]=='*:*:*') {
return true
}
if (Array.isArray(accesses)) { if (Array.isArray(accesses)) {
return accesses.every((access: any) => permissionsList.includes(access)); return accesses.every((access: any) => permissionsList.includes(access));
} }
@ -42,6 +48,9 @@ export function usePermission() {
*/ */
function hasSomePermission(accesses: string[]): boolean { function hasSomePermission(accesses: string[]): boolean {
const permissionsList = userStore.getPermissions; const permissionsList = userStore.getPermissions;
if(permissionsList[0]=='*:*:*') {
return true
}
if (Array.isArray(accesses)) { if (Array.isArray(accesses)) {
return accesses.some((access: any) => permissionsList.includes(access)); return accesses.some((access: any) => permissionsList.includes(access));
} }

View File

@ -365,13 +365,13 @@
click: () => openAppSearch(), click: () => openAppSearch(),
}, },
}, },
{ // {
icon: GithubOutlined, // icon: GithubOutlined,
tips: 'github', // tips: 'github',
eventObject: { // eventObject: {
click: () => window.open('https://github.com/jekip/naive-ui-admin'), // click: () => window.open('https://github.com/jekip/naive-ui-admin'),
}, // },
}, // },
{ {
icon: LockOutlined, icon: LockOutlined,
tips: '锁屏', tips: '锁屏',

View File

@ -0,0 +1,144 @@
<template>
<PageWrapper>
<div class="cache-box">
<el-card :bordered="false" header="缓存列表">
<el-table empty-text="暂无数据" border :height="fwbHeight" :data="cacheNameData" row-key="cacheName"
ref="cacheNameTable" highlight-current-row @row-click="onCheckedCacheName">
<el-table-column type="index" width="80" align="center" label="序号"></el-table-column>
<el-table-column show-overflow-tooltip align="center" label="缓存名称" prop="cacheName"
min-width="100"></el-table-column>
<el-table-column show-overflow-tooltip align="center" label="备注" prop="message"></el-table-column>
<el-table-column align="center" label="操作" width="60" fixed="right">
<template #default="{ row}">
<el-icon :color="`var(--el-color-danger)`" size="16" @click="handleDelete(row)" style="cursor: pointer;"><Delete /></el-icon>
</template>
</el-table-column>
</el-table>
</el-card>
<el-card :bordered="false" header="键名列表">
<el-table empty-text="暂无数据" border :height="fwbHeight" :data="cacheKeyData" row-key="cacheKey"
ref="cacheKeyTable" highlight-current-row @row-click="onCheckedCachKey">
<el-table-column type="index" width="80" align="center" label="序号"></el-table-column>
<el-table-column show-overflow-tooltip align="center" label="缓存键名" prop="cacheKey" min-width="100"></el-table-column>
<el-table-column align="center" label="操作" width="60" fixed="right">
<template #default="{ row}">
<el-icon :color="`var(--el-color-danger)`" size="16" @click="handleDelete(row)" style="cursor: pointer;"><Delete /></el-icon>
</template>
</el-table-column>
</el-table>
</el-card>
<el-card :bordered="false" header="缓存内容">
<el-form ref="form" :model="formData" label-width="80px" label-position="top" v-if="cacheKeyData.length > 0">
<el-form-item label="缓存名称:">
<el-input v-model="formData.cacheName"></el-input>
</el-form-item>
<el-form-item label="缓存键值:">
<el-input v-model="formData.cacheKey"></el-input>
</el-form-item>
<el-form-item label="缓存内容:">
<el-input v-model="formData.cacheValue" type="textarea"></el-input>
</el-form-item>
</el-form>
<div v-else>暂无数据</div>
</el-card>
</div>
</PageWrapper>
</template>
<script lang="ts" setup>
import { ref, onMounted,nextTick,reactive } from 'vue';
import { getCacheNames, getCacheKeys, getCacheValue } from '@/api/monitor/cache';
import { message, confirm } from "@/utils/auth";
const cacheNameTable = ref()
const cacheKeyTable = ref()
const cacheNameData = ref([])
const cacheKeyData = ref([])
const formData = reactive({
cacheKey:"",
cacheName:"",
cacheValue:"",
message:''
})
const cacheName = ref('')
const cacheKey = ref('')
const fwbHeight = document.body.clientHeight -230
//
const onCheckedCacheName = (row) => {
cacheName.value = row.cacheName
loadCachekeys()
}
//key
const onCheckedCachKey = (row) => {
cacheKey.value = row.cacheKey
loadCacheValue()
}
//
const loadCacheNames = async () => {
const result = await getCacheNames();
cacheNameData.value = result
cacheName.value = result.length > 0 ? result[0].cacheName : ''
if (cacheName.value) {
nextTick(() => {
cacheNameTable.value.setCurrentRow(result[0])
})
loadCachekeys()
}
};
//key
const loadCachekeys = async () => {
let datas = []
const result = await getCacheKeys(cacheName.value);
result.map(item=>{
datas.push({
cacheKey:item.split(':')[1]
})
})
cacheKeyData.value = datas
cacheKey.value = datas.length > 0 ? datas[0].cacheKey : ''
if (cacheKey.value) {
nextTick(() => {
cacheKeyTable.value.setCurrentRow(datas[0])
})
loadCacheValue()
}
};
//value
const loadCacheValue = async () => {
const data = await getCacheValue({ cacheName: cacheName.value,cacheKey:cacheKey.value });
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
formData[key] = data[key];
}
}
}
const handleDelete = async(row)=> {
await confirm('确定要删除?');
// await onlineOut(row.tokenId)
message("删除成功");
// loadTable()
}
onMounted(() => {
loadCacheNames()
})
</script>
<style lang="scss" scoped>
.cache-box {
display: flex;
>.el-card {
flex: 1;
&:nth-child(2) {
margin:0 15px;
}
}
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
</style>