feat: 合并Gin_Vue

This commit is contained in:
TsMask
2023-10-16 17:12:24 +08:00
parent 771320a839
commit 743568861d
77 changed files with 734 additions and 1870 deletions

View File

@@ -13,6 +13,7 @@ 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';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
const route = useRoute();
/**路由标题 */
@@ -43,7 +44,7 @@ function fnCacheKeyInfo(cacheKey: string) {
cacheKeyInfo.loading = true;
getCacheValue(cacheKeyTable.cacheName, cacheKey).then(res => {
isClick.value = false;
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
cacheKeyInfo.data = Object.assign(cacheKeyInfo.data, res.data);
cacheKeyInfo.loading = false;
}
@@ -106,7 +107,7 @@ function fnCacheKeyClear(cacheKey: string) {
clearCacheKey(cacheKeyTable.cacheName, cacheKey).then(res => {
hide();
isClick.value = false;
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `已删除缓存键名 ${cacheKey}`,
duration: 3,
@@ -139,7 +140,7 @@ function fnCacheKeyList(cacheName: string = 'load') {
cacheKeyTable.loading = true;
listCacheKey(cacheName).then(res => {
isClick.value = false;
if (res.code === 200 && res.data) {
if (res.code === RESULT_CODE_SUCCESS && res.data) {
cacheKeyTable.cacheName = cacheName;
cacheKeyTable.data = res.data;
cacheKeyTable.loading = false;
@@ -204,7 +205,7 @@ function fnClearCacheSafe() {
clearCacheSafe().then(res => {
hide();
isClick.value = false;
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: '已完成安全清理缓存',
duration: 3,
@@ -231,7 +232,7 @@ function fnCacheNameClear(cacheName: string) {
clearCacheName(cacheName).then(res => {
hide();
isClick.value = false;
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `已清理缓存名称 ${cacheName}`,
duration: 3,
@@ -257,7 +258,7 @@ function fnCacheNameList() {
cacheNameTable.loading = true;
listCacheName().then(res => {
isClick.value = false;
if (res.code === 200 && res.data) {
if (res.code === RESULT_CODE_SUCCESS && res.data) {
cacheNameTable.data = res.data;
cacheNameTable.loading = false;
}
@@ -316,11 +317,12 @@ onMounted(() => {
:columns="cacheNameTableColumns"
:data-source="cacheNameTable.data"
:loading="cacheNameTable.loading"
:scroll="{ y: 1200 }"
:pagination="false"
:row-selection="{
type: 'radio',
onChange: (selectedRowKeys: (string|number)[]) => fnCacheKeyList(selectedRowKeys[0] as string),
}"
:pagination="false"
>
<template
#customFilterDropdown="{
@@ -337,7 +339,7 @@ onMounted(() => {
:value="selectedKeys[0]"
style="width: 188px; margin-bottom: 8px; display: block"
@change="
(e:any) => setSelectedKeys(e.target.value ? [e.target.value] : [])
(e:any)=> setSelectedKeys(e.target.value ? [e.target.value] : [])
"
@pressEnter="confirm()"
/>
@@ -397,11 +399,12 @@ onMounted(() => {
:columns="cacheKeyTableColumns"
:data-source="cacheKeyTable.data"
:loading="cacheKeyTable.loading"
:scroll="{ y: 1200 }"
:pagination="false"
:row-selection="{
type: 'radio',
onChange: (selectedRowKeys: (string|number)[]) => fnCacheKeyInfo(selectedRowKeys[0] as string),
}"
:pagination="false"
>
<template
#customFilterDropdown="{

View File

@@ -15,6 +15,7 @@ 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';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
const route = useRoute();
echarts.use([
@@ -136,7 +137,7 @@ function commandStatsChart() {
onMounted(() => {
getCache()
.then(res => {
if (res.code === 200 && res.data) {
if (res.code === RESULT_CODE_SUCCESS && res.data) {
cache.info = res.data.info;
cache.dbSize = res.data.dbSize;
cache.commandStats = res.data.commandStats;

View File

@@ -22,6 +22,7 @@ import { parseDateToStr } from '@/utils/date-utils';
import useDictStore from '@/store/modules/dict';
import { hasPermissions } from '@/plugins/auth-user';
import { MENU_PATH_INLINE } from '@/constants/menu-constants';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
const { getDict } = useDictStore();
const route = useRoute();
const router = useRouter();
@@ -169,7 +170,7 @@ function fnTableSize({ key }: MenuInfo) {
}
/**表格斑马纹 */
function fnTableStriped(_record: unknown, index: number) {
function fnTableStriped(_record: unknown, index: number): any {
return tableState.striped && index % 2 === 1 ? 'table-striped' : undefined;
}
@@ -260,7 +261,7 @@ function fnModalVisibleByVive(jobId: string | number) {
getJob(jobId).then(res => {
modalState.confirmLoading = false;
hide();
if (res.code === 200 && res.data) {
if (res.code === RESULT_CODE_SUCCESS && res.data) {
modalState.from = Object.assign(modalState.from, res.data);
modalState.title = '任务信息';
modalState.visibleByView = true;
@@ -286,7 +287,7 @@ function fnModalVisibleByEdit(jobId?: string | number) {
getJob(jobId).then(res => {
modalState.confirmLoading = false;
hide();
if (res.code === 200 && res.data) {
if (res.code === RESULT_CODE_SUCCESS && res.data) {
modalState.from = Object.assign(modalState.from, res.data);
modalState.title = '修改任务';
modalState.visibleByEdit = true;
@@ -312,7 +313,7 @@ function fnModalOk() {
message.loading({ content: '请稍等...', key });
job
.then(res => {
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `${modalState.title}成功`,
key,
@@ -371,7 +372,7 @@ function fnRecordStatus(row: Record<string, string>) {
const key = 'changeJobStatus';
message.loading({ content: '请稍等...', key });
changeJobStatus(row.jobId, row.status).then(res => {
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `${row.jobName} ${text}成功`,
key,
@@ -405,7 +406,7 @@ function fnRecordRunOne(row: Record<string, string>) {
const key = 'runJob';
message.loading({ content: '请稍等...', key });
runJob(row.jobId).then(res => {
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `${row.jobName} 执行成功`,
key,
@@ -438,7 +439,7 @@ function fnRecordDelete(jobId: string = '0') {
const key = 'delJob';
message.loading({ content: '请稍等...', key });
delJob(jobId).then(res => {
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `删除成功`,
key,
@@ -468,7 +469,7 @@ function fnResetQueueJob() {
const key = 'resetQueueJob';
message.loading({ content: '请稍等...', key });
resetQueueJob().then(res => {
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `重置成功`,
key,
@@ -495,7 +496,7 @@ function fnExportList() {
const key = 'exportJob';
message.loading({ content: '请稍等...', key });
exportJob(toRaw(queryParams)).then(res => {
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `已完成导出`,
key,
@@ -523,7 +524,7 @@ function fnJobLogView(jobId: string | number = '0') {
function fnGetList() {
tableState.loading = true;
listJob(toRaw(queryParams)).then(res => {
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
// 取消勾选
if (tableState.selectedRowKeys.length > 0) {
tableState.selectedRowKeys = [];
@@ -704,9 +705,9 @@ onMounted(() => {
<template #icon><ReloadOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip>
<a-tooltip placement="topRight">
<template #title>密度</template>
<a-dropdown trigger="click">
<a-dropdown placement="bottomRight" trigger="click">
<a-button type="text">
<template #icon><ColumnHeightOutlined /></template>
</a-button>

View File

@@ -17,6 +17,7 @@ import { saveAs } from 'file-saver';
import { parseDateToStr } from '@/utils/date-utils';
import useTabsStore from '@/store/modules/tabs';
import useDictStore from '@/store/modules/dict';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
const tabsStore = useTabsStore();
const { getDict } = useDictStore();
const route = useRoute();
@@ -198,7 +199,7 @@ function fnTableSize({ key }: MenuInfo) {
}
/**表格斑马纹 */
function fnTableStriped(_record: unknown, index: number) {
function fnTableStriped(_record: unknown, index: number): any {
return tableState.striped && index % 2 === 1 ? 'table-striped' : undefined;
}
@@ -262,7 +263,7 @@ function fnRecordDelete() {
const key = 'delJobLog';
message.loading({ content: '请稍等...', key });
delJobLog(ids).then(res => {
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `删除成功`,
key,
@@ -290,7 +291,7 @@ function fnCleanList() {
const key = 'cleanJobLog';
message.loading({ content: '请稍等...', key });
cleanJobLog().then(res => {
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `清空成功`,
key,
@@ -318,7 +319,7 @@ function fnExportList() {
const key = 'exportJobLog';
message.loading({ content: '请稍等...', key });
exportJobLog(toRaw(queryParams)).then(res => {
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `已完成导出`,
key,
@@ -356,7 +357,7 @@ function fnGetList() {
queryParams.beginTime = queryRangePicker.value[0];
queryParams.endTime = queryRangePicker.value[1];
listJobLog(toRaw(queryParams)).then(res => {
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
// 取消勾选
if (tableState.selectedRowKeys.length > 0) {
tableState.selectedRowKeys = [];
@@ -384,7 +385,7 @@ onMounted(() => {
// 指定任务id数据列表
if (jobId && jobId !== '0') {
getJob(jobId).then(res => {
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
queryParams.jobName = res.data.jobName;
queryParams.jobGroup = res.data.jobGroup;
fnGetList();
@@ -534,9 +535,9 @@ onMounted(() => {
<template #icon><ReloadOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip>
<a-tooltip placement="topRight">
<template #title>密度</template>
<a-dropdown trigger="click">
<a-dropdown placement="bottomRight" trigger="click">
<a-button type="text">
<template #icon><ColumnHeightOutlined /></template>
</a-button>

View File

@@ -1,550 +0,0 @@
<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;
if (!queryRangePicker.value) {
queryRangePicker.value = ['', ''];
}
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',
selectedRowKeys: tableState.selectedRowKeys,
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

@@ -1,338 +0,0 @@
<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

@@ -1,696 +0,0 @@
<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;
if (!queryRangePicker.value) {
queryRangePicker.value = ['', ''];
}
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 placement="bottomRight">
<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',
selectedRowKeys: tableState.selectedRowKeys,
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

@@ -3,7 +3,8 @@ 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';
import { getSystemInfo } from '@/api/monitor/system';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
const route = useRoute();
/**路由标题 */
@@ -71,8 +72,8 @@ let server: ServerType = reactive({
});
onMounted(() => {
getServer().then(res => {
if (res.code === 200 && res.data) {
getSystemInfo().then(res => {
if (res.code === RESULT_CODE_SUCCESS && res.data) {
// CPU
let cpu = res.data.cpu;
cpu.coreUsed = cpu.coreUsed.map((item: string) => item).join(' / ');
@@ -127,14 +128,6 @@ onMounted(() => {
<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>
@@ -150,25 +143,9 @@ onMounted(() => {
:column="{ lg: 2, md: 2, xs: 1 }"
:bordered="true"
>
<a-descriptions-item
label="GO版本"
:span="2"
v-if="server.system && server.system.go"
>
<a-descriptions-item label="GO版本" :span="2">
{{ 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>