App-Android(使用App+htnl5框架,解决消息推送兼容SignalR问题)
loulijun2021
2022-09-21 32383daed1b498577da8c37145e66e2a93e28b2d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
        <meta name="HandheldFriendly" content="true"/>
        <meta name="MobileOptimized" content="320"/>
        <title>Hello H5+</title>
        <script type="text/javascript" src="../js/common.js"></script>
        <script type="text/javascript">
var ws=null,wc=null;
// 扩展API加载完毕,现在可以正常调用扩展API 
function plusReady(){
    ws=plus.webview.currentWebview();
    // 用户点击后
    ws.addEventListener('maskClick', function(){
        wc.close('auto');
    },false);
}
// 判断扩展API是否准备,否则监听plusready事件
if(window.plus){
    plusReady();
}else{
    document.addEventListener('plusready', plusReady, false);
}
// 显示侧滑页面
function showSide(){
    // 防止快速点击可能导致多次创建
    if(wc){
        return;
    }
    // 开启遮罩
    ws.setStyle({mask:'rgba(0,0,0,0.5)'});
    // 创建侧滑页面
    wc = createWithoutTitle('webview_mask_side.html', {
        left: '30%',
        width: '70%',
        popGesture: 'none',
        titleNView: {
            autoBackButton: true,
            backgroundColor: '#D74B28',
            titleColor: '#CCCCCC',
            titleText: '侧滑窗口'
        }
    });
    // 侧滑页面关闭后关闭遮罩
    wc.addEventListener('close', function(){
        ws.setStyle({mask:'none'});
        wc = null;
    }, false);
    // 侧滑页面加载后显示(避免白屏)
    wc.addEventListener('loaded', function(){
        wc.show('slide-in-right', 200);
    }, false);
}
        </script>
        <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
    </head>
    <body>
        <br/>
        <div class="button" onclick="showSide()">打开侧滑窗口</div>
        <div class="des">打开侧滑窗口后,当前Webview窗口会显示遮罩层。</div>
        <div class="des">Webview的遮罩层会覆盖Webview中所有内容(包括子Webview),并且截获Webview窗口的所有触屏事件。</div>
    </body>
</html>