xsx hai 1 ano
pai
achega
764797bf12

+ 1 - 0
im-platform/src/main/resources/application-dev.yml

@@ -8,6 +8,7 @@ spring:
     redis:
       host: localhost
       port: 6379
+      database: 1
 
 minio:
   endpoint: http://127.0.0.1:9001 #内网地址

+ 1 - 0
im-server/src/main/resources/application-dev.yml

@@ -3,4 +3,5 @@ spring:
     redis:
       host: 127.0.0.1
       port: 6379
+      database: 1
 

+ 10 - 5
im-uniapp/App.vue

@@ -9,12 +9,14 @@
 	export default {
 		data() {
 			return {
+				isExit: false, // 是否已退出
 				audioTip: null,
 				reconnecting: false // 正在重连标志
 			}
 		},
 		methods: {
 			init() {
+				this.isExit = false;
 				// 加载数据
 				store.dispatch("load").then(() => {
 					// 初始化websocket
@@ -62,11 +64,9 @@
 				});
 				wsApi.onClose((res) => {
 					console.log("ws断开", res);
-					// 3099是客户端正常主动关闭
-					if (res.code != 3099) {
-						// 重新连接
-						this.reconnectWs();
-					}
+					// 重新连接
+					this.reconnectWs();
+					
 				})
 			},
 			pullPrivateOfflineMessage(minId) {
@@ -281,6 +281,7 @@
 			},
 			exit() {
 				console.log("exit");
+				this.isExit = true;
 				wsApi.close(3099);
 				uni.removeStorageSync("loginInfo");
 				uni.reLaunch({
@@ -301,6 +302,10 @@
 				return loginInfo.expireTime < new Date().getTime();
 			},
 			reconnectWs() {
+				// 已退出则不再重连
+				if (this.isExit) {
+					return;
+				}
 				// 记录标志
 				this.reconnecting = true;
 				// 重新加载一次个人信息,目的是为了保证网络已经正常且token有效

+ 4 - 3
im-uniapp/pages/chat/chat.vue

@@ -1,6 +1,5 @@
 <template>
 	<view class="tab-page">
-
 		<view v-if="loading" class="chat-loading">
 			<loading :size="50" :mask="false">
 				<view>消息接收中...</view>
@@ -171,9 +170,11 @@
 		.chat-loading {
 			display: block;
 			width: 100%;
-			height: 100rpx;
+			height: 120rpx;
 			background: white;
-			position: relative;
+			position: fixed;
+			top:  0;
+			z-index: 999;
 			color: blue;
 
 			.loading-box {

+ 16 - 22
im-uniapp/pages/friend/friend.vue

@@ -2,7 +2,7 @@
 	<view class="tab-page friend">
 		<view class="nav-bar">
 			<view class="nav-search">
-				<uni-search-bar radius="100" @input="onInput" cancelButton="none" placeholder="点击搜索好友"></uni-search-bar>
+				<uni-search-bar v-model="searchText" radius="100" cancelButton="none" placeholder="点击搜索好友"></uni-search-bar>
 			</view>
 			<view class="nav-add" @click="onAddNewFriends()">
 				<uni-icons type="personadd" size="35"></uni-icons>
@@ -13,7 +13,7 @@
 		</view>
 		<view class="friend-items" v-else>
 			<up-index-list :index-list="friendIdx" >
-				<template v-for="(friends,i) in friendGroup">
+				<template v-for="(friends,i) in friendGroups">
 					<up-index-item>
 						<up-index-anchor :text="friendIdx[i]=='*'?'在线':friendIdx[i]"
 							bgColor="#f2f3fd"></up-index-anchor>
@@ -34,16 +34,10 @@
 	export default {
 		data() {
 			return {
-				searchText: '',
-				friendIdx: [],
-				friendGroup: []
+				searchText: ''
 			}
 		},
 		methods: {
-			onInput(searchText){
-				this.searchText = searchText;
-				this.refreshFriendGroup()
-			},
 			onAddNewFriends() {
 				uni.navigateTo({
 					url: "/pages/friend/friend-add"
@@ -60,8 +54,13 @@
 			},
 			isEnglish(character) {
 				return /^[A-Za-z]+$/.test(character);
+			}
+		},
+		computed: {
+			friends() {
+				return this.$store.state.friendStore.friends;
 			},
-			refreshFriendGroup() {
+			friendGroupMap(){
 				// 按首字母分组
 				let groupMap = new Map();
 				this.friends.forEach((f) => {
@@ -95,20 +94,15 @@
 					return a[0].localeCompare(b[0])
 				})
 				groupMap = new Map(arrayObj.map(i => [i[0], i[1]]));
-				this.friendIdx = Array.from(groupMap.keys())
-				this.friendGroup = Array.from(groupMap.values());
-			}
-
-		},
-		computed: {
-			friends() {
-				return this.$store.state.friendStore.friends;
+				return groupMap;
 			},
-		},
-		onShow() {
-			this.refreshFriendGroup();
+			friendIdx(){
+				return Array.from(this.friendGroupMap.keys());
+			},
+			friendGroups(){
+				return Array.from(this.friendGroupMap.values());
+			}
 		}
-
 	}
 </script>
 

+ 1 - 2
im-uniapp/pages/login/login.vue

@@ -13,7 +13,6 @@
 		<navigator class="nav-register" url="/pages/register/register">
 			没有账号,前往注册
 		</navigator>
-
 	</view>
 </template>
 
@@ -77,7 +76,7 @@
 
 		.title {
 			padding-top: 150rpx;
-			padding-bottom: 100rpx;
+			padding-bottom: 50rpx;
 			color: royalblue;
 			text-align: center;
 			font-size: 60rpx;

+ 3 - 3
im-uniapp/pages/register/register.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="register">
-		<view class="title">用户注册</view>
+		<view class="title">欢迎注册</view>
 		<uni-forms class="form" :modelValue="dataForm" :rules="rules" validate-trigger="bind" label-width="80px">
 			<uni-forms-item name="userName" label="用户名">
 				<uni-easyinput type="text" v-model="dataForm.userName" placeholder="用户名" />
@@ -76,7 +76,7 @@
 					method: 'POST'
 				}).then(() => {
 					uni.showToast({
-						title: "注册成功",
+						title: "注册成功,您已成为盒子IM的用户",
 						icon: 'none'
 					})
 					this.login();
@@ -114,7 +114,7 @@
 	.register {
 		.title {
 			padding-top: 150rpx;
-			padding-bottom: 100rpx;
+			padding-bottom: 50rpx;
 			color: royalblue;
 			text-align: center;
 			font-size: 60rpx;

+ 0 - 2
im-uniapp/store/friendStore.js

@@ -83,7 +83,6 @@ export default {
 	},
 	actions: {
 		loadFriend(context) {
-			console.log("loadFriend")
 			return new Promise((resolve, reject) => {
 				http({
 					url: '/friend/list',
@@ -92,7 +91,6 @@ export default {
 					context.commit("setFriends", friends);
 					context.commit("refreshOnlineStatus");
 					resolve()
-					console.log("loadFriend ok")
 				}).catch((res) => {
 					reject();
 				})

+ 5 - 0
im-web/src/view/Home.vue

@@ -269,6 +269,11 @@
 				location.href = "/";
 			},
 			playAudioTip() {
+				// 离线消息不播放铃声
+				if(this.$store.getters.isLoading()){
+					return;
+				}
+				// 防止过于密集播放
 				if (new Date().getTime() - this.lastPlayAudioTime > 1000) {
 					this.lastPlayAudioTime = new Date().getTime();
 					let audio = new Audio();