init: 初始系统模板

This commit is contained in:
TsMask
2023-09-05 14:38:23 +08:00
parent a5bc16ae4f
commit 1075c8ae4f
130 changed files with 22531 additions and 1 deletions

498
src/views/monitor/cache/index.vue vendored Normal file
View File

@@ -0,0 +1,498 @@
<script setup lang="ts">
import { useRoute } from 'vue-router';
import { reactive, ref, onMounted } from 'vue';
import {
listCacheName,
listCacheKey,
getCacheValue,
clearCacheName,
clearCacheKey,
clearCacheSafe,
} from '@/api/monitor/cache';
import { PageContainer } from '@ant-design-vue/pro-layout';
import { ColumnsType } from 'ant-design-vue/lib/table/Table';
import { message } from 'ant-design-vue/lib';
import { hasPermissions } from '@/plugins/auth-user';
const route = useRoute();
/**路由标题 */
let title = ref<string>(route.meta.title ?? '标题');
/**请求点击 */
let isClick = ref<boolean>(false);
/**缓存内容信息 */
let cacheKeyInfo = reactive({
loading: true,
data: {
cacheKey: '',
cacheName: '',
cacheValue: '',
remark: '',
},
});
/**
* 查询缓存内容详细
* @param cacheKey
*/
function fnCacheKeyInfo(cacheKey: string) {
if (!hasPermissions(['monitor:cache:query'])) return;
if (isClick.value) return;
isClick.value = true;
cacheKeyInfo.loading = true;
getCacheValue(cacheKeyTable.cacheName, cacheKey).then(res => {
isClick.value = false;
if (res.code === 200) {
cacheKeyInfo.data = Object.assign(cacheKeyInfo.data, res.data);
cacheKeyInfo.loading = false;
}
});
}
/**键名列表表格字段列 */
let cacheKeyTableColumns: ColumnsType = [
{
title: '序号',
dataIndex: 'num',
width: '50px',
align: 'center',
customRender(opt) {
return opt.index + 1;
},
},
{
title: '缓存键名',
dataIndex: 'cacheKey',
align: 'left',
ellipsis: true,
// 渲染值处理
customRender(opt) {
return opt.text;
},
// 自定义过滤控件
customFilterDropdown: true,
onFilter: (value, record) => {
if (typeof value === 'string') {
const nameLower = record.cacheKey.toLowerCase();
return nameLower.includes(value.toLowerCase());
}
},
},
{
title: '操作',
key: 'option',
align: 'center',
width: '50px',
},
];
/**键名列表表格数据 */
let cacheKeyTable = reactive({
loading: true,
data: [],
/**当前键名列表的缓存名称 */
cacheName: '',
});
/**
* 清理指定缓存键名
* @param cacheKey 键名列表中的缓存键名
*/
function fnCacheKeyClear(cacheKey: string) {
if (isClick.value) return;
isClick.value = true;
const hide = message.loading('请稍等...', 0);
clearCacheKey(cacheKeyTable.cacheName, cacheKey).then(res => {
hide();
isClick.value = false;
if (res.code === 200) {
message.success({
content: `已删除缓存键名 ${cacheKey}`,
duration: 3,
});
// 缓存内容显示且是删除的缓存键名,需要进行加载显示
if (!cacheKeyInfo.loading && cacheKeyInfo.data.cacheKey === cacheKey) {
cacheKeyInfo.loading = true;
}
} else {
message.error({
content: res.msg,
duration: 3,
});
}
fnCacheKeyList();
});
}
/** 查询缓存键名列表 */
function fnCacheKeyList(cacheName: string = 'load') {
if (cacheName === 'load') {
cacheName = cacheKeyTable.cacheName;
}
if (!cacheName) {
message.warning('请在缓存列表中选择数据项!', 3);
return;
}
if (isClick.value) return;
isClick.value = true;
cacheKeyTable.loading = true;
listCacheKey(cacheName).then(res => {
isClick.value = false;
if (res.code === 200 && res.data) {
cacheKeyTable.cacheName = cacheName;
cacheKeyTable.data = res.data;
cacheKeyTable.loading = false;
}
});
}
/**缓存列表表格数据 */
let cacheNameTable = reactive({
loading: true,
data: [],
});
/**缓存列表表格字段列 */
let cacheNameTableColumns: ColumnsType = [
{
title: '序号',
dataIndex: 'num',
width: '50px',
align: 'center',
customRender(opt) {
return opt.index + 1;
},
},
{
title: '缓存名称',
dataIndex: 'cacheName',
align: 'left',
ellipsis: true,
// 渲染值处理
customRender(opt) {
return opt.text;
},
// 自定义过滤控件
customFilterDropdown: true,
onFilter: (value, record) => {
if (typeof value === 'string') {
const nameLower = record.cacheName.toLowerCase();
return nameLower.includes(value.toLowerCase());
}
},
},
{
title: '备注',
dataIndex: 'remark',
align: 'left',
ellipsis: true,
},
{
title: '操作',
key: 'option',
align: 'center',
width: '50px',
},
];
/**安全清理缓存 */
function fnClearCacheSafe() {
if (isClick.value) return;
isClick.value = true;
const hide = message.loading('请稍等...', 0);
clearCacheSafe().then(res => {
hide();
isClick.value = false;
if (res.code === 200) {
message.success({
content: '已完成安全清理缓存',
duration: 3,
});
cacheKeyTable.loading = true;
cacheKeyInfo.loading = true;
} else {
message.error({
content: res.msg,
duration: 3,
});
}
});
}
/**
* 清理指定缓存名称
* @param cacheName 缓存名称
*/
function fnCacheNameClear(cacheName: string) {
if (isClick.value) return;
isClick.value = true;
const hide = message.loading('请稍等...', 0);
clearCacheName(cacheName).then(res => {
hide();
isClick.value = false;
if (res.code === 200) {
message.success({
content: `已清理缓存名称 ${cacheName}`,
duration: 3,
});
// 缓存内容显示且是删除的缓存名称,需要进行加载显示
if (!cacheKeyInfo.loading && cacheKeyInfo.data.cacheName === cacheName) {
cacheKeyInfo.loading = true;
}
} else {
message.error({
content: res.msg,
duration: 3,
});
}
fnCacheKeyList(cacheName);
});
}
/**查询缓存名称列表 */
function fnCacheNameList() {
if (isClick.value) return;
isClick.value = true;
cacheNameTable.loading = true;
listCacheName().then(res => {
isClick.value = false;
if (res.code === 200 && res.data) {
cacheNameTable.data = res.data;
cacheNameTable.loading = false;
}
});
}
onMounted(() => {
fnCacheNameList();
});
</script>
<template>
<PageContainer :title="title">
<template #content>
<a-typography-paragraph>
系统在缓存
<a-typography-text code>Redis</a-typography-text>
应用程序中的可控的缓存信息
</a-typography-paragraph>
</template>
<a-row :gutter="20">
<a-col :lg="8" :md="8" :xs="24">
<a-card
title="缓存列表"
:bordered="false"
:body-style="{ marginBottom: '24px', padding: 0 }"
>
<template #extra>
<a-space :size="8" align="center">
<a-tooltip>
<template #title>刷新</template>
<a-button type="text" @click.prevent="fnCacheNameList">
<template #icon><ReloadOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>安全清理</template>
<a-popconfirm
placement="bottomRight"
title="确认要执行可安全清理的缓存下所有键名吗?`"
ok-text="确认"
cancel-text="取消"
@confirm="fnClearCacheSafe()"
>
<a-button type="text" v-perms:has="['monitor:cache:remove']">
<template #icon><ClearOutlined /></template>
</a-button>
</a-popconfirm>
</a-tooltip>
</a-space>
</template>
<a-table
row-key="cacheName"
size="small"
:columns="cacheNameTableColumns"
:data-source="cacheNameTable.data"
:loading="cacheNameTable.loading"
:row-selection="{
type: 'radio',
onChange: (selectedRowKeys: (string|number)[]) => fnCacheKeyList(selectedRowKeys[0] as string),
}"
:pagination="false"
>
<template
#customFilterDropdown="{
setSelectedKeys,
selectedKeys,
confirm,
clearFilters,
column,
}"
>
<div style="padding: 8px">
<a-input
:placeholder="`模糊过滤 ${column.title}`"
:value="selectedKeys[0]"
style="width: 188px; margin-bottom: 8px; display: block"
@change="
e => setSelectedKeys(e.target.value ? [e.target.value] : [])
"
@pressEnter="confirm()"
/>
<a-button
type="primary"
size="small"
style="width: 90px; margin-right: 8px"
@click="confirm()"
>
过滤
</a-button>
<a-button
size="small"
style="width: 90px"
@click="clearFilters({ confirm: true })"
>
重置
</a-button>
</div>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'option'">
<a-popconfirm
placement="topRight"
title="确认要清理该缓存名称下的所有键名吗?`"
ok-text="确认"
cancel-text="取消"
@confirm="fnCacheNameClear(record.cacheName)"
>
<a-button type="text" v-perms:has="['monitor:cache:remove']">
<template #icon><ClearOutlined /></template>
</a-button>
</a-popconfirm>
</template>
</template>
</a-table>
</a-card>
</a-col>
<a-col :lg="8" :md="8" :xs="24">
<a-card
title="键名列表"
:bordered="false"
:body-style="{ marginBottom: '24px', padding: 0 }"
>
<template #extra>
<a-tooltip>
<template #title>刷新</template>
<a-button type="text" @click.prevent="fnCacheKeyList()">
<template #icon><ReloadOutlined /></template>
</a-button>
</a-tooltip>
</template>
<a-table
row-key="cacheKey"
size="small"
:columns="cacheKeyTableColumns"
:data-source="cacheKeyTable.data"
:loading="cacheKeyTable.loading"
:row-selection="{
type: 'radio',
onChange: (selectedRowKeys: (string|number)[]) => fnCacheKeyInfo(selectedRowKeys[0] as string),
}"
:pagination="false"
>
<template
#customFilterDropdown="{
setSelectedKeys,
selectedKeys,
confirm,
clearFilters,
column,
}"
>
<div style="padding: 8px">
<a-input
:placeholder="`模糊过滤 ${column.title}`"
:value="selectedKeys[0]"
style="width: 188px; margin-bottom: 8px; display: block"
@change="
e => setSelectedKeys(e.target.value ? [e.target.value] : [])
"
@pressEnter="confirm()"
/>
<a-button
type="primary"
size="small"
style="width: 90px; margin-right: 8px"
@click="confirm()"
>
过滤
</a-button>
<a-button
size="small"
style="width: 90px"
@click="clearFilters({ confirm: true })"
>
重置
</a-button>
</div>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'option'">
<a-popconfirm
placement="topRight"
title="确认要删除该缓存键吗?`"
ok-text="确认"
cancel-text="取消"
@confirm="fnCacheKeyClear(record.cacheKey)"
>
<a-button type="text" v-perms:has="['monitor:cache:remove']">
<template #icon><DeleteOutlined /></template>
</a-button>
</a-popconfirm>
</template>
</template>
</a-table>
</a-card>
</a-col>
<a-col :lg="8" :md="8" :xs="24" v-perms:has="['monitor:cache:query']">
<a-card
title="缓存内容"
:bordered="false"
:body-style="{ marginBottom: '24px', padding: 0 }"
:loading="cacheKeyInfo.loading"
>
<a-descriptions
size="small"
layout="vertical"
:bordered="true"
:column="1"
>
<a-descriptions-item label="缓存名称">
{{ cacheKeyInfo.data.cacheName }}
</a-descriptions-item>
<a-descriptions-item label="缓存键名">
{{ cacheKeyInfo.data.cacheKey }}
</a-descriptions-item>
<a-descriptions-item label="缓存内容">
<a-typography-paragraph>
<a-textarea
:value="cacheKeyInfo.data.cacheValue"
:auto-size="{ minRows: 4, maxRows: 10 }"
:maxlength="4000"
:disabled="true"
placeholder="显示缓存内容"
/>
</a-typography-paragraph>
</a-descriptions-item>
</a-descriptions>
</a-card>
</a-col>
</a-row>
</PageContainer>
</template>
<style lang="less" scoped></style>

222
src/views/monitor/cache/info.vue vendored Normal file
View File

@@ -0,0 +1,222 @@
<script setup lang="ts">
import * as echarts from 'echarts/core';
import {
ToolboxComponent,
ToolboxComponentOption,
TooltipComponent,
TooltipComponentOption,
LegendComponent,
LegendComponentOption,
} from 'echarts/components';
import { PieChart, PieSeriesOption } from 'echarts/charts';
import { LabelLayout } from 'echarts/features';
import { CanvasRenderer } from 'echarts/renderers';
import { PageContainer } from '@ant-design-vue/pro-layout';
import { getCache } from '@/api/monitor/cache';
import { reactive, ref, onMounted } from 'vue';
import { useRoute } from 'vue-router';
const route = useRoute();
echarts.use([
ToolboxComponent,
TooltipComponent,
LegendComponent,
PieChart,
CanvasRenderer,
LabelLayout,
]);
/**路由标题 */
let title = ref<string>(route.meta.title ?? '标题');
/**加载状态 */
let loading = ref<boolean>(true);
/**数据参数类型 */
type CacheType = {
/**服务信息 */
info: InfoType;
/**当前连接可用键Key总数 */
dbSize: number;
/**命令状态 */
commandStats: Record<string, string>[];
};
/**数据参数服务信息类型 */
type InfoType = {
clients: Record<string, string>;
cluster: Record<string, string>;
cpu: Record<string, string>;
errorstats: Record<string, string>;
keyspace: Record<string, string>;
memory: Record<string, string>;
modules: Record<string, string>;
persistence: Record<string, string>;
replication: Record<string, string>;
server: Record<string, string>;
stats: Record<string, string>;
};
let cache: CacheType = reactive({
info: {
clients: {},
cluster: {},
cpu: {},
errorstats: {},
keyspace: {},
memory: {},
modules: {},
persistence: {},
replication: {},
server: {},
stats: {},
},
dbSize: 0,
commandStats: [],
});
/**生成命令统计图 */
function commandStatsChart() {
const commandStatsDom = document.getElementById('commandstats');
if (!commandStatsDom) return;
const commandStatsEchart = echarts.init(commandStatsDom);
const option: echarts.ComposeOption<
| ToolboxComponentOption
| TooltipComponentOption
| LegendComponentOption
| PieSeriesOption
> = {
// 鼠标悬浮提示
tooltip: {
trigger: 'item',
formatter: '{a} <br/>{b} : {c} ({d}%)',
},
// 左侧标签
legend: {
orient: 'vertical',
left: 'left',
},
// 右侧工具
toolbox: {
show: true,
feature: {
mark: { show: true },
dataView: { show: true, readOnly: false },
restore: { show: true },
saveAsImage: { show: true },
},
},
series: [
{
name: '命令',
type: 'pie',
radius: ['5%', '80%'],
center: ['60%', '50%'],
roseType: 'area',
itemStyle: {
borderRadius: 8,
},
data: cache.commandStats,
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)',
},
},
},
],
};
commandStatsEchart.setOption(option);
window.addEventListener('resize', function () {
commandStatsEchart.resize();
});
}
onMounted(() => {
getCache()
.then(res => {
if (res.code === 200 && res.data) {
cache.info = res.data.info;
cache.dbSize = res.data.dbSize;
cache.commandStats = res.data.commandStats;
// 加载状态
loading.value = false;
}
})
.then(() => {
// 加载结束后生成图
commandStatsChart();
});
});
</script>
<template>
<PageContainer :title="title" :loading="loading">
<template #content>
<a-typography-paragraph>
缓存
<a-typography-text code>Redis</a-typography-text>
应用程序的信息
</a-typography-paragraph>
</template>
<a-card
title="基本信息"
:bordered="false"
:body-style="{ marginBottom: '24px', padding: 0 }"
>
<a-descriptions
size="middle"
layout="horizontal"
:label-style="{ width: '140px' }"
:bordered="true"
:column="{ lg: 4, md: 2, xs: 1 }"
>
<a-descriptions-item label="Redis版本">
{{ cache.info.server.redis_version }}
</a-descriptions-item>
<a-descriptions-item label="运行模式">
{{ cache.info.server.redis_mode == 'standalone' ? '单机' : '集群' }}
</a-descriptions-item>
<a-descriptions-item label="端口">
{{ cache.info.server.tcp_port }}
</a-descriptions-item>
<a-descriptions-item label="客户端数">
{{ cache.info.clients.connected_clients }}
</a-descriptions-item>
<a-descriptions-item label="运行时间(天)">
{{ cache.info.server.uptime_in_days }}
</a-descriptions-item>
<a-descriptions-item label="使用内存">
{{ cache.info.memory.used_memory_human }}
</a-descriptions-item>
<a-descriptions-item label="使用CPU">
{{ parseFloat(cache.info.cpu.used_cpu_user_children).toFixed(2) }}
</a-descriptions-item>
<a-descriptions-item label="内存配置">
{{ cache.info.memory.maxmemory_human }}
</a-descriptions-item>
<a-descriptions-item label="AOF是否开启">
{{ cache.info.persistence.aof_enabled == '0' ? '否' : '是' }}
</a-descriptions-item>
<a-descriptions-item label="RDB是否成功">
{{ cache.info.persistence.rdb_last_bgsave_status }}
</a-descriptions-item>
<a-descriptions-item label="Key数量">
{{ cache.dbSize }}
</a-descriptions-item>
<a-descriptions-item label="网络入口/出口">
{{ cache.info.stats.instantaneous_input_kbps }} kps /
{{ cache.info.stats.instantaneous_output_kbps }} kps
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card title="命令统计" :bordered="false">
<div id="commandstats" style="height: 400px; width: 100%"></div>
</a-card>
</PageContainer>
</template>
<style lang="less" scoped></style>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,682 @@
<script setup lang="ts">
import { useRoute, useRouter } from 'vue-router';
import { reactive, ref, onMounted, toRaw } from 'vue';
import { PageContainer } from '@ant-design-vue/pro-layout';
import { message, Modal } from 'ant-design-vue/lib';
import { SizeType } from 'ant-design-vue/lib/config-provider';
import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface';
import { ColumnsType } from 'ant-design-vue/lib/table';
import {
exportJobLog,
listJobLog,
delJobLog,
cleanJobLog,
} from '@/api/monitor/jobLog';
import { getJob } from '@/api/monitor/job';
import { saveAs } from 'file-saver';
import { parseDateToStr } from '@/utils/date-utils';
import useTabsStore from '@/store/modules/tabs';
import useDictStore from '@/store/modules/dict';
const tabsStore = useTabsStore();
const { getDict } = useDictStore();
const route = useRoute();
const router = useRouter();
// 获取地址栏参数
const jobId = route.params && (route.params.jobId as string);
/**字典数据 */
let dict: {
/**任务组名 */
sysJobGroup: DictType[];
/**执行状态 */
sysCommonStatus: DictType[];
} = reactive({
sysJobGroup: [],
sysCommonStatus: [],
});
/**记录开始结束时间 */
let queryRangePicker = ref<[string, string]>(['', '']);
/**查询参数 */
let queryParams = reactive({
/**任务名称 */
jobName: '',
/**任务组名 */
jobGroup: undefined,
/**执行状态 */
status: undefined,
/**记录开始时间 */
beginTime: '',
/**记录结束时间 */
endTime: '',
/**当前页数 */
pageNum: 1,
/**每页条数 */
pageSize: 20,
});
/**查询参数重置 */
function fnQueryReset() {
if (jobId && jobId !== '0') {
queryParams = Object.assign(queryParams, {
status: undefined,
beginTime: '',
endTime: '',
pageNum: 1,
pageSize: 20,
});
} else {
queryParams = Object.assign(queryParams, {
jobName: '',
jobGroup: undefined,
status: undefined,
beginTime: '',
endTime: '',
pageNum: 1,
pageSize: 20,
});
}
queryRangePicker.value = ['', ''];
tablePagination.current = 1;
tablePagination.pageSize = 20;
fnGetList();
}
/**表格状态类型 */
type TabeStateType = {
/**加载等待 */
loading: boolean;
/**紧凑型 */
size: SizeType;
/**斑马纹 */
striped: boolean;
/**搜索栏 */
seached: boolean;
/**记录数据 */
data: object[];
/**勾选记录 */
selectedRowKeys: (string | number)[];
};
/**表格状态 */
let tableState: TabeStateType = reactive({
loading: false,
size: 'middle',
striped: false,
seached: true,
data: [],
selectedRowKeys: [],
});
/**表格字段列 */
let tableColumns: ColumnsType = [
{
title: '日志编号',
dataIndex: 'jobLogId',
align: 'center',
},
{
title: '任务名称',
dataIndex: 'jobName',
align: 'center',
},
{
title: '任务组名',
dataIndex: 'jobGroup',
key: 'jobGroup',
align: 'center',
},
{
title: '调用目标',
dataIndex: 'invokeTarget',
align: 'center',
},
{
title: '执行状态',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '记录时间',
dataIndex: 'createTime',
align: 'center',
customRender(opt) {
if (+opt.value <= 0) return '';
return parseDateToStr(+opt.value);
},
},
{
title: '消耗时间',
dataIndex: 'costTime',
key: 'costTime',
align: 'center',
customRender(opt) {
return `${opt.value} ms`;
},
},
{
title: '操作',
key: 'jobLogId',
align: 'center',
},
];
/**表格分页器参数 */
let tablePagination = reactive({
/**当前页数 */
current: 1,
/**每页条数 */
pageSize: 20,
/**默认的每页条数 */
defaultPageSize: 20,
/**指定每页可以显示多少条 */
pageSizeOptions: ['10', '20', '50', '100'],
/**只有一页时是否隐藏分页器 */
hideOnSinglePage: false,
/**是否可以快速跳转至某页 */
showQuickJumper: true,
/**是否可以改变 pageSize */
showSizeChanger: true,
/**数据总数 */
total: 0,
showTotal: (total: number) => `总共 ${total}`,
onChange: (page: number, pageSize: number) => {
tablePagination.current = page;
tablePagination.pageSize = pageSize;
queryParams.pageNum = page;
queryParams.pageSize = pageSize;
fnGetList();
},
});
/**表格紧凑型变更操作 */
function fnTableSize({ key }: MenuInfo) {
tableState.size = key as SizeType;
}
/**表格斑马纹 */
function fnTableStriped(_record: unknown, index: number) {
return tableState.striped && index % 2 === 1 ? 'table-striped' : undefined;
}
/**表格多选 */
function fnTableSelectedRowKeys(keys: (string | number)[]) {
tableState.selectedRowKeys = keys;
}
/**对话框对象信息状态类型 */
type ModalStateType = {
/**详情框是否显示 */
visibleByView: boolean;
/**标题 */
title: string;
/**表单数据 */
from: Record<string, any>;
};
/**对话框对象信息状态 */
let modalState: ModalStateType = reactive({
visibleByView: false,
title: '任务日志',
from: {
jobLogId: undefined,
jobName: '',
jobGroup: 'DEFAULT',
invokeTarget: '',
targetParams: '',
status: '0',
jobMsg: '',
createTime: 0,
},
});
/**
* 对话框弹出显示为 查看
* @param row 调度日志信息对象
*/
function fnModalVisibleByVive(row: Record<string, string>) {
modalState.from = Object.assign(modalState.from, row);
modalState.title = '调度日志信息';
modalState.visibleByView = true;
}
/**
* 对话框弹出关闭执行函数
*/
function fnModalCancel() {
modalState.visibleByView = false;
}
/**
* 任务删除
*/
function fnRecordDelete() {
const ids = tableState.selectedRowKeys.join(',');
Modal.confirm({
title: '提示',
content: `确认删除调度日志编号为 【${ids}】 的数据项吗?`,
onOk() {
const key = 'delJobLog';
message.loading({ content: '请稍等...', key });
delJobLog(ids).then(res => {
if (res.code === 200) {
message.success({
content: `删除成功`,
key,
duration: 2,
});
fnGetList();
} else {
message.error({
content: `${res.msg}`,
key,
duration: 2,
});
}
});
},
});
}
/**列表清空 */
function fnCleanList() {
Modal.confirm({
title: '提示',
content: `确认清空所有调度日志数据项吗?`,
onOk() {
const key = 'cleanJobLog';
message.loading({ content: '请稍等...', key });
cleanJobLog().then(res => {
if (res.code === 200) {
message.success({
content: `清空成功`,
key,
duration: 2,
});
fnGetList();
} else {
message.error({
content: `${res.msg}`,
key,
duration: 2,
});
}
});
},
});
}
/**列表导出 */
function fnExportList() {
Modal.confirm({
title: '提示',
content: `确认根据搜索条件导出xlsx表格文件吗?`,
onOk() {
const key = 'exportJobLog';
message.loading({ content: '请稍等...', key });
exportJobLog(toRaw(queryParams)).then(res => {
if (res.code === 200) {
message.success({
content: `已完成导出`,
key,
duration: 2,
});
saveAs(res.data, `job_log_${Date.now()}.xlsx`);
} else {
message.error({
content: `${res.msg}`,
key,
duration: 2,
});
}
});
},
});
}
/**关闭跳转 */
function fnClose() {
const to = tabsStore.tabClose(route.path);
if (to) {
router.push(to);
} else {
router.back();
}
}
/**查询调度日志列表 */
function fnGetList() {
tableState.loading = true;
queryParams.beginTime = queryRangePicker.value[0];
queryParams.endTime = queryRangePicker.value[1];
listJobLog(toRaw(queryParams)).then(res => {
if (res.code === 200) {
// 取消勾选
if (tableState.selectedRowKeys.length > 0) {
tableState.selectedRowKeys = [];
}
tablePagination.total = res.total;
tableState.data = res.rows;
tableState.loading = false;
}
});
}
onMounted(() => {
// 初始字典数据
Promise.allSettled([
getDict('sys_job_group'),
getDict('sys_common_status'),
]).then(resArr => {
if (resArr[0].status === 'fulfilled') {
dict.sysJobGroup = resArr[0].value;
}
if (resArr[1].status === 'fulfilled') {
dict.sysCommonStatus = resArr[1].value;
}
});
// 指定任务id数据列表
if (jobId && jobId !== '0') {
getJob(jobId).then(res => {
if (res.code === 200) {
queryParams.jobName = res.data.jobName;
queryParams.jobGroup = res.data.jobGroup;
fnGetList();
}
});
} else {
// 获取列表数据
fnGetList();
}
});
</script>
<template>
<PageContainer>
<a-card
v-show="tableState.seached"
:bordered="false"
:body-style="{ marginBottom: '24px', paddingBottom: 0 }"
>
<!-- 表格搜索栏 -->
<a-form :model="queryParams" name="queryParams" layout="horizontal">
<a-row :gutter="16">
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="任务名称" name="jobName">
<a-input
v-model:value="queryParams.jobName"
:allow-clear="jobId === '0'"
:disabled="jobId !== '0'"
placeholder="请输入任务名称"
></a-input>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="任务组名" name="jobGroup">
<a-select
v-model:value="queryParams.jobGroup"
allow-clear
placeholder="请选择菜单状态"
:options="dict.sysJobGroup"
>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="执行状态" name="status">
<a-select
v-model:value="queryParams.status"
allow-clear
placeholder="请选择执行状态"
:options="dict.sysCommonStatus"
>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="记录时间" name="queryRangePicker">
<a-range-picker
v-model:value="queryRangePicker"
allow-clear
bordered
value-format="YYYY-MM-DD"
:placeholder="['记录开始', '记录结束']"
style="width: 100%"
></a-range-picker>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item>
<a-space :size="8">
<a-button type="primary" @click.prevent="fnGetList">
<template #icon><SearchOutlined /></template>
搜索
</a-button>
<a-button type="default" @click.prevent="fnQueryReset">
<template #icon><ClearOutlined /></template>
重置
</a-button>
</a-space>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-card>
<a-card :bordered="false" :body-style="{ padding: '0px' }">
<!-- 插槽-卡片左侧侧 -->
<template #title>
<a-space :size="8" align="center">
<a-button type="default" @click.prevent="fnClose()">
<template #icon><CloseOutlined /></template>
关闭
</a-button>
<a-button
type="default"
danger
:disabled="tableState.selectedRowKeys.length <= 0"
@click.prevent="fnRecordDelete()"
v-perms:has="['monitor:job:remove']"
>
<template #icon><DeleteOutlined /></template>
删除
</a-button>
<a-button
type="dashed"
danger
@click.prevent="fnCleanList()"
v-perms:has="['monitor:job:remove']"
>
<template #icon><DeleteOutlined /></template>
清空
</a-button>
<a-button
type="dashed"
@click.prevent="fnExportList()"
v-perms:has="['monitor:job:export']"
>
<template #icon><ExportOutlined /></template>
导出
</a-button>
</a-space>
</template>
<!-- 插槽-卡片右侧 -->
<template #extra>
<a-space :size="8" align="center">
<a-tooltip>
<template #title>搜索栏</template>
<a-switch
v-model:checked="tableState.seached"
checked-children=""
un-checked-children=""
size="small"
/>
</a-tooltip>
<a-tooltip>
<template #title>表格斑马纹</template>
<a-switch
v-model:checked="tableState.striped"
checked-children=""
un-checked-children=""
size="small"
/>
</a-tooltip>
<a-tooltip>
<template #title>刷新</template>
<a-button type="text" @click.prevent="fnGetList">
<template #icon><ReloadOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>密度</template>
<a-dropdown trigger="click">
<a-button type="text">
<template #icon><ColumnHeightOutlined /></template>
</a-button>
<template #overlay>
<a-menu
:selected-keys="[tableState.size as string]"
@click="fnTableSize"
>
<a-menu-item key="default">默认</a-menu-item>
<a-menu-item key="middle">中等</a-menu-item>
<a-menu-item key="small">紧凑</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</a-tooltip>
</a-space>
</template>
<!-- 表格列表 -->
<a-table
class="table"
row-key="jobLogId"
:columns="tableColumns"
:loading="tableState.loading"
:data-source="tableState.data"
:size="tableState.size"
:row-class-name="fnTableStriped"
:scroll="{ x: true }"
:pagination="tablePagination"
:row-selection="{
type: 'checkbox',
onChange: fnTableSelectedRowKeys,
}"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'jobGroup'">
<DictTag :options="dict.sysJobGroup" :value="record.jobGroup" />
</template>
<template v-if="column.key === 'status'">
<a-tag :color="+record.status ? 'success' : 'error'">
{{ ['失败', '正常'][+record.status] }}
</a-tag>
</template>
<template v-if="column.key === 'jobLogId'">
<a-space :size="8" align="center">
<a-tooltip>
<template #title>查看详情</template>
<a-button
type="link"
@click.prevent="fnModalVisibleByVive(record)"
v-perms:has="['monitor:job:query']"
>
<template #icon><ProfileOutlined /></template>
详情
</a-button>
</a-tooltip>
</a-space>
</template>
</template>
</a-table>
</a-card>
<!-- 详情框 -->
<a-modal
width="800px"
:visible="modalState.visibleByView"
:title="modalState.title"
@cancel="fnModalCancel"
>
<a-form layout="horizontal">
<a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="日志编号" name="jobLogId">
{{ modalState.from.jobLogId }}
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="执行状态" name="status">
<a-tag :color="+modalState.from.status ? 'success' : 'error'">
{{ ['失败', '正常'][+modalState.from.status] }}
</a-tag>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="任务名称" name="jobName">
{{ modalState.from.jobName }}
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="任务组名" name="jobGroup">
<DictTag
:options="dict.sysJobGroup"
:value="modalState.from.jobGroup"
/>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="调用目标" name="invokeTarget">
{{ modalState.from.invokeTarget }}
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="记录时间" name="createTime">
<span v-if="+modalState.from.createTime > 0">
{{ parseDateToStr(+modalState.from.createTime) }}
</span>
</a-form-item>
</a-col>
</a-row>
<a-form-item label="传入参数" name="targetParams">
<a-textarea
v-model:value="modalState.from.targetParams"
:auto-size="{ minRows: 2, maxRows: 6 }"
placeholder="传入参数"
:disabled="true"
/>
</a-form-item>
<a-form-item label="日志信息" name="jobMsg">
<a-textarea
v-model:value="modalState.from.jobMsg"
:auto-size="{ minRows: 2, maxRows: 6 }"
placeholder="日志信息"
:disabled="true"
/>
</a-form-item>
</a-form>
<template #footer>
<a-button key="cancel" @click="fnModalCancel">关闭</a-button>
</template>
</a-modal>
</PageContainer>
</template>
<style lang="less" scoped>
.table :deep(.table-striped) td {
background-color: #fafafa;
}
.table :deep(.ant-pagination) {
padding: 0 24px;
}
</style>

View File

@@ -0,0 +1,546 @@
<script setup lang="ts">
import { useRoute } from 'vue-router';
import { reactive, ref, onMounted, toRaw } from 'vue';
import { PageContainer } from '@ant-design-vue/pro-layout';
import { message, Modal } from 'ant-design-vue/lib';
import { SizeType } from 'ant-design-vue/lib/config-provider';
import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface';
import { ColumnsType } from 'ant-design-vue/lib/table';
import {
exportLogininfor,
listLogininfor,
delLogininfor,
cleanLogininfor,
unlockLogininfor,
} from '@/api/monitor/logininfor';
import { saveAs } from 'file-saver';
import { parseDateToStr } from '@/utils/date-utils';
import useDictStore from '@/store/modules/dict';
const { getDict } = useDictStore();
const route = useRoute();
/**路由标题 */
let title = ref<string>(route.meta.title ?? '标题');
/**字典数据 */
let dict: {
/**登录状态 */
sysCommonStatus: DictType[];
} = reactive({
sysCommonStatus: [],
});
/**开始结束时间 */
let queryRangePicker = ref<[string, string]>(['', '']);
/**查询参数 */
let queryParams = reactive({
/**登录地址 */
ipaddr: '',
/**登录账号 */
userName: '',
/**登录状态 */
status: undefined,
/**开始时间 */
beginTime: '',
/**结束时间 */
endTime: '',
/**当前页数 */
pageNum: 1,
/**每页条数 */
pageSize: 20,
});
/**查询参数重置 */
function fnQueryReset() {
queryParams = Object.assign(queryParams, {
ipaddr: '',
userName: '',
status: undefined,
beginTime: '',
endTime: '',
pageNum: 1,
pageSize: 20,
});
queryRangePicker.value = ['', ''];
tablePagination.current = 1;
tablePagination.pageSize = 20;
fnGetList();
}
/**表格状态类型 */
type TabeStateType = {
/**加载等待 */
loading: boolean;
/**紧凑型 */
size: SizeType;
/**斑马纹 */
striped: boolean;
/**搜索栏 */
seached: boolean;
/**记录数据 */
data: object[];
/**勾选记录 */
selectedRowKeys: (string | number)[];
/**勾选单个的登录账号 */
selectedUserName: string;
};
/**表格状态 */
let tableState: TabeStateType = reactive({
loading: false,
size: 'middle',
striped: false,
seached: false,
data: [],
selectedRowKeys: [],
selectedUserName: '',
});
/**表格字段列 */
let tableColumns: ColumnsType = [
{
title: '日志编号',
dataIndex: 'infoId',
align: 'center',
},
{
title: '登录账号',
dataIndex: 'userName',
align: 'center',
},
{
title: '登录地址',
dataIndex: 'ipaddr',
align: 'center',
},
{
title: '登录地点',
dataIndex: 'loginLocation',
align: 'center',
},
{
title: '操作系统',
dataIndex: 'os',
align: 'center',
},
{
title: '浏览器',
dataIndex: 'browser',
align: 'center',
},
{
title: '登录状态',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '登录信息',
dataIndex: 'msg',
align: 'center',
},
{
title: '登录时间',
dataIndex: 'loginTime',
align: 'center',
customRender(opt) {
if (+opt.value <= 0) return '';
return parseDateToStr(+opt.value);
},
},
];
/**表格分页器参数 */
let tablePagination = reactive({
/**当前页数 */
current: 1,
/**每页条数 */
pageSize: 20,
/**默认的每页条数 */
defaultPageSize: 20,
/**指定每页可以显示多少条 */
pageSizeOptions: ['10', '20', '50', '100'],
/**只有一页时是否隐藏分页器 */
hideOnSinglePage: false,
/**是否可以快速跳转至某页 */
showQuickJumper: true,
/**是否可以改变 pageSize */
showSizeChanger: true,
/**数据总数 */
total: 0,
showTotal: (total: number) => `总共 ${total}`,
onChange: (page: number, pageSize: number) => {
tablePagination.current = page;
tablePagination.pageSize = pageSize;
queryParams.pageNum = page;
queryParams.pageSize = pageSize;
fnGetList();
},
});
/**表格紧凑型变更操作 */
function fnTableSize({ key }: MenuInfo) {
tableState.size = key as SizeType;
}
/**表格斑马纹 */
function fnTableStriped(_record: unknown, index: number) {
return tableState.striped && index % 2 === 1 ? 'table-striped' : undefined;
}
/**表格多选 */
function fnTableSelectedRows(
_: (string | number)[],
rows: Record<string, string>[]
) {
tableState.selectedRowKeys = rows.map(item => item.infoId);
// 针对单个登录账号解锁
if (rows.length === 1) {
tableState.selectedUserName = rows[0].userName;
} else {
tableState.selectedUserName = '';
}
}
/**记录删除 */
function fnRecordDelete() {
const ids = tableState.selectedRowKeys.join(',');
Modal.confirm({
title: '提示',
content: `确认删除访问编号为 【${ids}】 的数据项吗?`,
onOk() {
const hide = message.loading('请稍等...', 0);
delLogininfor(ids).then(res => {
hide();
if (res.code === 200) {
message.success({
content: `删除成功`,
duration: 3,
});
} else {
message.error({
content: `${res.msg}`,
duration: 3,
});
}
fnGetList();
});
},
});
}
/**列表清空 */
function fnCleanList() {
Modal.confirm({
title: '提示',
content: `确认清空所有登录日志数据项?`,
onOk() {
const hide = message.loading('请稍等...', 0);
cleanLogininfor().then(res => {
hide();
if (res.code === 200) {
message.success({
content: `清空成功`,
duration: 3,
});
} else {
message.error({
content: `${res.msg}`,
duration: 3,
});
}
fnGetList();
});
},
});
}
/**登录账号解锁 */
function fnUnlock() {
const username = tableState.selectedUserName;
Modal.confirm({
title: '提示',
content: `确认解锁用户 【${username}】 数据项?`,
onOk() {
const hide = message.loading('请稍等...', 0);
unlockLogininfor(username).then(res => {
hide();
if (res.code === 200) {
message.success({
content: `${username} 解锁成功`,
duration: 3,
});
} else {
message.error({
content: `${res.msg}`,
duration: 3,
});
}
});
},
});
}
/**列表导出 */
function fnExportList() {
Modal.confirm({
title: '提示',
content: `确认根据搜索条件导出xlsx表格文件吗?`,
onOk() {
const hide = message.loading('正在打开...', 0);
exportLogininfor(toRaw(queryParams)).then(res => {
hide();
if (res.code === 200) {
message.success({
content: `已完成导出`,
duration: 2,
});
saveAs(res.data, `logininfor_${Date.now()}.xlsx`);
} else {
message.error({
content: `${res.msg}`,
duration: 2,
});
}
});
},
});
}
/**查询登录日志列表 */
function fnGetList() {
if (tableState.loading) return;
tableState.loading = true;
queryParams.beginTime = queryRangePicker.value[0];
queryParams.endTime = queryRangePicker.value[1];
listLogininfor(toRaw(queryParams)).then(res => {
if (res.code === 200 && Array.isArray(res.rows)) {
// 取消勾选
if (tableState.selectedRowKeys.length > 0) {
tableState.selectedRowKeys = [];
}
tablePagination.total = res.total;
tableState.data = res.rows;
}
tableState.loading = false;
});
}
onMounted(() => {
// 初始字典数据
Promise.allSettled([getDict('sys_common_status')]).then(resArr => {
if (resArr[0].status === 'fulfilled') {
dict.sysCommonStatus = resArr[0].value;
}
});
// 获取列表数据
fnGetList();
});
</script>
<template>
<PageContainer :title="title">
<template #content>
<a-typography-paragraph>
对登录进行日志收集登录锁定的信息存入
<a-typography-text code>Redis</a-typography-text>
可对登录账号进行解锁
</a-typography-paragraph>
</template>
<a-card
v-show="tableState.seached"
:bordered="false"
:body-style="{ marginBottom: '24px', paddingBottom: 0 }"
>
<!-- 表格搜索栏 -->
<a-form :model="queryParams" name="queryParams" layout="horizontal">
<a-row :gutter="16">
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="登录地址" name="ipaddr">
<a-input
v-model:value="queryParams.ipaddr"
allow-clear
:maxlength="128"
placeholder="请输入登录地址"
></a-input>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="登录账号" name="userName">
<a-input
v-model:value="queryParams.userName"
allow-clear
:maxlength="30"
placeholder="请输入登录账号"
></a-input>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="登录状态" name="status">
<a-select
v-model:value="queryParams.status"
allow-clear
placeholder="请选择登录状态"
:options="dict.sysCommonStatus"
>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="登录时间" name="queryRangePicker">
<a-range-picker
v-model:value="queryRangePicker"
allow-clear
bordered
value-format="YYYY-MM-DD"
:placeholder="['登录开始', '登录结束']"
style="width: 100%"
></a-range-picker>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item>
<a-space :size="8">
<a-button type="primary" @click.prevent="fnGetList">
<template #icon><SearchOutlined /></template>
搜索</a-button
>
<a-button type="default" @click.prevent="fnQueryReset">
<template #icon><ClearOutlined /></template>
重置</a-button
>
</a-space>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-card>
<a-card :bordered="false" :body-style="{ padding: '0px' }">
<!-- 插槽-卡片左侧侧 -->
<template #title>
<a-space :size="8" align="center">
<a-button
type="primary"
:disabled="!tableState.selectedUserName"
@click.prevent="fnUnlock()"
v-perms:has="['monitor:logininfor:unlock']"
>
<template #icon><UnlockOutlined /></template>
解锁
</a-button>
<a-button
type="default"
danger
:disabled="tableState.selectedRowKeys.length <= 0"
@click.prevent="fnRecordDelete()"
v-perms:has="['monitor:logininfor:remove']"
>
<template #icon><DeleteOutlined /></template>
删除
</a-button>
<a-button
type="dashed"
danger
@click.prevent="fnCleanList()"
v-perms:has="['monitor:logininfor:remove']"
>
<template #icon><DeleteOutlined /></template>
清空
</a-button>
<a-button
type="dashed"
@click.prevent="fnExportList()"
v-perms:has="['monitor:logininfor:export']"
>
<template #icon><ExportOutlined /></template>
导出
</a-button>
</a-space>
</template>
<!-- 插槽-卡片右侧 -->
<template #extra>
<a-space :size="8" align="center">
<a-tooltip>
<template #title>搜索栏</template>
<a-switch
v-model:checked="tableState.seached"
checked-children=""
un-checked-children=""
size="small"
/>
</a-tooltip>
<a-tooltip>
<template #title>表格斑马纹</template>
<a-switch
v-model:checked="tableState.striped"
checked-children=""
un-checked-children=""
size="small"
/>
</a-tooltip>
<a-tooltip>
<template #title>刷新</template>
<a-button type="text" @click.prevent="fnGetList">
<template #icon><ReloadOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>密度</template>
<a-dropdown trigger="click">
<a-button type="text">
<template #icon><ColumnHeightOutlined /></template>
</a-button>
<template #overlay>
<a-menu
:selected-keys="[tableState.size as string]"
@click="fnTableSize"
>
<a-menu-item key="default">默认</a-menu-item>
<a-menu-item key="middle">中等</a-menu-item>
<a-menu-item key="small">紧凑</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</a-tooltip>
</a-space>
</template>
<!-- 表格列表 -->
<a-table
class="table"
row-key="infoId"
:columns="tableColumns"
:loading="tableState.loading"
:data-source="tableState.data"
:size="tableState.size"
:row-class-name="fnTableStriped"
:scroll="{ x: true }"
:pagination="tablePagination"
:row-selection="{
type: 'checkbox',
onChange: fnTableSelectedRows,
}"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'status'">
<DictTag :options="dict.sysCommonStatus" :value="record.status" />
</template>
</template>
</a-table>
</a-card>
</PageContainer>
</template>
<style lang="less" scoped>
.table :deep(.table-striped) td {
background-color: #fafafa;
}
.table :deep(.ant-pagination) {
padding: 0 24px;
}
</style>

View File

@@ -0,0 +1,338 @@
<script setup lang="ts">
import { useRoute } from 'vue-router';
import { reactive, ref, onMounted } from 'vue';
import { PageContainer } from '@ant-design-vue/pro-layout';
import { message, Modal } from 'ant-design-vue/lib';
import { forceLogout, listOnline } from '@/api/monitor/online';
import { parseDateToStr } from '@/utils/date-utils';
import { SizeType } from 'ant-design-vue/lib/config-provider';
import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface';
import { ColumnsType } from 'ant-design-vue/lib/table';
const route = useRoute();
/**路由标题 */
let title = ref<string>(route.meta.title ?? '标题');
/**查询参数 */
let queryParams = reactive({
/**登录主机 */
ipaddr: '',
/**登录账号 */
userName: '',
});
/**表格状态类型 */
type TabeStateType = {
/**加载等待 */
loading: boolean;
/**紧凑型 */
size: SizeType;
/**斑马纹 */
striped: boolean;
/**搜索栏 */
seached: boolean;
/**记录数据 */
data: object[];
};
/**表格状态 */
let tableState: TabeStateType = reactive({
loading: false,
size: 'middle',
striped: false,
seached: false,
data: [],
});
/**表格字段列 */
let tableColumns: ColumnsType = [
{
title: '序号',
dataIndex: 'num',
width: '50px',
align: 'center',
customRender(opt) {
const idxNum = (tablePagination.current - 1) * tablePagination.pageSize;
return idxNum + opt.index + 1;
},
},
{
title: '会话编号',
dataIndex: 'tokenId',
align: 'center',
},
{
title: '登录账号',
dataIndex: 'userName',
align: 'center',
},
{
title: '所属部门',
dataIndex: 'deptName',
align: 'center',
},
{
title: '登录主机',
dataIndex: 'ipaddr',
align: 'center',
},
{
title: '登录地点',
dataIndex: 'loginLocation',
align: 'center',
},
{
title: '操作系统',
dataIndex: 'os',
align: 'center',
},
{
title: '浏览器',
dataIndex: 'browser',
align: 'center',
},
{
title: '登录时间',
dataIndex: 'loginTime',
align: 'center',
customRender(opt) {
if (+opt.value <= 0) return '';
return parseDateToStr(+opt.value);
},
},
{
title: '操作',
key: 'tokenId',
align: 'center',
},
];
/**表格分页器参数 */
let tablePagination = {
/**当前页数 */
current: 1,
/**每页条数 */
pageSize: 20,
/**默认的每页条数 */
defaultPageSize: 20,
/**指定每页可以显示多少条 */
pageSizeOptions: ['10', '20', '50', '100'],
/**只有一页时是否隐藏分页器 */
hideOnSinglePage: true,
/**是否可以快速跳转至某页 */
showQuickJumper: true,
/**是否可以改变 pageSize */
showSizeChanger: true,
/**数据总数 */
total: 0,
showTotal: (total: number) => `总共 ${total}`,
onChange: (page: number, pageSize: number) => {
tablePagination.current = page;
tablePagination.pageSize = pageSize;
},
};
/**表格紧凑型变更操作 */
function fnTableSize({ key }: MenuInfo) {
tableState.size = key as SizeType;
}
/**表格斑马纹 */
function fnTableStriped(_record: unknown, index: number) {
return tableState.striped && index % 2 === 1 ? 'table-striped' : undefined;
}
/**查询参数重置 */
function fnQueryReset() {
queryParams.ipaddr = '';
queryParams.userName = '';
tablePagination.current = 1;
tablePagination.pageSize = 20;
fnGetList();
}
/** 查询在线用户列表 */
function fnGetList() {
if (tableState.loading) return;
tableState.loading = true;
listOnline(queryParams).then(res => {
if (res.code === 200 && Array.isArray(res.rows)) {
tableState.data = res.rows;
}
tableState.loading = false;
});
}
/** 强退按钮操作 */
function fnForceLogout(row: Record<string, string>) {
Modal.confirm({
title: '提示',
content: `确认强退登录账号为 ${row.userName} 的用户?`,
onOk() {
const hide = message.loading('正在打开...', 0);
forceLogout(row.tokenId).finally(() => {
hide();
message.error({
content: `已强退用户 ${row.userName}`,
duration: 2,
});
});
fnGetList();
},
});
}
onMounted(() => {
fnGetList();
});
</script>
<template>
<PageContainer :title="title">
<template #content>
<a-typography-paragraph>
登录用户
<a-typography-text code>Token</a-typography-text>
授权标识记录存储在
<a-typography-text code>Redis</a-typography-text>
可撤销对用户的授权拒绝用户请求并强制退出
</a-typography-paragraph>
</template>
<a-card
v-show="tableState.seached"
:bordered="false"
:body-style="{ marginBottom: '24px', paddingBottom: 0 }"
>
<!-- 表格搜索栏 -->
<a-form :model="queryParams" name="queryParams" layout="horizontal">
<a-row :gutter="16">
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="登录账号" name="userName">
<a-input
v-model:value="queryParams.userName"
allow-clear
:maxlength="30"
placeholder="请输入登录账号"
></a-input>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="登录主机" name="ipaddr">
<a-input
v-model:value="queryParams.ipaddr"
allow-clear
:maxlength="128"
placeholder="请输入登录主机"
></a-input> </a-form-item
></a-col>
<a-col :lg="12" :md="24" :xs="24">
<a-form-item>
<a-space :size="8">
<a-button type="primary" @click.prevent="fnGetList">
<template #icon><SearchOutlined /></template>
搜索
</a-button>
<a-button type="default" @click.prevent="fnQueryReset">
<template #icon><ClearOutlined /></template>
重置
</a-button>
</a-space>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-card>
<a-card :bordered="false" :body-style="{ padding: '0px' }">
<!-- 插槽-卡片左侧侧 -->
<template #title>
{{ title }}
</template>
<!-- 插槽-卡片右侧 -->
<template #extra>
<a-space :size="8" align="center">
<a-tooltip>
<template #title>搜索栏</template>
<a-switch
v-model:checked="tableState.seached"
checked-children=""
un-checked-children=""
size="small"
/>
</a-tooltip>
<a-tooltip>
<template #title>表格斑马纹</template>
<a-switch
v-model:checked="tableState.striped"
checked-children=""
un-checked-children=""
size="small"
/>
</a-tooltip>
<a-tooltip>
<template #title>刷新</template>
<a-button type="text" @click.prevent="fnGetList">
<template #icon><ReloadOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>密度</template>
<a-dropdown trigger="click">
<a-button type="text">
<template #icon><ColumnHeightOutlined /></template>
</a-button>
<template #overlay>
<a-menu
:selected-keys="[tableState.size as string]"
@click="fnTableSize"
>
<a-menu-item key="default">默认</a-menu-item>
<a-menu-item key="middle">中等</a-menu-item>
<a-menu-item key="small">紧凑</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</a-tooltip>
</a-space>
</template>
<!-- 表格列表 -->
<a-table
class="table"
row-key="tokenId"
:columns="tableColumns"
:loading="tableState.loading"
:data-source="tableState.data"
:size="tableState.size"
:row-class-name="fnTableStriped"
:pagination="tablePagination"
:scroll="{ x: true }"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'tokenId'">
<a-button
type="link"
@click.prevent="fnForceLogout(record)"
v-perms:has="['monitor:online:forceLogout']"
>
<template #icon><LogoutOutlined /></template>
强退
</a-button>
</template>
</template>
</a-table>
</a-card>
</PageContainer>
</template>
<style lang="less" scoped>
.table :deep(.table-striped) td {
background-color: #fafafa;
}
.table :deep(.ant-pagination) {
padding: 0 24px;
}
</style>

View File

@@ -0,0 +1,692 @@
<script setup lang="ts">
import { useRoute } from 'vue-router';
import { reactive, ref, onMounted, toRaw } from 'vue';
import { PageContainer } from '@ant-design-vue/pro-layout';
import { message, Modal } from 'ant-design-vue/lib';
import { SizeType } from 'ant-design-vue/lib/config-provider';
import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface';
import { ColumnsType } from 'ant-design-vue/lib/table';
import {
exportOperlog,
listOperlog,
delOperlog,
cleanOperlog,
} from '@/api/monitor/operlog';
import { saveAs } from 'file-saver';
import { parseDateToStr } from '@/utils/date-utils';
import useDictStore from '@/store/modules/dict';
const { getDict } = useDictStore();
const route = useRoute();
/**路由标题 */
let title = ref<string>(route.meta.title ?? '标题');
/**字典数据 */
let dict: {
/**业务类型 */
sysBusinessType: DictType[];
/**登录状态 */
sysCommonStatus: DictType[];
} = reactive({
sysBusinessType: [],
sysCommonStatus: [],
});
/**开始结束时间 */
let queryRangePicker = ref<[string, string]>(['', '']);
/**查询参数 */
let queryParams = reactive({
/**操作模块 */
title: '',
/**操作人员 */
operName: '',
/**业务类型 */
businessType: undefined,
/**操作状态 */
status: undefined,
/**开始时间 */
beginTime: '',
/**结束时间 */
endTime: '',
/**当前页数 */
pageNum: 1,
/**每页条数 */
pageSize: 20,
});
/**查询参数重置 */
function fnQueryReset() {
queryParams = Object.assign(queryParams, {
title: '',
operName: '',
businessType: undefined,
status: undefined,
beginTime: '',
endTime: '',
pageNum: 1,
pageSize: 20,
});
queryRangePicker.value = ['', ''];
tablePagination.current = 1;
tablePagination.pageSize = 20;
fnGetList();
}
/**表格状态类型 */
type TabeStateType = {
/**加载等待 */
loading: boolean;
/**紧凑型 */
size: SizeType;
/**斑马纹 */
striped: boolean;
/**搜索栏 */
seached: boolean;
/**记录数据 */
data: object[];
/**勾选记录 */
selectedRowKeys: (string | number)[];
};
/**表格状态 */
let tableState: TabeStateType = reactive({
loading: false,
size: 'middle',
striped: false,
seached: false,
data: [],
selectedRowKeys: [],
});
/**表格字段列 */
let tableColumns: ColumnsType = [
{
title: '日志编号',
dataIndex: 'operId',
align: 'center',
},
{
title: '模块名称',
dataIndex: 'title',
align: 'center',
},
{
title: '业务类型',
dataIndex: 'businessType',
key: 'businessType',
align: 'center',
},
{
title: '操作人员',
dataIndex: 'operName',
align: 'center',
},
{
title: '请求方式',
dataIndex: 'requestMethod',
align: 'center',
},
{
title: '请求主机',
dataIndex: 'operIp',
align: 'center',
},
{
title: '操作状态',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '操作日期',
dataIndex: 'operTime',
align: 'center',
customRender(opt) {
if (+opt.value <= 0) return '';
return parseDateToStr(+opt.value);
},
},
{
title: '消耗时间',
dataIndex: 'costTime',
key: 'costTime',
align: 'center',
customRender(opt) {
return `${opt.value} ms`;
},
},
{
title: '操作',
key: 'operId',
align: 'center',
},
];
/**表格分页器参数 */
let tablePagination = reactive({
/**当前页数 */
current: 1,
/**每页条数 */
pageSize: 20,
/**默认的每页条数 */
defaultPageSize: 20,
/**指定每页可以显示多少条 */
pageSizeOptions: ['10', '20', '50', '100'],
/**只有一页时是否隐藏分页器 */
hideOnSinglePage: false,
/**是否可以快速跳转至某页 */
showQuickJumper: true,
/**是否可以改变 pageSize */
showSizeChanger: true,
/**数据总数 */
total: 0,
showTotal: (total: number) => `总共 ${total}`,
onChange: (page: number, pageSize: number) => {
tablePagination.current = page;
tablePagination.pageSize = pageSize;
queryParams.pageNum = page;
queryParams.pageSize = pageSize;
fnGetList();
},
});
/**表格紧凑型变更操作 */
function fnTableSize({ key }: MenuInfo) {
tableState.size = key as SizeType;
}
/**表格斑马纹 */
function fnTableStriped(_record: unknown, index: number) {
return tableState.striped && index % 2 === 1 ? 'table-striped' : undefined;
}
/**表格多选 */
function fnTableSelectedRowKeys(keys: (string | number)[]) {
tableState.selectedRowKeys = keys;
}
/**对话框对象信息状态类型 */
type ModalStateType = {
/**详情框是否显示 */
visibleByView: boolean;
/**标题 */
title: string;
/**表单数据 */
from: Record<string, any>;
};
/**对话框对象信息状态 */
let modalState: ModalStateType = reactive({
visibleByView: false,
title: '操作日志',
from: {
operId: undefined,
businessType: 0,
deptName: '',
method: '',
operIp: '',
operLocation: '',
operMsg: '',
operName: '',
operParam: '',
operTime: 0,
operUrl: '',
operatorType: 1,
requestMethod: 'PUT',
status: 1,
title: '',
},
});
/**
* 对话框弹出显示为 查看
* @param row 操作日志信息对象
*/
function fnModalVisibleByVive(row: Record<string, string>) {
modalState.from = Object.assign(modalState.from, row);
modalState.title = '操作日志信息';
modalState.visibleByView = true;
}
/**
* 对话框弹出关闭执行函数
*/
function fnModalCancel() {
modalState.visibleByView = false;
}
/**记录删除 */
function fnRecordDelete() {
const ids = tableState.selectedRowKeys.join(',');
Modal.confirm({
title: '提示',
content: `确认删除访问编号为 【${ids}】 的数据项吗?`,
onOk() {
const key = 'delOperlog';
message.loading({ content: '请稍等...', key });
delOperlog(ids).then(res => {
if (res.code === 200) {
message.success({
content: '删除成功',
key,
duration: 2,
});
fnGetList();
} else {
message.error({
content: `${res.msg}`,
key,
duration: 2,
});
}
});
},
});
}
/**列表清空 */
function fnCleanList() {
Modal.confirm({
title: '提示',
content: `确认清空所有登录日志数据项?`,
onOk() {
const key = 'cleanOperlog';
message.loading({ content: '请稍等...', key });
cleanOperlog().then(res => {
if (res.code === 200) {
message.success({
content: '清空成功',
key,
duration: 2,
});
fnGetList();
} else {
message.error({
content: `${res.msg}`,
key,
duration: 2,
});
}
});
},
});
}
/**列表导出 */
function fnExportList() {
Modal.confirm({
title: '提示',
content: `确认根据搜索条件导出xlsx表格文件吗?`,
onOk() {
const key = 'exportOperlog';
message.loading({ content: '请稍等...', key });
exportOperlog(toRaw(queryParams)).then(res => {
if (res.code === 200) {
message.success({
content: `已完成导出`,
key,
duration: 2,
});
saveAs(res.data, `operlog_${Date.now()}.xlsx`);
} else {
message.error({
content: `${res.msg}`,
key,
duration: 2,
});
}
});
},
});
}
/**查询登录日志列表 */
function fnGetList() {
if (tableState.loading) return;
tableState.loading = true;
queryParams.beginTime = queryRangePicker.value[0];
queryParams.endTime = queryRangePicker.value[1];
listOperlog(toRaw(queryParams)).then(res => {
if (res.code === 200 && Array.isArray(res.rows)) {
// 取消勾选
if (tableState.selectedRowKeys.length > 0) {
tableState.selectedRowKeys = [];
}
tablePagination.total = res.total;
tableState.data = res.rows;
}
tableState.loading = false;
});
}
onMounted(() => {
// 初始字典数据
Promise.allSettled([
getDict('sys_oper_type'),
getDict('sys_common_status'),
]).then(resArr => {
if (resArr[0].status === 'fulfilled') {
dict.sysBusinessType = resArr[0].value;
}
if (resArr[1].status === 'fulfilled') {
dict.sysCommonStatus = resArr[1].value;
}
});
// 获取列表数据
fnGetList();
});
</script>
<template>
<PageContainer :title="title">
<template #content>
<a-typography-paragraph>
对接口请求进行日志收集统计高频接口分析优化等操作
</a-typography-paragraph>
</template>
<a-card
v-show="tableState.seached"
:bordered="false"
:body-style="{ marginBottom: '24px', paddingBottom: 0 }"
>
<!-- 表格搜索栏 -->
<a-form :model="queryParams" name="queryParams" layout="horizontal">
<a-row :gutter="16">
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="操作模块" name="title">
<a-input
v-model:value="queryParams.title"
allow-clear
placeholder="请输入操作模块"
></a-input>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="操作人员" name="operName">
<a-input
v-model:value="queryParams.operName"
allow-clear
placeholder="请输入操作人员"
></a-input>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="操作类型" name="businessType">
<a-select
v-model:value="queryParams.businessType"
allow-clear
placeholder="请选择操作类型"
:options="dict.sysBusinessType"
>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="操作状态" name="status">
<a-select
v-model:value="queryParams.status"
allow-clear
placeholder="请选择操作状态"
:options="dict.sysCommonStatus"
>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="操作时间" name="queryRangePicker">
<a-range-picker
v-model:value="queryRangePicker"
allow-clear
bordered
value-format="YYYY-MM-DD"
:placeholder="['操作开始', '操作结束']"
style="width: 100%"
></a-range-picker>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item>
<a-space :size="8">
<a-button type="primary" @click.prevent="fnGetList">
<template #icon><SearchOutlined /></template>
搜索</a-button
>
<a-button type="default" @click.prevent="fnQueryReset">
<template #icon><ClearOutlined /></template>
重置</a-button
>
</a-space>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-card>
<a-card :bordered="false" :body-style="{ padding: '0px' }">
<!-- 插槽-卡片左侧侧 -->
<template #title>
<a-space :size="8" align="center">
<a-button
type="default"
danger
:disabled="tableState.selectedRowKeys.length <= 0"
@click.prevent="fnRecordDelete()"
v-perms:has="['monitor:operlog:remove']"
>
<template #icon><DeleteOutlined /></template>
删除
</a-button>
<a-button
type="dashed"
danger
@click.prevent="fnCleanList()"
v-perms:has="['monitor:operlog:remove']"
>
<template #icon><DeleteOutlined /></template>
清空
</a-button>
<a-button
type="dashed"
@click.prevent="fnExportList()"
v-perms:has="['monitor:operlog:export']"
>
<template #icon><ExportOutlined /></template>
导出
</a-button>
</a-space>
</template>
<!-- 插槽-卡片右侧 -->
<template #extra>
<a-space :size="8" align="center">
<a-tooltip>
<template #title>搜索栏</template>
<a-switch
v-model:checked="tableState.seached"
checked-children=""
un-checked-children=""
size="small"
/>
</a-tooltip>
<a-tooltip>
<template #title>表格斑马纹</template>
<a-switch
v-model:checked="tableState.striped"
checked-children=""
un-checked-children=""
size="small"
/>
</a-tooltip>
<a-tooltip>
<template #title>刷新</template>
<a-button type="text" @click.prevent="fnGetList">
<template #icon><ReloadOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>密度</template>
<a-dropdown trigger="click">
<a-button type="text">
<template #icon><ColumnHeightOutlined /></template>
</a-button>
<template #overlay>
<a-menu
:selected-keys="[tableState.size as string]"
@click="fnTableSize"
>
<a-menu-item key="default">默认</a-menu-item>
<a-menu-item key="middle">中等</a-menu-item>
<a-menu-item key="small">紧凑</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</a-tooltip>
</a-space>
</template>
<!-- 表格列表 -->
<a-table
class="table"
row-key="operId"
:columns="tableColumns"
:loading="tableState.loading"
:data-source="tableState.data"
:size="tableState.size"
:row-class-name="fnTableStriped"
:scroll="{ x: true }"
:pagination="tablePagination"
:row-selection="{
type: 'checkbox',
onChange: fnTableSelectedRowKeys,
}"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'businessType'">
<DictTag
:options="dict.sysBusinessType"
:value="record.businessType"
/>
</template>
<template v-if="column.key === 'status'">
<DictTag :options="dict.sysCommonStatus" :value="record.status" />
</template>
<template v-if="column.key === 'operId'">
<a-space :size="8" align="center">
<a-tooltip>
<template #title>查看详情</template>
<a-button
type="link"
@click.prevent="fnModalVisibleByVive(record)"
v-perms:has="['monitor:operlog:query']"
>
<template #icon><ProfileOutlined /></template>
详情
</a-button>
</a-tooltip>
</a-space>
</template>
</template>
</a-table>
</a-card>
<!-- 详情框 -->
<a-modal
width="800px"
:visible="modalState.visibleByView"
:title="modalState.title"
@cancel="fnModalCancel"
>
<a-form layout="horizontal">
<a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="日志编号" name="operId">
{{ modalState.from.operId }}
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="执行状态" name="status">
<a-tag :color="+modalState.from.status ? 'success' : 'error'">
{{ ['失败', '正常'][+modalState.from.status] }}
</a-tag>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="业务类型" name="businessType">
{{ modalState.from.title }} /
<DictTag
:options="dict.sysBusinessType"
:value="modalState.from.businessType"
/>
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="操作人员" name="operName">
{{ modalState.from.operName }} / {{ modalState.from.operIp }} /
{{ modalState.from.operLocation }}
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="请求地址" name="operUrl">
{{ modalState.from.requestMethod }} -
{{ modalState.from.operUrl }}
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="操作时间" name="operTime">
<span v-if="+modalState.from.operTime > 0">
{{ parseDateToStr(+modalState.from.operTime) }}
</span>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="请求耗时" name="costTime">
{{ modalState.from.costTime }} ms
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="操作方法" name="method">
{{ modalState.from.method }}
</a-form-item>
</a-col>
</a-row>
<a-form-item label="请求参数" name="operParam">
<a-textarea
v-model:value="modalState.from.operParam"
:auto-size="{ minRows: 2, maxRows: 6 }"
placeholder="请求参数"
:disabled="true"
/>
</a-form-item>
<a-form-item label="操作信息" name="operMsg">
<a-textarea
v-model:value="modalState.from.operMsg"
:auto-size="{ minRows: 2, maxRows: 6 }"
placeholder="操作信息"
:disabled="true"
/>
</a-form-item>
</a-form>
<template #footer>
<a-button key="cancel" @click="fnModalCancel">关闭</a-button>
</template>
</a-modal>
</PageContainer>
</template>
<style lang="less" scoped>
.table :deep(.table-striped) td {
background-color: #fafafa;
}
.table :deep(.ant-pagination) {
padding: 0 24px;
}
</style>

View File

@@ -0,0 +1,329 @@
<script setup lang="ts">
import { useRoute } from 'vue-router';
import { reactive, ref, onMounted } from 'vue';
import { PageContainer } from '@ant-design-vue/pro-layout';
import { ColumnsType } from 'ant-design-vue/lib/table';
import { getServer } from '@/api/monitor/server';
const route = useRoute();
/**路由标题 */
let title = ref<string>(route.meta.title ?? '标题');
/**加载状态 */
let loading = ref<boolean>(true);
/**磁盘信息表格字段列 */
let diskTableColumns: ColumnsType = [
{
title: '路径盘符',
dataIndex: 'target',
align: 'center',
},
{
title: '总大小',
dataIndex: 'size',
align: 'center',
},
{
title: '剩余大小',
dataIndex: 'avail',
align: 'center',
},
{
title: '已使用大小',
dataIndex: 'used',
align: 'center',
},
{
title: '空间使用率(%)',
dataIndex: 'pcent',
align: 'center',
},
];
/**数据参数类型 */
type ServerType = {
/**CPU */
cpu: Record<string, string | number>;
/**磁盘 */
disk: Record<string, string>[];
/**内存 */
memory: Record<string, string | number>;
/**网络 */
network: Record<string, string>;
/**项目 */
project: Record<string, string>;
/**系统 */
system: Record<string, string | number>;
/**时间 */
time: Record<string, string | number>;
};
let server: ServerType = reactive({
cpu: {},
disk: [],
memory: {},
network: {},
project: {},
system: {},
time: {},
});
onMounted(() => {
getServer().then(res => {
if (res.code === 200 && res.data) {
// CPU信息
let cpu = res.data.cpu;
cpu.coreUsed = cpu.coreUsed.map((item: string) => item).join(' / ');
server.cpu = cpu;
// 磁盘信息
server.disk = res.data.disk;
// 内存信息
server.memory = res.data.memory;
// 网络信息
server.network = res.data.network;
// 项目信息
server.project = res.data.project;
// 系统信息
server.system = res.data.system;
// 时间信息
server.time = res.data.time;
// 加载状态
loading.value = false;
}
});
});
</script>
<template>
<PageContainer :title="title" :loading="loading">
<template #content>
<a-typography-paragraph> 服务器与应用程序的信息 </a-typography-paragraph>
</template>
<a-card
title="项目信息"
:bordered="false"
:body-style="{ marginBottom: '24px', padding: 0 }"
>
<a-descriptions
size="middle"
layout="horizontal"
:label-style="{ width: '140px' }"
:bordered="true"
:column="{ lg: 2, md: 2, xs: 1 }"
>
<a-descriptions-item label="项目名称">
{{ server.project.name }}
</a-descriptions-item>
<a-descriptions-item label="项目版本">
{{ server.project.version }}
</a-descriptions-item>
<a-descriptions-item label="项目环境">
{{ server.project.env }}
</a-descriptions-item>
<a-descriptions-item label="项目路径">
{{ server.project.appDir }}
</a-descriptions-item>
<a-descriptions-item label="项目依赖">
<a-tag
v-for="(value, name) in server.project.dependencies"
:key="name"
>
{{ name }}:{{ value }}
</a-tag>
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card
title="系统信息"
:bordered="false"
:body-style="{ marginBottom: '24px', padding: 0 }"
>
<a-descriptions
size="middle"
layout="horizontal"
:label-style="{ width: '140px' }"
:column="{ lg: 2, md: 2, xs: 1 }"
:bordered="true"
>
<a-descriptions-item
label="GO版本"
:span="2"
v-if="server.system && server.system.go"
>
{{ server.system.go }}
</a-descriptions-item>
<a-descriptions-item
label="Node版本"
v-if="server.system && server.system.node"
>
{{ server.system.node }}
</a-descriptions-item>
<a-descriptions-item
label="V8版本"
v-if="server.system && server.system.v8"
>
{{ server.system.v8 }}
</a-descriptions-item>
<a-descriptions-item label="进程PID号">
{{ server.system.processId }}
</a-descriptions-item>
<a-descriptions-item label="运行平台">
{{ server.system.platform }}
</a-descriptions-item>
<a-descriptions-item label="系统架构">
{{ server.system.arch }}
</a-descriptions-item>
<a-descriptions-item label="系统平台">
{{ server.system.uname }}
</a-descriptions-item>
<a-descriptions-item label="系统发行版本">
{{ server.system.release }}
</a-descriptions-item>
<a-descriptions-item label="主机名称">
{{ server.system.hostname }}
</a-descriptions-item>
<a-descriptions-item label="主机用户目录" :span="2">
{{ server.system.homeDir }}
</a-descriptions-item>
<a-descriptions-item label="项目路径" :span="2">
{{ server.system.cmd }}
</a-descriptions-item>
<a-descriptions-item label="执行命令" :span="2">
{{ server.system.execCommand }}
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card
title="CPU信息"
:bordered="false"
:body-style="{ marginBottom: '24px', padding: 0 }"
>
<a-descriptions
size="middle"
layout="horizontal"
:label-style="{ width: '140px' }"
:column="1"
:bordered="true"
>
<a-descriptions-item label="型号">
{{ server.cpu.model }}
</a-descriptions-item>
<a-descriptions-item label="速率Hz">
{{ server.cpu.speed }}
</a-descriptions-item>
<a-descriptions-item label="核心数">
{{ server.cpu.core }}
</a-descriptions-item>
<a-descriptions-item label="使用率(%)">
{{ server.cpu.coreUsed }}
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card
title="内存信息"
:bordered="false"
:body-style="{ marginBottom: '24px', padding: 0 }"
>
<a-descriptions
size="middle"
layout="horizontal"
:label-style="{ width: '140px' }"
:column="{ lg: 2, md: 2, xs: 1 }"
:bordered="true"
>
<a-descriptions-item label="总内存">
{{ server.memory.totalmem }}
</a-descriptions-item>
<a-descriptions-item label="剩余内存">
{{ server.memory.freemem }}
</a-descriptions-item>
<a-descriptions-item label="使用率(%)">
{{ server.memory.usage }}
</a-descriptions-item>
<a-descriptions-item label="进程总内存">
{{ server.memory.rss }}
</a-descriptions-item>
<a-descriptions-item label="堆的总大小">
{{ server.memory.heapTotal }}
</a-descriptions-item>
<a-descriptions-item label="堆已分配">
{{ server.memory.heapUsed }}
</a-descriptions-item>
<a-descriptions-item label="链接库占用">
{{ server.memory.external }}
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card
title="时间信息"
:bordered="false"
:body-style="{ marginBottom: '24px', padding: 0 }"
>
<a-descriptions
size="middle"
layout="horizontal"
:label-style="{ width: '140px' }"
:column="{ lg: 2, md: 2, xs: 1 }"
:bordered="true"
>
<a-descriptions-item label="时区">
{{ server.time.timezone }}
</a-descriptions-item>
<a-descriptions-item label="时间">
{{ server.time.current }}
</a-descriptions-item>
<a-descriptions-item label="时区名称">
{{ server.time.timezoneName }}
</a-descriptions-item>
<a-descriptions-item label="程序启动时间">
{{ server.time.uptime }}
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card
title="网络信息"
:bordered="false"
:body-style="{ marginBottom: '24px', padding: 0 }"
>
<a-descriptions
size="middle"
layout="horizontal"
:label-style="{ width: '140px' }"
:column="1"
:bordered="true"
>
<a-descriptions-item
:label="name"
v-for="(value, name) in server.network"
:key="name"
>
{{ value }}
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card title="磁盘信息" :bordered="false" :body-style="{ padding: 0 }">
<a-table
class="disk"
row-key="target"
size="middle"
:columns="diskTableColumns"
:data-source="server.disk"
:pagination="false"
:scroll="{ x: true }"
>
</a-table>
</a-card>
</PageContainer>
</template>
<style lang="less" scoped></style>