forked from github/dataease
perf(X-Pack): 定时报告使用websocket机制实时刷新页面
This commit is contained in:
parent
e18c7f2507
commit
67af3a7eeb
@ -14,8 +14,8 @@ import io.dataease.exportCenter.dao.auto.entity.CoreExportTask;
|
|||||||
import io.dataease.exportCenter.dao.auto.mapper.CoreExportTaskMapper;
|
import io.dataease.exportCenter.dao.auto.mapper.CoreExportTaskMapper;
|
||||||
import io.dataease.utils.*;
|
import io.dataease.utils.*;
|
||||||
import io.dataease.visualization.server.DataVisualizationServer;
|
import io.dataease.visualization.server.DataVisualizationServer;
|
||||||
import io.dataease.websocket.entity.WsMessage;
|
import io.dataease.websocket.WsMessage;
|
||||||
import io.dataease.websocket.service.WsService;
|
import io.dataease.websocket.WsService;
|
||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package io.dataease.websocket.aop;
|
package io.dataease.websocket.aop;
|
||||||
|
|
||||||
import io.dataease.websocket.entity.WsMessage;
|
import io.dataease.websocket.WsMessage;
|
||||||
import io.dataease.websocket.service.WsService;
|
import io.dataease.websocket.WsService;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.aspectj.lang.JoinPoint;
|
import org.aspectj.lang.JoinPoint;
|
||||||
import org.aspectj.lang.annotation.AfterReturning;
|
import org.aspectj.lang.annotation.AfterReturning;
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
package io.dataease.websocket.service;
|
|
||||||
|
|
||||||
import io.dataease.websocket.entity.WsMessage;
|
|
||||||
|
|
||||||
|
|
||||||
public interface WsService {
|
|
||||||
|
|
||||||
void releaseMessage(WsMessage wsMessage);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
package io.dataease.websocket.service.impl;
|
package io.dataease.websocket.service.impl;
|
||||||
|
|
||||||
import io.dataease.websocket.entity.WsMessage;
|
import io.dataease.websocket.WsMessage;
|
||||||
import io.dataease.websocket.service.WsService;
|
import io.dataease.websocket.WsService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||||
|
@ -96,7 +96,6 @@ const refresh = async (formEl: FormInstance | undefined) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
debugger
|
|
||||||
if (!wsCache.get(appStore.getDekey)) {
|
if (!wsCache.get(appStore.getDekey)) {
|
||||||
queryDekey()
|
queryDekey()
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, h, onUnmounted, onMounted } from 'vue'
|
import { ref, h, onUnmounted } from 'vue'
|
||||||
import { EmptyBackground } from '@/components/empty-background'
|
import { EmptyBackground } from '@/components/empty-background'
|
||||||
import { ElButton, ElMessage, ElMessageBox, ElTabPane, ElTabs } from 'element-plus-secondary'
|
import { ElButton, ElMessage, ElMessageBox, ElTabPane, ElTabs } from 'element-plus-secondary'
|
||||||
import { RefreshLeft } from '@element-plus/icons-vue'
|
import { RefreshLeft } from '@element-plus/icons-vue'
|
||||||
import eventBus from '@/utils/eventBus'
|
|
||||||
import {
|
import {
|
||||||
exportTasks,
|
exportTasks,
|
||||||
exportRetry,
|
exportRetry,
|
||||||
@ -327,7 +326,7 @@ const delAll = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
eventBus.on('task-export-topic-call', taskExportTopicCall)
|
useEmitt({ name: 'task-export-topic-call', callback: taskExportTopicCall })
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
init
|
init
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import SockJS from 'sockjs-client/dist/sockjs.min.js'
|
import SockJS from 'sockjs-client/dist/sockjs.min.js'
|
||||||
import Stomp from 'stompjs'
|
import Stomp from 'stompjs'
|
||||||
import eventBus from '@/utils/eventBus'
|
|
||||||
import { useCache } from '@/hooks/web/useCache'
|
import { useCache } from '@/hooks/web/useCache'
|
||||||
|
import { useEmitt } from '@/hooks/web/useEmitt'
|
||||||
const { wsCache } = useCache()
|
const { wsCache } = useCache()
|
||||||
let stompClient: Stomp.Client
|
let stompClient: Stomp.Client
|
||||||
let timeInterval: NodeJS.Timer | null = null
|
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 {
|
export default {
|
||||||
install() {
|
install() {
|
||||||
@ -13,6 +15,10 @@ export default {
|
|||||||
{
|
{
|
||||||
topic: '/task-export-topic',
|
topic: '/task-export-topic',
|
||||||
event: 'task-export-topic-call'
|
event: 'task-export-topic-call'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
topic: '/report-notici',
|
||||||
|
event: 'report-notici-call'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
function isLoginStatus() {
|
function isLoginStatus() {
|
||||||
@ -32,6 +38,9 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
const href = window.location.href
|
const href = window.location.href
|
||||||
prefix = href.substring(0, href.indexOf('#'))
|
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'))
|
const socket = new SockJS(prefix + 'websocket?userId=' + wsCache.get('user.uid'))
|
||||||
stompClient = Stomp.over(socket)
|
stompClient = Stomp.over(socket)
|
||||||
@ -40,10 +49,10 @@ export default {
|
|||||||
}
|
}
|
||||||
stompClient.connect(
|
stompClient.connect(
|
||||||
heads,
|
heads,
|
||||||
res => {
|
() => {
|
||||||
channels.forEach(channel => {
|
channels.forEach(channel => {
|
||||||
stompClient.subscribe('/user/' + wsCache.get('user.uid') + channel.topic, res => {
|
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)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
2
de-xpack
2
de-xpack
@ -1 +1 @@
|
|||||||
Subproject commit 4f83c4df67befbd90eb219b2d6d04c04e213179f
|
Subproject commit afbf1f3843f0c2f32da55ed7ea83a9c65e144a2e
|
@ -1,4 +1,4 @@
|
|||||||
package io.dataease.websocket.entity;
|
package io.dataease.websocket;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -0,0 +1,10 @@
|
|||||||
|
package io.dataease.websocket;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public interface WsService {
|
||||||
|
|
||||||
|
void releaseMessage(WsMessage wsMessage);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user