Browse Source

代码整理优化

master
xie.bx 3 years ago
parent
commit
db40f25433
  1. 31
      commom/pom.xml
  2. 16
      im-platform/pom.xml
  3. 2
      im-platform/src/main/java/com/lx/implatform/ImplatformApp.java
  4. 39
      im-platform/src/main/java/com/lx/implatform/config/GlobalCorsConfig.java
  5. 1
      im-platform/src/main/java/com/lx/implatform/config/WebSecurityConfg.java
  6. 2
      im-platform/src/main/java/com/lx/implatform/service/impl/FriendServiceImpl.java
  7. 3
      im-platform/src/main/java/com/lx/implatform/service/impl/GroupServiceImpl.java
  8. 2
      im-platform/src/main/java/com/lx/implatform/service/impl/SecurityUserDetailsServiceImpl.java
  9. 15
      im-platform/src/main/java/com/lx/implatform/task/PullAlreadyReadMessageTask.java
  10. 4
      im-platform/src/main/resources/application.yml
  11. 14
      im-platform/src/main/resources/db/db.sql
  12. 16
      im-server/pom.xml
  13. 2
      im-server/src/main/java/com/lx/implatform/imserver/IMServerApp.java
  14. 42
      im-server/src/main/java/com/lx/implatform/imserver/task/AbstractPullMessageTask.java
  15. 1
      im-server/src/main/java/com/lx/implatform/imserver/task/PullUnreadGroupMessageTask.java
  16. 1
      im-ui/src/api/httpRequest.js
  17. 20
      im-ui/src/components/chat/ChatGroup.vue
  18. 7
      im-ui/src/components/chat/ChatGroupSide.vue
  19. 16
      im-ui/src/components/chat/ChatPrivate.vue
  20. 2
      im-ui/src/components/common/HeadImage.vue
  21. 2
      im-ui/src/components/common/UserInfo.vue
  22. 4
      im-ui/src/components/friend/AddFriend.vue
  23. 2
      im-ui/src/components/group/AddGroupMember.vue
  24. 17
      im-ui/src/components/setting/Setting.vue
  25. 4
      im-ui/src/store/friendStore.js
  26. 2
      im-ui/src/store/groupStore.js
  27. 2
      im-ui/src/store/userStore.js
  28. 6
      im-ui/src/view/Chat.vue
  29. 6
      im-ui/src/view/Friend.vue
  30. 17
      im-ui/src/view/Group.vue
  31. 14
      im-ui/src/view/Home.vue
  32. 2
      im-ui/src/view/Login.vue
  33. 2
      im-ui/src/view/Register.vue
  34. 24
      pom.xml

31
commom/pom.xml

@ -17,28 +17,33 @@
<dependencies>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>compile</scope>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
<!--FastJson-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
@ -53,9 +58,5 @@
<artifactId>velocity</artifactId>
<version>${velocity.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
</project>

16
im-platform/pom.xml

@ -104,14 +104,18 @@
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

2
im-platform/src/main/java/com/lx/implatform/ImplatformApp.java

@ -16,6 +16,6 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy;
public class ImplatformApp {
public static void main(String[] args) {
SpringApplication.run(ImplatformApp.class);
SpringApplication.run(ImplatformApp.class,args);
}
}

39
im-platform/src/main/java/com/lx/implatform/config/GlobalCorsConfig.java

@ -0,0 +1,39 @@
package com.lx.implatform.config;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
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;
}
}

1
im-platform/src/main/java/com/lx/implatform/config/WebSecurityConfg.java

@ -149,6 +149,7 @@ public class WebSecurityConfg extends WebSecurityConfigurerAdapter {
AuthenticationEntryPoint entryPoint(){
return (request, response, exception) -> {
response.setContentType("application/json;charset=utf-8");
log.info(request.getRequestURI());
PrintWriter out = response.getWriter();
Result result = ResultUtils.error(ResultCode.NO_LOGIN);
out.write(new ObjectMapper().writeValueAsString(result));

2
im-platform/src/main/java/com/lx/implatform/service/impl/FriendServiceImpl.java

@ -40,7 +40,7 @@ public class FriendServiceImpl extends ServiceImpl<FriendMapper, Friend> impleme
@Override
public List<Friend> findFriendByUserId(Long UserId) {
QueryWrapper<Friend> queryWrapper = new QueryWrapper<>();
QueryWrapper<Friend> queryWrapper = new QueryWrapper();
queryWrapper.lambda().eq(Friend::getUserId,UserId);
List<Friend> friends = this.list(queryWrapper);
return friends;

3
im-platform/src/main/java/com/lx/implatform/service/impl/GroupServiceImpl.java

@ -71,9 +71,12 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements
groupMember.setGroupId(group.getId());
groupMember.setUserId(user.getId());
groupMember.setAliasName(user.getNickName());
groupMember.setRemark(groupName);
groupMember.setHeadImage(user.getHeadImageThumb());
groupMemberService.save(groupMember);
GroupVO vo = BeanUtils.copyProperties(group, GroupVO.class);
vo.setAliasName(user.getNickName());
vo.setRemark(groupName);
return vo;
}

2
im-platform/src/main/java/com/lx/implatform/service/impl/SecurityUserDetailsServiceImpl.java

@ -31,7 +31,7 @@ public class SecurityUserDetailsServiceImpl implements UserDetailsService {
throw new UsernameNotFoundException("用户不存在");
}
//定义权限列表.
List<GrantedAuthority> authorities = new ArrayList<>();
List<GrantedAuthority> authorities = new ArrayList();
// 用户可以访问的资源名称(或者说用户所拥有的权限) 注意:必须"ROLE_"开头
authorities.add(new SimpleGrantedAuthority("ROLE_XX"));

15
im-platform/src/main/java/com/lx/implatform/task/PullAlreadyReadMessageTask.java

@ -5,12 +5,14 @@ import com.lx.common.contant.RedisKey;
import com.lx.common.enums.MessageStatusEnum;
import com.lx.implatform.entity.PrivateMessage;
import com.lx.implatform.service.IPrivateMessageService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@ -32,16 +34,24 @@ public class PullAlreadyReadMessageTask {
@PostConstruct
public void init(){
for(int i=0;i<threadNum;i++){
executorService.submit(new Task());
executorService.execute(new Task());
}
}
@PreDestroy
public void destroy(){
log.info("{}线程任务关闭",this.getClass().getSimpleName());
executorService.shutdown();
}
protected class Task implements Runnable{
@SneakyThrows
@Override
public void run() {
try {
String key = RedisKey.IM_READED_PRIVATE_MESSAGE_ID;
Integer msgId = (Integer)redisTemplate.opsForList().leftPop(key,1, TimeUnit.SECONDS);
Integer msgId = (Integer)redisTemplate.opsForList().leftPop(key,10, TimeUnit.SECONDS);
if(msgId!=null){
UpdateWrapper<PrivateMessage> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda().eq(PrivateMessage::getId,msgId)
@ -51,6 +61,7 @@ public class PullAlreadyReadMessageTask {
}
}catch (Exception e){
log.error(e.getMessage());
Thread.sleep(200);
}finally {
// 下一次循环
executorService.submit(this);

4
im-platform/src/main/resources/application.yml

@ -29,8 +29,8 @@ mybatis-plus:
# *.xml的具体路径
- classpath*:mapper/*.xml
minio:
endpoint: http://127.0.0.1:9001
public: http://127.0.0.1:9001
endpoint: http://127.0.0.1:9001 #内网地址
public: http://3xagfu.natappfree.cc/file #外网访问地址
accessKey: admin
secretKey: 12345678
bucketName: lx-im

14
im-platform/src/main/resources/db/db.sql

@ -1,4 +1,4 @@
use `lx-im`;
use `box-im`;
create table `im_user`(
`id` bigint not null auto_increment primary key comment 'id',
`user_name` varchar(255) not null comment '用户名',
@ -33,7 +33,7 @@ create table `im_private_message`(
`type` tinyint(1) NOT NULL comment '消息类型 0:文字 1:图片 2:文件',
`status` tinyint(1) NOT NULL comment '状态 0:未读 1:已读 ',
`send_time` datetime DEFAULT CURRENT_TIMESTAMP comment '发送时间',
key `idx_send_recv_user_id` (`send_user_id`,`recv_user_id`)
key `idx_send_recv_id` (`send_id`,`recv_id`)
)ENGINE=InnoDB CHARSET=utf8mb3 comment '私聊消息';
@ -71,13 +71,3 @@ create table `im_group_message`(
`send_time` datetime DEFAULT CURRENT_TIMESTAMP comment '发送时间',
key `idx_group_id` (group_id)
)ENGINE=InnoDB CHARSET=utf8mb3 comment '群消息';
create table `im_group_message_read_pos`(
`id` bigint not null auto_increment primary key comment 'id',
`group_id` bigint not null comment '群id',
`user_id` bigint not null comment '用户id',
`read_pos` bigint default 0 comment '已读取消息的最大消息id',
`last_read_time` datetime DEFAULT CURRENT_TIMESTAMP comment '最后读取时间',
key `idx_user_id`(`user_id`)
)ENGINE=InnoDB CHARSET=utf8mb3 comment '群消息读取位置';

16
im-server/pom.xml

@ -39,14 +39,18 @@
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

2
im-server/src/main/java/com/lx/implatform/imserver/IMServerApp.java

@ -25,7 +25,7 @@ public class IMServerApp implements CommandLineRunner {
private WebsocketServer WSServer;
public static void main(String[] args) {
SpringApplication.run(IMServerApp.class);
SpringApplication.run(IMServerApp.class,args);
}

42
im-server/src/main/java/com/lx/implatform/imserver/task/AbstractPullMessageTask.java

@ -1,10 +1,12 @@
package com.lx.implatform.imserver.task;
import com.lx.implatform.imserver.websocket.WebsocketServer;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -29,21 +31,37 @@ public abstract class AbstractPullMessageTask{
public void init(){
// 初始化定时器
executorService = Executors.newFixedThreadPool(threadNum);
executorService.execute(new Runnable() {
@Override
public void run() {
try{
if(WSServer.isReady()){
pullMessage();
for(int i=0;i<threadNum;i++){
executorService.execute(new Runnable() {
@SneakyThrows
@Override
public void run() {
try{
if(WSServer.isReady()){
pullMessage();
}
Thread.sleep(100);
}catch (Exception e){
log.error("任务调度异常",e);
Thread.sleep(200);
}
if(!executorService.isShutdown()){
executorService.execute(this);
}
Thread.sleep(100);
}catch (Exception e){
log.error("任务调度异常",e);
}
executorService.execute(this);
}
});
});
}
}
@PreDestroy
public void destroy(){
log.info("{}线程任务关闭",this.getClass().getSimpleName());
executorService.shutdown();
}
public abstract void pullMessage();
}

1
im-server/src/main/java/com/lx/implatform/imserver/task/PullUnreadGroupMessageTask.java

@ -28,6 +28,7 @@ public class PullUnreadGroupMessageTask extends AbstractPullMessageTask {
private RedisTemplate<String,Object> redisTemplate;
@Override
public void pullMessage() {
// 从redis拉取未读消息

1
im-ui/src/api/httpRequest.js

@ -3,6 +3,7 @@ import router from '@/router'
import {Message} from 'element-ui'
const http = axios.create({
baseURL: process.env.VUE_APP_BASE_API,
timeout: 1000 * 30,
withCredentials: true,
headers: {

20
im-ui/src/components/chat/ChatGroup.vue

@ -21,13 +21,13 @@
<div class="chat-tool-bar">
<div title="表情" class="el-icon-service" @click="$message.error('还不支持发表情符号呢')"></div>
<div title="发送图片" >
<file-upload action="/api/image/upload" :maxSize="5*1024*1024" :fileTypes="['image/jpeg', 'image/png', 'image/jpg', 'image/webp','image/gif']"
<file-upload :action="imageAction" :maxSize="5*1024*1024" :fileTypes="['image/jpeg', 'image/png', 'image/jpg', 'image/webp','image/gif']"
@before="handleImageBefore" @success="handleImageSuccess" @fail="handleImageFail">
<i class="el-icon-picture-outline"></i>
</file-upload>
</div>
<div title="发送文件">
<file-upload action="/api/file/upload" :maxSize="10*1024*1024" @before="handleFileBefore" @success="handleFileSuccess"
<file-upload :action="fileAction" :maxSize="10*1024*1024" @before="handleFileBefore" @success="handleFileSuccess"
@fail="handleFileFail">
<i class="el-icon-wallet"></i>
</file-upload>
@ -80,7 +80,7 @@
type: 1
}
this.$http({
url: '/api/message/group/send',
url: '/message/group/send',
method: 'post',
data: msgInfo
}).then((data) => {
@ -138,7 +138,7 @@
type: 2
}
this.$http({
url: '/api/message/group/send',
url: '/message/group/send',
method: 'post',
data: msgInfo
}).then(() => {
@ -200,7 +200,7 @@
type: 0
}
this.$http({
url: '/api/message/group/send',
url: '/message/group/send',
method: 'post',
data: msgInfo
}).then((data) => {
@ -224,7 +224,7 @@
},
loadGroup(groupId) {
this.$http({
url: `/api/group/find/${groupId}`,
url: `/group/find/${groupId}`,
method: 'get'
}).then((group) => {
this.group = group;
@ -232,7 +232,7 @@
});
this.$http({
url: `/api/group/members/${groupId}`,
url: `/group/members/${groupId}`,
method: 'get'
}).then((groupMembers) => {
this.groupMembers = groupMembers;
@ -261,6 +261,12 @@
title() {
let size = this.groupMembers.filter(m => !m.quit).length;
return `${this.chat.showName}(${size})`;
},
imageAction(){
return `${process.env.VUE_APP_BASE_API}/image/upload`;
},
fileAction(){
return `${process.env.VUE_APP_BASE_API}/file/upload`;
}
},

7
im-ui/src/components/chat/ChatGroupSide.vue

@ -80,7 +80,7 @@
},
loadGroupMembers() {
this.$http({
url: `/api/group/members/${this.group.id}`,
url: `/group/members/${this.group.id}`,
method: "get"
}).then((members) => {
this.groupMembers = members;
@ -89,7 +89,7 @@
handleSaveGroup() {
let vo = this.group;
this.$http({
url: "/api/group/modify",
url: "/group/modify",
method: "put",
data: vo
}).then((group) => {
@ -105,7 +105,7 @@
type: 'warning'
}).then(() => {
this.$http({
url: `/api/group/quit/${this.group.id}`,
url: `/group/quit/${this.group.id}`,
method: 'delete'
}).then(() => {
this.$store.commit("removeGroup", this.group.id);
@ -124,6 +124,7 @@
isOwner() {
return this.group.ownerId == this.$store.state.userStore.userInfo.id;
}
}
}
</script>

16
im-ui/src/components/chat/ChatPrivate.vue

@ -18,13 +18,13 @@
<div class="chat-tool-bar">
<div class="el-icon-service"></div>
<div>
<file-upload action="/api/image/upload" :maxSize="5*1024*1024" :fileTypes="['image/jpeg', 'image/png', 'image/jpg','image/webp', 'image/gif']"
<file-upload :action="imageAction" :maxSize="5*1024*1024" :fileTypes="['image/jpeg', 'image/png', 'image/jpg','image/webp', 'image/gif']"
@before="handleImageBefore" @success="handleImageSuccess" @fail="handleImageFail">
<i class="el-icon-picture-outline"></i>
</file-upload>
</div>
<div>
<file-upload action="/api/file/upload" :maxSize="10*1024*1024" @before="handleFileBefore" @success="handleFileSuccess"
<file-upload :action="fileAction" :maxSize="10*1024*1024" @before="handleFileBefore" @success="handleFileSuccess"
@fail="handleFileFail">
<i class="el-icon-wallet"></i>
</file-upload>
@ -67,7 +67,7 @@
type: 1
}
this.$http({
url: '/api/message/private/send',
url: '/message/private/send',
method: 'post',
data: msgInfo
}).then((data) => {
@ -126,7 +126,7 @@
type: 2
}
this.$http({
url: '/api/message/private/send',
url: '/message/private/send',
method: 'post',
data: msgInfo
}).then(() => {
@ -180,7 +180,7 @@
type: 0
}
this.$http({
url: '/api/message/private/send',
url: '/message/private/send',
method: 'post',
data: msgInfo
}).then((data) => {
@ -212,6 +212,12 @@
computed: {
mine() {
return this.$store.state.userStore.userInfo;
},
imageAction(){
return `${process.env.VUE_APP_BASE_API}/image/upload`;
},
fileAction(){
return `${process.env.VUE_APP_BASE_API}/file/upload`;
}
},
mounted() {

2
im-ui/src/components/common/HeadImage.vue

@ -28,7 +28,7 @@
showUserInfo(e){
if(this.id && this.id>0){
this.$http({
url: `/api/user/find/${this.id}`,
url: `/user/find/${this.id}`,
method: 'get'
}).then((user) => {
this.$store.commit("setUserInfoBoxPos",e);

2
im-ui/src/components/common/UserInfo.vue

@ -63,7 +63,7 @@
},
handleAddFriend() {
this.$http({
url: "/api/friend/add",
url: "/friend/add",
method: "post",
params: {
friendId: this.user.id

4
im-ui/src/components/friend/AddFriend.vue

@ -45,7 +45,7 @@
},
handleSearch() {
this.$http({
url: "/api/user/findByNickName",
url: "/user/findByNickName",
method: "get",
params: {
nickName: this.searchText
@ -56,7 +56,7 @@
},
handleAddFriend(user){
this.$http({
url: "/api/friend/add",
url: "/friend/add",
method: "post",
params: {
friendId: user.id

2
im-ui/src/components/group/AddGroupMember.vue

@ -64,7 +64,7 @@
})
if (inviteVO.friendIds.length > 0) {
this.$http({
url: "/api/group/invite",
url: "/group/invite",
method: 'post',
data: inviteVO
}).then(() => {

17
im-ui/src/components/setting/Setting.vue

@ -3,7 +3,7 @@
<el-form :model="userInfo" label-width="80px" :rules="rules" ref="settingForm">
<el-form-item label="头像">
<file-upload class="avatar-uploader"
action="/api/image/upload"
:action="imageAction"
:showLoading="true"
:maxSize="maxSize"
@success="handleUploadSuccess"
@ -53,7 +53,7 @@
},
maxSize: 5*1024*1024,
action: "/api/image/upload",
action: "/image/upload",
rules: {
nickName: [{
required: true,
@ -74,7 +74,7 @@
return false;
}
this.$http({
url: "/api/user/update",
url: "/user/update",
method: "put",
data: this.userInfo
}).then(()=>{
@ -94,11 +94,16 @@
type: Boolean
}
},
computed:{
imageAction(){
return `${process.env.VUE_APP_BASE_API}/image/upload`;
}
},
mounted() {
this.userInfo = this.$store.state.userStore.userInfo;
console.log(this.userInfo)
//
let mine = this.$store.state.userStore.userInfo;
this.userInfo = JSON.parse(JSON.stringify(mine));
}
}
</script>

4
im-ui/src/store/friendStore.js

@ -10,7 +10,7 @@ export default {
mutations: {
initFriendStore(state) {
httpRequest({
url: '/api/friend/list',
url: '/friend/list',
method: 'get'
}).then((friends) => {
this.commit("setFriends",friends);
@ -48,7 +48,7 @@ export default {
}
state.friends.forEach((f)=>{userIds.push(f.id)});
httpRequest({
url: '/api/user/online',
url: '/user/online',
method: 'get',
params: {userIds: userIds.join(',')}
}).then((onlineIds) => {

2
im-ui/src/store/groupStore.js

@ -9,7 +9,7 @@ export default {
mutations: {
initGroupStore(state) {
httpRequest({
url: '/api/group/list',
url: '/group/list',
method: 'get'
}).then((groups) => {
this.commit("setGroups",groups);

2
im-ui/src/store/userStore.js

@ -11,7 +11,7 @@ export default {
console.log("用户切换")
this.commit("resetChatStore");
}
state.userInfo = userInfo;
state.userInfo = Object.assign(state.userInfo, userInfo);
}
}

6
im-ui/src/view/Chat.vue

@ -66,7 +66,7 @@
type: 0
}
this.$http({
url: '/api/message/group/send',
url: '/message/group/send',
method: 'post',
data: msgInfo
}).then((data) => {
@ -86,7 +86,7 @@
//
let userId = chat.targetId;
this.$http({
url: `/api/user/find/${userId}`,
url: `/user/find/${userId}`,
method: 'get'
}).then((user) => {
//
@ -104,7 +104,7 @@
headImage: user.headImageThumb
};
this.$http({
url: "/api/friend/update",
url: "/friend/update",
method: "put",
data: friendInfo
}).then(() => {

6
im-ui/src/view/Friend.vue

@ -84,7 +84,7 @@
type: 'warning'
}).then(() => {
this.$http({
url: `/api/friend/delete/${friend.id}`,
url: `/friend/delete/${friend.id}`,
method: 'delete'
}).then((data) => {
this.$message.success("删除好友成功");
@ -117,7 +117,7 @@
friend.headImage = user.headImageThumb;
friend.nickName = user.nickName;
this.$http({
url: "/api/friend/update",
url: "/friend/update",
method: "put",
data: friend
}).then(() => {
@ -127,7 +127,7 @@
},
loadUserInfo(friend,index){
this.$http({
url: `/api/user/find/${friend.id}`,
url: `/user/find/${friend.id}`,
method: 'get'
}).then((user) => {
this.userInfo = user;

17
im-ui/src/view/Group.vue

@ -26,7 +26,7 @@
<div v-show="activeGroup.id">
<div class="r-group-info">
<div>
<file-upload class="avatar-uploader" action="/api/image/upload" :disabled="!isOwner" :showLoading="true"
<file-upload class="avatar-uploader" :action="imageAction" :disabled="!isOwner" :showLoading="true"
:maxSize="maxSize" @success="handleUploadSuccess" :fileTypes="['image/jpeg', 'image/png', 'image/jpg','image/webp']">
<img v-if="activeGroup.headImage" :src="activeGroup.headImage" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
@ -119,7 +119,7 @@
inputErrorMessage: '请输入群聊名称'
}).then((o) => {
this.$http({
url: `/api/group/create?groupName=${o.value}`,
url: `/group/create?groupName=${o.value}`,
method: 'post'
}).then((group) => {
this.$store.commit("addGroup", group);
@ -148,7 +148,7 @@
if (valid) {
let vo = this.activeGroup;
this.$http({
url: "/api/group/modify",
url: "/group/modify",
method: "put",
data: vo
}).then((group) => {
@ -165,7 +165,7 @@
type: 'warning'
}).then(() => {
this.$http({
url: `/api/group/delete/${this.activeGroup.id}`,
url: `/group/delete/${this.activeGroup.id}`,
method: 'delete'
}).then(() => {
this.$store.commit("removeGroup", this.activeGroup.id);
@ -182,7 +182,7 @@
type: 'warning'
}).then(() => {
this.$http({
url: `/api/group/kick/${this.activeGroup.id}`,
url: `/group/kick/${this.activeGroup.id}`,
method: 'delete',
params: {
userId: member.userId
@ -201,7 +201,7 @@
type: 'warning'
}).then(() => {
this.$http({
url: `/api/group/quit/${this.activeGroup.id}`,
url: `/group/quit/${this.activeGroup.id}`,
method: 'delete'
}).then(() => {
this.$store.commit("removeGroup", this.activeGroup.id);
@ -224,7 +224,7 @@
},
loadGroupMembers() {
this.$http({
url: `/api/group/members/${this.activeGroup.id}`,
url: `/group/members/${this.activeGroup.id}`,
method: "get"
}).then((members) => {
this.groupMembers = members;
@ -241,6 +241,9 @@
},
isOwner() {
return this.activeGroup.ownerId == this.$store.state.userStore.userInfo.id;
},
imageAction(){
return `${process.env.VUE_APP_BASE_API}/image/upload`;
}
},
mounted() {

14
im-ui/src/view/Home.vue

@ -68,7 +68,7 @@
init(userInfo) {
this.$store.commit("setUserInfo", userInfo);
this.$store.commit("initStore");
this.$wsApi.createWebSocket("ws://localhost:8878/im", this.$store);
this.$wsApi.createWebSocket(process.env.VUE_APP_WS_URL, this.$store);
this.$wsApi.onopen(() => {
this.pullUnreadMessage();
});
@ -92,12 +92,12 @@
pullUnreadMessage() {
//
this.$http({
url: "/api/message/private/pullUnreadMessage",
url: "/message/private/pullUnreadMessage",
method: 'post'
});
//
this.$http({
url: "/api/message/group/pullUnreadMessage",
url: "/message/group/pullUnreadMessage",
method: 'post'
});
},
@ -110,7 +110,7 @@
}
//
this.$http({
url: `/api/friend/find/${msg.sendId}`,
url: `/friend/find/${msg.sendId}`,
method: 'get'
}).then((friend) => {
this.insertPrivateMessage(friend, msg);
@ -138,7 +138,7 @@
}
//
this.$http({
url: `/api/group/find/${msg.groupId}`,
url: `/group/find/${msg.groupId}`,
method: 'get'
}).then((group) => {
this.insertGroupMessage(group, msg);
@ -159,7 +159,7 @@
},
handleExit() {
this.$http({
url: "/api/logout",
url: "/logout",
method: 'get'
}).then(() => {
this.$wsApi.closeWebSocket();
@ -180,7 +180,7 @@
},
mounted() {
this.$http({
url: "/api/user/self",
url: "/user/self",
methods: 'get'
}).then((userInfo) => {
this.init(userInfo);

2
im-ui/src/view/Login.vue

@ -63,7 +63,7 @@
this.$refs[formName].validate((valid) => {
if (valid) {
this.$http({
url: "/api/login",
url: "/login",
method: 'post',
params: this.loginForm
})

2
im-ui/src/view/Register.vue

@ -95,7 +95,7 @@
this.$refs[formName].validate((valid) => {
if (valid) {
this.$http({
url: "/api/register",
url: "/register",
method: 'post',
data: this.registerForm
})

24
pom.xml

@ -15,28 +15,10 @@
<module>commom</module>
</modules>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
<!--FastJson-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>

Loading…
Cancel
Save