perf(X-Pack): 定时报告使用websocket机制实时刷新页面

This commit is contained in:
fit2cloud-chenyw 2024-05-30 18:48:06 +08:00
parent e18c7f2507
commit 67af3a7eeb
10 changed files with 33 additions and 27 deletions

View File

@ -14,8 +14,8 @@ import io.dataease.exportCenter.dao.auto.entity.CoreExportTask;
import io.dataease.exportCenter.dao.auto.mapper.CoreExportTaskMapper;
import io.dataease.utils.*;
import io.dataease.visualization.server.DataVisualizationServer;
import io.dataease.websocket.entity.WsMessage;
import io.dataease.websocket.service.WsService;
import io.dataease.websocket.WsMessage;
import io.dataease.websocket.WsService;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;

View File

@ -1,7 +1,7 @@
package io.dataease.websocket.aop;
import io.dataease.websocket.entity.WsMessage;
import io.dataease.websocket.service.WsService;
import io.dataease.websocket.WsMessage;
import io.dataease.websocket.WsService;
import org.apache.commons.lang3.ArrayUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;

View File

@ -1,11 +0,0 @@
package io.dataease.websocket.service;
import io.dataease.websocket.entity.WsMessage;
public interface WsService {
void releaseMessage(WsMessage wsMessage);
}

View File

@ -1,7 +1,7 @@
package io.dataease.websocket.service.impl;
import io.dataease.websocket.entity.WsMessage;
import io.dataease.websocket.service.WsService;
import io.dataease.websocket.WsMessage;
import io.dataease.websocket.WsService;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.messaging.simp.SimpMessagingTemplate;

View File

@ -96,7 +96,6 @@ const refresh = async (formEl: FormInstance | undefined) => {
})
}
onMounted(() => {
debugger
if (!wsCache.get(appStore.getDekey)) {
queryDekey()
.then(res => {

View File

@ -1,9 +1,8 @@
<script lang="ts" setup>
import { ref, h, onUnmounted, onMounted } from 'vue'
import { ref, h, onUnmounted } from 'vue'
import { EmptyBackground } from '@/components/empty-background'
import { ElButton, ElMessage, ElMessageBox, ElTabPane, ElTabs } from 'element-plus-secondary'
import { RefreshLeft } from '@element-plus/icons-vue'
import eventBus from '@/utils/eventBus'
import {
exportTasks,
exportRetry,
@ -327,7 +326,7 @@ const delAll = () => {
})
}
eventBus.on('task-export-topic-call', taskExportTopicCall)
useEmitt({ name: 'task-export-topic-call', callback: taskExportTopicCall })
defineExpose({
init

View File

@ -1,11 +1,13 @@
import SockJS from 'sockjs-client/dist/sockjs.min.js'
import Stomp from 'stompjs'
import eventBus from '@/utils/eventBus'
import { useCache } from '@/hooks/web/useCache'
import { useEmitt } from '@/hooks/web/useEmitt'
const { wsCache } = useCache()
let stompClient: Stomp.Client
let timeInterval: NodeJS.Timer | null = null
const basePath = import.meta.env.VITE_API_BASEPATH
import dev from '../../config/dev'
const env = import.meta.env
const basePath = env.VITE_API_BASEPATH
export default {
install() {
@ -13,6 +15,10 @@ export default {
{
topic: '/task-export-topic',
event: 'task-export-topic-call'
},
{
topic: '/report-notici',
event: 'report-notici-call'
}
]
function isLoginStatus() {
@ -32,6 +38,9 @@ export default {
} else {
const href = window.location.href
prefix = href.substring(0, href.indexOf('#'))
if (env.MODE === 'dev') {
prefix = dev.server.proxy[basePath].target + '/'
}
}
const socket = new SockJS(prefix + 'websocket?userId=' + wsCache.get('user.uid'))
stompClient = Stomp.over(socket)
@ -40,10 +49,10 @@ export default {
}
stompClient.connect(
heads,
res => {
() => {
channels.forEach(channel => {
stompClient.subscribe('/user/' + wsCache.get('user.uid') + channel.topic, res => {
res && res.body && eventBus.emit(channel.event, res.body)
res && res.body && useEmitt().emitter.emit(channel.event, res.body)
})
})
},

@ -1 +1 @@
Subproject commit 4f83c4df67befbd90eb219b2d6d04c04e213179f
Subproject commit afbf1f3843f0c2f32da55ed7ea83a9c65e144a2e

View File

@ -1,4 +1,4 @@
package io.dataease.websocket.entity;
package io.dataease.websocket;
import lombok.AllArgsConstructor;
import lombok.Data;

View File

@ -0,0 +1,10 @@
package io.dataease.websocket;
public interface WsService {
void releaseMessage(WsMessage wsMessage);
}