fix: 修复消息通知websocket的连接问题

This commit is contained in:
2023-05-10 15:49:52 +08:00
parent 5e308a87df
commit 1aa8203011
9 changed files with 19 additions and 11 deletions

View File

@@ -104,7 +104,7 @@ public class WebSocketServer {
/**
* 群发自定义消息
* */
public static void sendInfo(SocketMsg socketMsg,@PathParam("sid") String sid) throws IOException {
public static void sendInfo(SocketMsg socketMsg, @PathParam("sid") String sid) throws IOException {
String message = JSONObject.toJSONString(socketMsg);
log.info("推送消息到"+sid+",推送内容:"+message);
for (WebSocketServer item : webSocketSet) {

View File

@@ -6,6 +6,7 @@ import cn.dev33.satoken.stp.StpLogic;
import cn.dev33.satoken.stp.StpUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
@@ -17,12 +18,12 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
* @Date: 2022-09-20
*/
@Slf4j
@RequiredArgsConstructor
@Configuration
public class SaTokenConfigure implements WebMvcConfigurer {
// 白名单
private final SecurityProperties securityProperties;
@Autowired
private SecurityProperties securityProperties;
// Sa-Token 整合 jwt (Simple 简单模式)
@Bean

View File

@@ -23,7 +23,7 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter;
* @author ZhangHouYing
* @date 2019-08-24 15:44
*/
//@Configuration
@Configuration
public class WebSocketConfig {
@Bean

View File

@@ -1,6 +1,7 @@
package org.nl.system.service.menu.dao;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -117,6 +118,7 @@ public class SysMenu implements Serializable {
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date create_time;
/**
@@ -132,6 +134,7 @@ public class SysMenu implements Serializable {
/**
* 修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date update_time;

View File

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.enums.NoticeEnum;
@@ -26,6 +27,7 @@ import org.nl.system.service.notice.dao.SysNotice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
@@ -48,7 +50,7 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
@Autowired
private SysDictMapper dictMapper;
@Autowired
@Resource
private WebSocketServer webSocketServer;
@Override
@@ -153,6 +155,7 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
@Override
public void createNotice(String msg, String title, String type) {
log.info("创建消息通知:信息-{}, 标题-{}, 类型-{}", msg, title, type);
// 获取标题相同的信息
List<SysNotice> sysNotices = sysNoticeMapper.selectList(new LambdaQueryWrapper<SysNotice>().eq(SysNotice::getNotice_title, title));
if (ObjectUtil.isNotEmpty(sysNotices)) return;

View File

@@ -75,7 +75,6 @@ security:
# actuator 监控配置
- /actuator
- /actuator/**
- /**
# 上传
- /api/localStorage/pictures
# 参数

View File

@@ -4,7 +4,6 @@ window.g = {
},
prod: {
VUE_APP_BASE_API: 'http://127.0.0.1:8010'
}
}

View File

@@ -76,6 +76,9 @@ export default {
Doc,
TopNav
},
created() {
this.initWebSocket()
},
data() {
return {
Avatar: Avatar,
@@ -106,9 +109,6 @@ export default {
}
}
},
created() {
this.initWebSocket()
},
methods: {
toggleSideBar() {
this.$store.dispatch('app/toggleSideBar')

View File

@@ -7,7 +7,7 @@
<div style="margin: 5px" v-loading="loading">
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane :label="d.label" :name="d.value" v-for="d in dict.notice_type" :key="d.id">
<el-empty v-show="notReadMsgList[d.value-1].length == 0" description="暂无信息" ></el-empty>
<el-empty v-if="notReadMsgList && notReadMsgList[d.value-1] && notReadMsgList[d.value-1].length === 0" description="暂无信息" ></el-empty>
<div v-for="o in notReadMsgList[d.value-1]" :key="o.notice_id">
<a href="javascript:" @click="showMessage(o)">
<el-row @click="showMessage">
@@ -52,6 +52,9 @@ export default {
notReadMsgList: []
}
},
beforeMount() {
this.getMessage()
},
methods: {
/**
* 打开列表页