|
@@ -688,14 +688,14 @@ const getList = async (type) => {
|
|
};
|
|
};
|
|
// 响应式变量定义
|
|
// 响应式变量定义
|
|
const timer = ref(null);
|
|
const timer = ref(null);
|
|
-const lastEventId = ref(null);
|
|
|
|
|
|
+const lastEventTime = ref(null);
|
|
// 定时监测新事件的方法
|
|
// 定时监测新事件的方法
|
|
const startMonitoring = (interval = 5000) => {
|
|
const startMonitoring = (interval = 5000) => {
|
|
// 首次获取时设置监测起点
|
|
// 首次获取时设置监测起点
|
|
const initMonitoring = () => {
|
|
const initMonitoring = () => {
|
|
- listEvent({}).then(({ code, rows }) => {
|
|
|
|
|
|
+ listEvent({ pageNum: 1, pageSize: 15 }).then(({ code, rows }) => {
|
|
if (rows.length) {
|
|
if (rows.length) {
|
|
- lastEventId.value = rows[0].id;
|
|
|
|
|
|
+ lastEventTime.value = rows[0].createTime;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
};
|
|
};
|
|
@@ -704,9 +704,11 @@ const startMonitoring = (interval = 5000) => {
|
|
initMonitoring();
|
|
initMonitoring();
|
|
// 设置定时器
|
|
// 设置定时器
|
|
timer.value = setInterval(async () => {
|
|
timer.value = setInterval(async () => {
|
|
- const { rows } = await listEvent({});
|
|
|
|
|
|
+ const { rows } = await listEvent({ pageNum: 1, pageSize: 15 });
|
|
if (rows.length > 0) {
|
|
if (rows.length > 0) {
|
|
- if (rows[0].id !== lastEventId.value) {
|
|
|
|
|
|
+ const index = rows.findIndex((item) => new Date(item.createTime).getTime() > new Date(lastEventTime.value).getTime());
|
|
|
|
+ if (index > -1) {
|
|
|
|
+ lastEventTime.value = rows[index].createTime;
|
|
ElNotification({
|
|
ElNotification({
|
|
title: '提示',
|
|
title: '提示',
|
|
message: '有新事件产生',
|
|
message: '有新事件产生',
|