diff --git a/commom/pom.xml b/commom/pom.xml index 30f9a0c..6fae948 100644 --- a/commom/pom.xml +++ b/commom/pom.xml @@ -17,28 +17,33 @@ - com.baomidou - mybatis-plus-generator - 3.3.2 - - - mysql - mysql-connector-java - compile + org.projectlombok + lombok + ${lombok.version} cn.hutool hutool-all + - org.projectlombok - lombok - 1.18.16 + com.alibaba + fastjson org.apache.commons commons-lang3 + + com.baomidou + mybatis-plus-generator + 3.3.2 + + + mysql + mysql-connector-java + compile + org.springframework spring-beans @@ -53,9 +58,5 @@ velocity ${velocity.version} - - mysql - mysql-connector-java - \ No newline at end of file diff --git a/im-platform/pom.xml b/im-platform/pom.xml index 76a47f9..c77d10e 100644 --- a/im-platform/pom.xml +++ b/im-platform/pom.xml @@ -104,14 +104,18 @@ + ${project.artifactId} - org.apache.maven.plugins - maven-compiler-plugin - - 8 - 8 - + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + diff --git a/im-platform/src/main/java/com/lx/implatform/ImplatformApp.java b/im-platform/src/main/java/com/lx/implatform/ImplatformApp.java index ac24e13..e7c07b6 100644 --- a/im-platform/src/main/java/com/lx/implatform/ImplatformApp.java +++ b/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); } } diff --git a/im-platform/src/main/java/com/lx/implatform/config/GlobalCorsConfig.java b/im-platform/src/main/java/com/lx/implatform/config/GlobalCorsConfig.java new file mode 100644 index 0000000..c155836 --- /dev/null +++ b/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() { + FilterRegistrationBean 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; + } +} diff --git a/im-platform/src/main/java/com/lx/implatform/config/WebSecurityConfg.java b/im-platform/src/main/java/com/lx/implatform/config/WebSecurityConfg.java index cb0c14c..cc1c1a4 100644 --- a/im-platform/src/main/java/com/lx/implatform/config/WebSecurityConfg.java +++ b/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)); diff --git a/im-platform/src/main/java/com/lx/implatform/service/impl/FriendServiceImpl.java b/im-platform/src/main/java/com/lx/implatform/service/impl/FriendServiceImpl.java index 448da16..aba682d 100644 --- a/im-platform/src/main/java/com/lx/implatform/service/impl/FriendServiceImpl.java +++ b/im-platform/src/main/java/com/lx/implatform/service/impl/FriendServiceImpl.java @@ -40,7 +40,7 @@ public class FriendServiceImpl extends ServiceImpl impleme @Override public List findFriendByUserId(Long UserId) { - QueryWrapper queryWrapper = new QueryWrapper<>(); + QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.lambda().eq(Friend::getUserId,UserId); List friends = this.list(queryWrapper); return friends; diff --git a/im-platform/src/main/java/com/lx/implatform/service/impl/GroupServiceImpl.java b/im-platform/src/main/java/com/lx/implatform/service/impl/GroupServiceImpl.java index f4f1eeb..ecaa2ba 100644 --- a/im-platform/src/main/java/com/lx/implatform/service/impl/GroupServiceImpl.java +++ b/im-platform/src/main/java/com/lx/implatform/service/impl/GroupServiceImpl.java @@ -71,9 +71,12 @@ public class GroupServiceImpl extends ServiceImpl 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; } diff --git a/im-platform/src/main/java/com/lx/implatform/service/impl/SecurityUserDetailsServiceImpl.java b/im-platform/src/main/java/com/lx/implatform/service/impl/SecurityUserDetailsServiceImpl.java index 9896544..765cdc7 100644 --- a/im-platform/src/main/java/com/lx/implatform/service/impl/SecurityUserDetailsServiceImpl.java +++ b/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 authorities = new ArrayList<>(); + List authorities = new ArrayList(); // 用户可以访问的资源名称(或者说用户所拥有的权限) 注意:必须"ROLE_"开头 authorities.add(new SimpleGrantedAuthority("ROLE_XX")); diff --git a/im-platform/src/main/java/com/lx/implatform/task/PullAlreadyReadMessageTask.java b/im-platform/src/main/java/com/lx/implatform/task/PullAlreadyReadMessageTask.java index c9c1595..5009592 100644 --- a/im-platform/src/main/java/com/lx/implatform/task/PullAlreadyReadMessageTask.java +++ b/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 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); diff --git a/im-platform/src/main/resources/application.yml b/im-platform/src/main/resources/application.yml index 809dab3..a2e77f5 100644 --- a/im-platform/src/main/resources/application.yml +++ b/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 diff --git a/im-platform/src/main/resources/db/db.sql b/im-platform/src/main/resources/db/db.sql index 226b258..5c52c3a 100644 --- a/im-platform/src/main/resources/db/db.sql +++ b/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 '群消息读取位置'; \ No newline at end of file diff --git a/im-server/pom.xml b/im-server/pom.xml index 998752a..5553681 100644 --- a/im-server/pom.xml +++ b/im-server/pom.xml @@ -39,14 +39,18 @@ + ${project.artifactId} - org.apache.maven.plugins - maven-compiler-plugin - - 8 - 8 - + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + diff --git a/im-server/src/main/java/com/lx/implatform/imserver/IMServerApp.java b/im-server/src/main/java/com/lx/implatform/imserver/IMServerApp.java index b4a66de..5e1e907 100644 --- a/im-server/src/main/java/com/lx/implatform/imserver/IMServerApp.java +++ b/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); } diff --git a/im-server/src/main/java/com/lx/implatform/imserver/task/AbstractPullMessageTask.java b/im-server/src/main/java/com/lx/implatform/imserver/task/AbstractPullMessageTask.java index 603ef11..d2a9b93 100644 --- a/im-server/src/main/java/com/lx/implatform/imserver/task/AbstractPullMessageTask.java +++ b/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 redisTemplate; + @Override public void pullMessage() { // 从redis拉取未读消息 diff --git a/im-ui/src/api/httpRequest.js b/im-ui/src/api/httpRequest.js index 883162b..bd93ec1 100644 --- a/im-ui/src/api/httpRequest.js +++ b/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: { diff --git a/im-ui/src/components/chat/ChatGroup.vue b/im-ui/src/components/chat/ChatGroup.vue index 149e857..57197b3 100644 --- a/im-ui/src/components/chat/ChatGroup.vue +++ b/im-ui/src/components/chat/ChatGroup.vue @@ -21,13 +21,13 @@
-
- @@ -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`; } }, diff --git a/im-ui/src/components/chat/ChatGroupSide.vue b/im-ui/src/components/chat/ChatGroupSide.vue index 8859759..8350617 100644 --- a/im-ui/src/components/chat/ChatGroupSide.vue +++ b/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; } + } } diff --git a/im-ui/src/components/chat/ChatPrivate.vue b/im-ui/src/components/chat/ChatPrivate.vue index a2caa7e..5791c93 100644 --- a/im-ui/src/components/chat/ChatPrivate.vue +++ b/im-ui/src/components/chat/ChatPrivate.vue @@ -18,13 +18,13 @@
-
- @@ -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() { diff --git a/im-ui/src/components/common/HeadImage.vue b/im-ui/src/components/common/HeadImage.vue index bd9d16a..71e0827 100644 --- a/im-ui/src/components/common/HeadImage.vue +++ b/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); diff --git a/im-ui/src/components/common/UserInfo.vue b/im-ui/src/components/common/UserInfo.vue index f6c35a8..70bd364 100644 --- a/im-ui/src/components/common/UserInfo.vue +++ b/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 diff --git a/im-ui/src/components/friend/AddFriend.vue b/im-ui/src/components/friend/AddFriend.vue index 65ce74a..752cdb3 100644 --- a/im-ui/src/components/friend/AddFriend.vue +++ b/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 diff --git a/im-ui/src/components/group/AddGroupMember.vue b/im-ui/src/components/group/AddGroupMember.vue index 705d60c..a0d1c6c 100644 --- a/im-ui/src/components/group/AddGroupMember.vue +++ b/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(() => { diff --git a/im-ui/src/components/setting/Setting.vue b/im-ui/src/components/setting/Setting.vue index 748cf70..8441b71 100644 --- a/im-ui/src/components/setting/Setting.vue +++ b/im-ui/src/components/setting/Setting.vue @@ -3,7 +3,7 @@ { @@ -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)); } - } diff --git a/im-ui/src/store/friendStore.js b/im-ui/src/store/friendStore.js index 1937d0d..20ebeaf 100644 --- a/im-ui/src/store/friendStore.js +++ b/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) => { diff --git a/im-ui/src/store/groupStore.js b/im-ui/src/store/groupStore.js index 91baacd..36e0bdc 100644 --- a/im-ui/src/store/groupStore.js +++ b/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); diff --git a/im-ui/src/store/userStore.js b/im-ui/src/store/userStore.js index 4ad45bd..e7497b3 100644 --- a/im-ui/src/store/userStore.js +++ b/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); } } diff --git a/im-ui/src/view/Chat.vue b/im-ui/src/view/Chat.vue index 0a90070..ab31ca7 100644 --- a/im-ui/src/view/Chat.vue +++ b/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(() => { diff --git a/im-ui/src/view/Friend.vue b/im-ui/src/view/Friend.vue index 72a6105..33e9217 100644 --- a/im-ui/src/view/Friend.vue +++ b/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; diff --git a/im-ui/src/view/Group.vue b/im-ui/src/view/Group.vue index f453319..249fb4e 100644 --- a/im-ui/src/view/Group.vue +++ b/im-ui/src/view/Group.vue @@ -26,7 +26,7 @@
- @@ -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() { diff --git a/im-ui/src/view/Home.vue b/im-ui/src/view/Home.vue index 3b2b92f..f654c7d 100644 --- a/im-ui/src/view/Home.vue +++ b/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); diff --git a/im-ui/src/view/Login.vue b/im-ui/src/view/Login.vue index 3ada321..5b69360 100644 --- a/im-ui/src/view/Login.vue +++ b/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 }) diff --git a/im-ui/src/view/Register.vue b/im-ui/src/view/Register.vue index a51d805..00d942f 100644 --- a/im-ui/src/view/Register.vue +++ b/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 }) diff --git a/pom.xml b/pom.xml index 653000f..59570e9 100644 --- a/pom.xml +++ b/pom.xml @@ -15,28 +15,10 @@ commom - - - org.projectlombok - lombok - 1.18.16 - - - cn.hutool - hutool-all - - - - com.alibaba - fastjson - - - org.apache.commons - commons-lang3 - - - + 1.8 + 1.8 + 1.8 UTF-8 UTF-8 1.8