Browse Source

修复h5键盘显示的bug

master
xsx 1 year ago
parent
commit
1ef8c26b92
  1. 2
      im-server/src/main/java/com/bx/imserver/netty/processor/LoginProcessor.java
  2. 3
      im-uniapp/main.js
  3. 3
      im-uniapp/package.json
  4. 25
      im-uniapp/pages/chat/chat-box.vue

2
im-server/src/main/java/com/bx/imserver/netty/processor/LoginProcessor.java

@ -34,7 +34,7 @@ public class LoginProcessor extends AbstractMessageProcessor<IMLoginInfo> {
private String accessTokenSecret;
@Override
public synchronized void process(ChannelHandlerContext ctx, IMLoginInfo loginInfo) {
public void process(ChannelHandlerContext ctx, IMLoginInfo loginInfo) {
if (!JwtUtil.checkSign(loginInfo.getAccessToken(), accessTokenSecret)) {
ctx.channel().close();
log.warn("用户token校验不通过,强制下线,token:{}", loginInfo.getAccessToken());

3
im-uniapp/main.js

@ -14,6 +14,9 @@ import useGroupStore from '@/store/groupStore.js'
import useConfigStore from '@/store/configStore.js'
import useUserStore from '@/store/userStore.js'
//import VConsole from 'vconsole'
//new VConsole();
// #ifdef H5
import * as recorder from './common/recorder-h5';
// #endif

3
im-uniapp/package.json

@ -5,6 +5,7 @@
},
"dependencies": {
"js-audio-recorder": "^1.0.7",
"pinyin-pro": "^3.23.1"
"pinyin-pro": "^3.23.1",
"vconsole": "^3.15.1"
}
}

25
im-uniapp/pages/chat/chat-box.vue

@ -45,7 +45,7 @@
@touchend.prevent="sendTextMessage()" size="mini">发送</button>
</view>
<view class="chat-tab-bar" v-show="chatTabBox!='none' ||showKeyBoard " :style="{height:`${keyboardHeight}px`}">
<view class="chat-tab-bar" v-show="chatTabBox!='none' || (showKeyBoard && !isH5) " :style="{height:`${keyboardHeight}px`}">
<view v-if="chatTabBox == 'tools'" class="chat-tools">
<view class="chat-tools-item">
<image-upload :maxCount="9" sourceType="album" :onBefore="onUploadImageBefore"
@ -136,7 +136,8 @@
needScrollToBottom: false, //
showMinIdx: 0, // showMinIdx
reqQueue: [], //
isSending: false //
isSending: false, //
isH5: false // h5
}
},
methods: {
@ -645,6 +646,22 @@
})
}
},
listenKeyBoardForH5() {
// H5TextArea@keyboardheightchange
//
let initHeight = window.innerHeight;
window.addEventListener('resize', () => {
let keyboardHeight = initHeight - window.innerHeight;
if (keyboardHeight > 0) {
this.keyboardHeight = this.rpxTopx(keyboardHeight);
this.showKeyBoard = true;
this.switchChatTabBox('none', false)
this.scrollToBottom();
} else {
this.showKeyBoard = false;
}
});
},
generateId() {
// id
return String(new Date().getTime()) + String(Math.floor(Math.random() * 1000));
@ -721,6 +738,10 @@
}
},
onLoad(options) {
// #ifdef H5
this.isH5 = true;
this.listenKeyBoardForH5();
// #endif
//
this.chat = this.chatStore.chats[options.chatIdx];
// 20

Loading…
Cancel
Save