@@ -21,7 +21,7 @@ let useLocalNetworkRoomShare = (window.localStorage.getItem("tl-rtc-file-use-loc
21
21
// 是否开启消息红点
22
22
let useMessageDot = ( window . localStorage . getItem ( "tl-rtc-file-use-message-dot" ) || "true" ) === 'true' ;
23
23
// 是否开启浏览器系统消息通知
24
- let useWebMsgNotify = ( window . localStorage . getItem ( "tl-rtc-file-use-web-msg-notify" ) || "true " ) === 'true' ;
24
+ let useWebMsgNotify = ( window . localStorage . getItem ( "tl-rtc-file-use-web-msg-notify" ) || "" ) === 'true' ;
25
25
26
26
axios . get ( "/api/comm/initData?turn=" + useTurn , { } ) . then ( async ( initData ) => {
27
27
let { data : {
@@ -1136,6 +1136,36 @@ axios.get("/api/comm/initData?turn="+useTurn, {}).then(async (initData) => {
1136
1136
return
1137
1137
}
1138
1138
1139
+ //如果开启了系统弹窗 && 当前页面没有焦点
1140
+ if ( this . webMsgNotify && ! document . hasFocus ( ) ) {
1141
+ //修改标签页title
1142
+ let title = document . title ;
1143
+ let msg = data . title + " " + data . message ;
1144
+ let time = 0 ;
1145
+ let timer = null ;
1146
+ timer = setInterval ( ( ) => {
1147
+ time ++ ;
1148
+ if ( time % 2 === 0 ) {
1149
+ document . title = msg ;
1150
+ } else {
1151
+ document . title = title ;
1152
+ }
1153
+ if ( time > 10 ) {
1154
+ clearInterval ( timer ) ;
1155
+ document . title = title ;
1156
+ }
1157
+ } , 500 ) ;
1158
+
1159
+ //浏览器系统桌面消息通知
1160
+ if ( window . Notification && Notification . permission === 'granted' ) {
1161
+ new Notification ( "tl-rtc-file通知" + data . title , {
1162
+ body : data . message ,
1163
+ dir : 'auto' ,
1164
+ icon : '../image/44826979.png'
1165
+ } )
1166
+ }
1167
+ }
1168
+
1139
1169
let levelTime = 1800 ;
1140
1170
for ( let len in lengthLevel ) {
1141
1171
if ( len > this . popUpList . length ) {
@@ -4669,6 +4699,17 @@ axios.get("/api/comm/initData?turn="+useTurn, {}).then(async (initData) => {
4669
4699
this . useWebMsgNotify = ! this . useWebMsgNotify ;
4670
4700
4671
4701
if ( this . useWebMsgNotify ) {
4702
+ // 开启通知开关的时候,如果没有通知权限,请求浏览器通知权限
4703
+ if ( window . Notification ) {
4704
+ if ( Notification . permission !== "granted" ) {
4705
+ Notification . requestPermission ( function ( status ) {
4706
+ if ( Notification . permission !== status ) {
4707
+ Notification . permission = status ;
4708
+ }
4709
+ } ) ;
4710
+ }
4711
+ }
4712
+
4672
4713
window . localStorage . setItem ( "tl-rtc-file-use-web-message-notify" , true )
4673
4714
$ ( "#webMsgNotifyOpen" ) . css ( "display" , "inline" ) ;
4674
4715
$ ( "#webMsgNotifyClose" ) . css ( "display" , "none" ) ;
0 commit comments