feat: 添加生产环境配置并优化在线用户监控功能

- 添加生产环境相关配置文件(.env.prod, .env.production, docker-compose.prod.yaml)到.gitignore
- 更新前后端生产环境配置,包括数据库、Redis等连接信息
- 重构在线用户监控页面,优化查询逻辑和分页处理
- 调整路由配置,将个人中心路由移至根路由下
- 修改接口参数处理,将IP地址查询改为模糊查询
This commit is contained in:
zhangtao
2025-05-28 00:23:14 +08:00
parent 412068f4da
commit d9f42f9d08
8 changed files with 97 additions and 86 deletions
+22 -17
View File
@@ -32,6 +32,25 @@ export const generator = (routers) => {
};
const rootRouter = {
path: "/",
name: "Index",
redirect: "/dashboard",
component: BasicLayout,
children: [
{
path: "/profile",
name: "Profile",
meta: {
title: "个人中心",
keepAlive: true,
},
component: () => import("../views/current/profile.vue"),
},
],
};
const routes = [
{ path: "/login",
name: "Login",
@@ -60,25 +79,11 @@ const routes = [
meta: { title: "404" },
component: () => import("../views/exception/404.vue"),
},
{
...rootRouter,
},
];
const rootRouter = {
path: "/",
name: "Index",
redirect: "/dashboard",
component: BasicLayout,
children: [
{
path: "/profile",
name: "Profile",
meta: {
title: "个人中心",
keepAlive: true,
},
component: () => import("../views/current/profile.vue"),
},
],
};
const router = createRouter({
history: createWebHistory(),
+51 -50
View File
@@ -4,7 +4,7 @@
<!-- 搜索表单 -->
<div class="table-search-wrapper">
<a-card :bordered="false">
<a-form :model="queryState" @finish="handleQuery">
<a-form :model="queryState" @finish="onFinish">
<a-flex wrap="wrap" gap="small">
<a-form-item name="ipaddr" label="主机" >
@@ -36,8 +36,9 @@
<a-table
:rowKey="record => record.session_id"
:columns="columns"
:data-source="tableData"
:data-source="dataSource"
:loading="loading"
@change="handlePageChange"
:scroll="{ x: 400 }"
:pagination="pagination"
:style="{ minHeight: 'calc(100vh - 420px)' }"
@@ -62,22 +63,15 @@
</template>
<script lang="ts" setup>
import { ref, reactive, computed, onMounted } from 'vue';
import { ref, reactive, onMounted } from 'vue';
import { DeleteOutlined } from '@ant-design/icons-vue';
import { Modal, message } from 'ant-design-vue';
import { getOnlineList, deleteOnline} from "@/api/monitor/online";
import type { QueryState, OnlineUser } from './types';
import type { searchType, OnlineUser } from './types';
const onlineList = ref<OnlineUser[]>([]);
const dataSource = ref<OnlineUser[]>([]);
const loading = ref(false);
const total = ref(0);
const pageNum = ref(1);
const pageSize = ref(10);
const queryState = ref<QueryState>({
ipaddr: undefined,
name: undefined
});
const queryState = reactive<searchType>({});
const columns = [
{ title: '会话编号', dataIndex: 'session_id', key: 'sessionId', ellipsis: true },
@@ -96,43 +90,54 @@ const pagination = reactive({
pageSize: 10,
defaultPageSize: 10,
showSizeChanger: true,
total: onlineList.value.length,
total: dataSource.value.length,
showTotal: (total, range) => `${range[0]}-${range[1]} 条 / 总共 ${total}`
})
const tableData = computed(() => {
if (!onlineList.value) return [];
const start = (pageNum.value - 1) * pageSize.value;
return onlineList.value.slice(start, start + pageSize.value);
});
const onFinish = () => {
pagination.current = 1;
loadingData();
};
const getList = async () => {
try {
loading.value = true;
const response = await getOnlineList(queryState.value);
onlineList.value = response?.data?.data?.items || [];
total.value = response?.data?.data?.total || 0;
} catch (error) {
message.error('获取数据失败');
onlineList.value = [];
total.value = 0;
} finally {
loading.value = false;
const loadingData = async () => {
loading.value = true;
let params = {};
if (queryState.ipaddr) {
params['ipaddr'] = queryState.ipaddr
}
};
const handleQuery = () => {
pageNum.value = 1;
getList();
};
if (queryState.name) {
params['name'] = queryState.name
}
if (queryState.login_location) {
params['login_location'] = queryState.login_location
}
params['page_no'] = pagination.current;
params['page_size'] = pagination.pageSize;
getOnlineList(params).then(response => {
const result = response.data;
dataSource.value = result.data.items;
pagination.total = result.data.total;
pagination.current = result.data.page_no;
pagination.pageSize = result.data.page_size;
}).catch(error => {
console.log(error);
}).finally(() => {
loading.value = false;
});
};
const resetQuery = () => {
Object.keys(queryState.value).forEach((key: string) => {
delete queryState.value[key];
Object.keys(queryState).forEach((key: string) => {
delete queryState[key];
});
pagination.current = 1;
getList();
loadingData();
};
const handleForceLogout = (row: OnlineUser) => {
@@ -143,7 +148,7 @@ const handleForceLogout = (row: OnlineUser) => {
async onOk() {
try {
await deleteOnline(row.session_id);
await getList();
await loadingData();
message.success('强退成功');
} catch (error) {
message.error('强退失败');
@@ -152,19 +157,15 @@ const handleForceLogout = (row: OnlineUser) => {
});
};
const handlePageChange = (page: number, size: number) => {
pageNum.value = page;
pageSize.value = size;
const handlePageChange = (values: any) => {
pagination.current = values.current;
pagination.pageSize = values.pageSize;
loadingData();
};
const handlePageSizeChange = (current: number, size: number) => {
pageSize.value = size;
pageNum.value = 1;
};
onMounted(() => {
getList();
});
onMounted(() => loadingData());
</script>
<style lang="scss" scoped>
+1 -1
View File
@@ -1,4 +1,4 @@
export interface QueryState {
export interface searchType {
ipaddr?: string;
name?: string;
login_location?: string;