Forráskód Böngészése

!36 bug修复
Merge pull request !36 from blue/v_2.0.0

blue 2 éve
szülő
commit
1aa43f52b9

+ 0 - 5
im-commom/pom.xml

@@ -59,11 +59,6 @@
             <artifactId>java-jwt</artifactId>
             <version>3.11.0</version>
         </dependency>
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <version>32.1.2-jre</version>
-        </dependency>
         <!-- slf4j -->
         <dependency>
             <groupId>org.slf4j</groupId>

+ 0 - 38
im-platform/src/main/java/com/bx/implatform/config/GlobalCorsConfig.java

@@ -1,38 +0,0 @@
-package com.bx.implatform.config;
-
-import org.springframework.boot.web.servlet.FilterRegistrationBean;
-import org.springframework.context.annotation.Bean;
-import org.springframework.core.Ordered;
-import org.springframework.web.cors.CorsConfiguration;
-import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
-import org.springframework.web.filter.CorsFilter;
-
-import java.util.Arrays;
-
-//@Configuration
-public class GlobalCorsConfig {
-
-    @Bean
-    public FilterRegistrationBean<CorsFilter> corsFilter() {
-        FilterRegistrationBean<CorsFilter> corsFilterFilterRegistrationBean = new FilterRegistrationBean<>();
-        //添加CORS配置信息
-        CorsConfiguration corsConfiguration = new CorsConfiguration();
-        //允许的域,不要写*,否则cookie就无法使用了
-        corsConfiguration.addAllowedOrigin("*");
-        //允许的头信息
-        corsConfiguration.addAllowedHeader("*");
-        //允许的请求方式
-        corsConfiguration.setAllowedMethods(Arrays.asList("POST", "PUT", "GET", "OPTIONS", "DELETE"));
-        //是否发送cookie信息
-        corsConfiguration.setAllowCredentials(true);
-        //预检请求的有效期,单位为秒
-        corsConfiguration.setMaxAge(3600L);
-
-        //添加映射路径,标识待拦截的请求
-        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
-        source.registerCorsConfiguration("/**", corsConfiguration);
-        corsFilterFilterRegistrationBean.setFilter(new CorsFilter(source));
-        corsFilterFilterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE);
-        return corsFilterFilterRegistrationBean;
-    }
-}

+ 3 - 3
im-platform/src/main/java/com/bx/implatform/service/impl/GroupMessageServiceImpl.java

@@ -2,7 +2,7 @@ package com.bx.implatform.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollectionUtil;
-import cn.hutool.core.text.CharSequenceUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -73,7 +73,7 @@ public class GroupMessageServiceImpl extends ServiceImpl<GroupMessageMapper, Gro
         msg.setSendTime(new Date());
         msg.setSendNickName(member.getAliasName());
         if (CollUtil.isNotEmpty(dto.getAtUserIds())) {
-            msg.setAtUserIds(CharSequenceUtil.join(",", dto.getAtUserIds()));
+            msg.setAtUserIds(StrUtil.join(",", dto.getAtUserIds()));
         }
         this.save(msg);
         // 群发
@@ -207,7 +207,7 @@ public class GroupMessageServiceImpl extends ServiceImpl<GroupMessageMapper, Gro
         sendMessage.setSendResult(true);
         imClient.sendGroupMessage(sendMessage);
         // 记录已读消息位置
-        String key = CharSequenceUtil.join(":", RedisKey.IM_GROUP_READED_POSITION, groupId, session.getUserId());
+        String key = StrUtil.join(":", RedisKey.IM_GROUP_READED_POSITION, groupId, session.getUserId());
         redisTemplate.opsForValue().set(key, message.getId());
 
     }

+ 12 - 2
im-ui/src/components/chat/ChatBox.vue

@@ -47,7 +47,7 @@
 								<div title="聊天记录" class="el-icon-chat-dot-round" @click="showHistoryBox()"></div>
 							</div>
 							<div class="send-content-area">
-								<div contenteditable="true" v-show="!sendImageUrl" id="inputText" ref="editBox" class="send-text-area"
+								<div contenteditable="true" v-show="!sendImageUrl" ref="editBox" class="send-text-area"
 									:disabled="lockMessage" @paste.prevent="onEditorPaste"
 									@compositionstart="onEditorCompositionStart"
 									@compositionend="onEditorCompositionEnd" @input="onEditorInput"
@@ -221,7 +221,7 @@
 				let sendText = ""
 				this.$refs.editBox.childNodes.forEach((node) => {
 					if (node.nodeName == "#text") {
-						sendText = document.getElementById("inputText").innerHTML;
+						sendText += this.html2Escape(node.textContent);
 					} else if (node.nodeName == "SPAN") {
 						sendText += node.innerText;
 					} else if (node.nodeName == "IMG") {
@@ -230,6 +230,16 @@
 				})
 				return sendText;
 			},
+			html2Escape(strHtml) {
+				return strHtml.replace(/[<>&"]/g, function(c) {
+					return {
+						'<': '&lt;',
+						'>': '&gt;',
+						'&': '&amp;',
+						'"': '&quot;'
+					}[c];
+				});
+			},
 			createAtUserIds() {
 				let ids = [];
 				this.$refs.editBox.childNodes.forEach((node) => {

+ 1 - 1
im-uniapp/package.json

@@ -6,7 +6,7 @@
 				"browser":"chrome",
 				"env": {
 					"UNI_PLATFORM": "h5",
-					"BASE_URL": "http://127.0.0.1:8888",
+					"BASE_URL": "/api",
 					"WS_URL": "ws://127.0.0.1:8878/im"
 				}
 			},

+ 19 - 0
im-uniapp/vite.config.js

@@ -0,0 +1,19 @@
+import { defineConfig } from "vite"
+import uni from "@dcloudio/vite-plugin-uni";
+ 
+export default defineConfig({
+	plugins: [
+		uni()
+	],
+	server: {
+		proxy: {
+			'/api': {
+				rewrite: path => path.replace(/^\/api/, ''),
+				logLevel: 'debug',
+				target: 'http://localhost:8888',
+				changeOrigin: true
+			},
+			
+		}
+	}
+})