Browse Source

一些优化

master
xsx 2 years ago
parent
commit
764797bf12
  1. 1
      im-platform/src/main/resources/application-dev.yml
  2. 1
      im-server/src/main/resources/application-dev.yml
  3. 15
      im-uniapp/App.vue
  4. 7
      im-uniapp/pages/chat/chat.vue
  5. 38
      im-uniapp/pages/friend/friend.vue
  6. 3
      im-uniapp/pages/login/login.vue
  7. 6
      im-uniapp/pages/register/register.vue
  8. 2
      im-uniapp/store/friendStore.js
  9. 5
      im-web/src/view/Home.vue

1
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
im-server/src/main/resources/application-dev.yml

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

15
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

7
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 {

38
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>

3
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;

6
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;

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
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();

Loading…
Cancel
Save