Skip to content

Commit 577f530

Browse files
committed
fix: ios wechat keyboard bug
1 parent 81f1bf5 commit 577f530

File tree

5 files changed

+44
-6
lines changed

5 files changed

+44
-6
lines changed

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
gtag('config', 'UA-112201282-1');
3333
</script>
34-
<script src="//wechatfe.github.io/vconsole/lib/vconsole.min.js?v=3.2.0"></script>
34+
<script src="https://cdn.bootcss.com/vConsole/3.2.2/vconsole.min.js"></script>
3535
<script>
3636
var debug = location.href.match(/debug=(\w+)/);
3737
if(debug && debug[1]) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
"babel-core": "^6.22.1",
4444
"babel-eslint": "^7.1.1",
4545
"babel-loader": "^6.2.10",
46-
"babel-runtime": "^6.26.0",
4746
"babel-plugin-transform-runtime": "^6.22.0",
4847
"babel-preset-env": "^1.2.1",
4948
"babel-preset-es2015": "^6.24.0",
5049
"babel-preset-stage-2": "^6.22.0",
5150
"babel-register": "^6.22.0",
51+
"babel-runtime": "^6.26.0",
5252
"chalk": "^1.1.3",
5353
"connect-history-api-fallback": "^1.3.0",
5454
"cookie-parser": "^1.4.3",

src/main.js

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import 'muse-ui/dist/muse-ui.css';
1111
import './styles/main.styl';
1212
import socket from './socket';
1313
import {queryString} from '@utils/queryString';
14+
import ios from './utils/ios';
15+
16+
// 微信 回弹 bug
17+
ios();
1418

1519
import vuePicturePreview from './components/photo-viewer';
1620
Vue.use(vuePicturePreview);

src/utils/ios.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
export default function () {
2+
const u = navigator.userAgent;
3+
const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
4+
const classList = 'input';
5+
setTimeout(() => {
6+
[].forEach.call(document.querySelectorAll(classList), function(el) {
7+
el.addEventListener("blur", function(e) {
8+
console.log(1111);
9+
if (isIOS) {
10+
blurAdjust();
11+
}
12+
});
13+
});
14+
}, 1000);
15+
16+
// 解决苹果不回弹页面 https://blog.csdn.net/m0_37520980/article/details/86305488
17+
function blurAdjust(e) {
18+
setTimeout(() => {
19+
if (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA') {
20+
return;
21+
}
22+
let result = 'pc';
23+
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { // 判断iPhone|iPad|iPod|iOS
24+
result = 'ios';
25+
} else if (/(Android)/i.test(navigator.userAgent)) { // 判断Android
26+
result = 'android';
27+
}
28+
29+
if (result === 'ios') {
30+
document.activeElement.scrollIntoViewIfNeeded(true);
31+
}
32+
}, 100);
33+
}
34+
}

src/view/Chat.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
<mu-icon-button icon="people" slot="right" @click="openSimpleDialog"/>
2020
</mu-appbar>
2121
</div>
22-
<div class="notice" v-if="noticeList.length > 0" :class="[noticeBar ? 'notice-hidden' : '']">
22+
<!-- <div class="notice" v-if="noticeList.length > 0" :class="[noticeBar ? 'notice-hidden' : '']">
2323
<div class="notice-container">
2424
<div class="notice-li" v-for="(item, key) in noticeList" :key="key">
2525
<a :href="item.href">{{key + 1}}. {{item.title}}</a>
2626
</div>
2727
</div>
28-
<!-- <div class="notice-tool-bar" @click="handleNotice">
28+
<div class="notice-tool-bar" @click="handleNotice">
2929
{{noticeBar ? '显示通知' : '关闭通知'}}
30-
</div> -->
31-
</div>
30+
</div>
31+
</div> -->
3232
<div class="chat-inner">
3333
<div class="chat-container">
3434
<div v-if="getInfos.length === 0" class="chat-no-people">暂无消息,赶紧来占个沙发~</div>

0 commit comments

Comments
 (0)