Skip to content

Commit 77727c0

Browse files
committed
feat: web message notify
fix: values name err
1 parent f86e2ad commit 77727c0

File tree

7 files changed

+61
-20
lines changed

7 files changed

+61
-20
lines changed

svr/conf/cfg.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "10.5.1",
2+
"version": "10.5.2",
33
"socket": {
44
"port": "请到 tlrtcfile.env 中进行配置",
55
"host": "请到 tlrtcfile.env 中进行配置"

svr/web-res/js/audioShare.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var audioShare = new Vue({
1010
return {
1111
stream: null,
1212
times: 0,
13-
interverlId: 0,
13+
intervalId: 0,
1414
track: null,
1515
}
1616
},
@@ -29,7 +29,7 @@ var audioShare = new Vue({
2929
if(window.navigator.mediaDevices && window.navigator.mediaDevices.getUserMedia){
3030
media = window.navigator.mediaDevices.getUserMedia(defaultConstraints);
3131
} else if (window.navigator.mozGetUserMedia) {
32-
media = navagator.mozGetUserMedia(defaultConstraints);
32+
media = navigator.mozGetUserMedia(defaultConstraints);
3333
} else if (window.navigator.getUserMedia) {
3434
media = window.navigator.getUserMedia(defaultConstraints)
3535
} else if (window.navigator.webkitGetUserMedia) {
@@ -87,7 +87,7 @@ var audioShare = new Vue({
8787
video.play();
8888

8989
//计算时间
90-
this.interverlId = setInterval(() => {
90+
this.intervalId = setInterval(() => {
9191
that.times += 1;
9292
window.Bus.$emit("changeAudioShareTimes", that.times)
9393

@@ -113,7 +113,7 @@ var audioShare = new Vue({
113113
this.stream.getTracks().forEach(track => track.stop());
114114
}
115115

116-
clearInterval(this.interverlId);
116+
clearInterval(this.intervalId);
117117

118118
window.Bus.$emit("changeAudioShareTimes", 0);
119119

svr/web-res/js/index.js

+42-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let useLocalNetworkRoomShare = (window.localStorage.getItem("tl-rtc-file-use-loc
2121
// 是否开启消息红点
2222
let useMessageDot = (window.localStorage.getItem("tl-rtc-file-use-message-dot") || "true") === 'true';
2323
// 是否开启浏览器系统消息通知
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';
2525

2626
axios.get("/api/comm/initData?turn="+useTurn, {}).then(async (initData) => {
2727
let { data : {
@@ -1136,6 +1136,36 @@ axios.get("/api/comm/initData?turn="+useTurn, {}).then(async (initData) => {
11361136
return
11371137
}
11381138

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+
11391169
let levelTime = 1800;
11401170
for(let len in lengthLevel){
11411171
if(len > this.popUpList.length){
@@ -4669,6 +4699,17 @@ axios.get("/api/comm/initData?turn="+useTurn, {}).then(async (initData) => {
46694699
this.useWebMsgNotify = !this.useWebMsgNotify;
46704700

46714701
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+
46724713
window.localStorage.setItem("tl-rtc-file-use-web-message-notify", true)
46734714
$("#webMsgNotifyOpen").css("display", "inline");
46744715
$("#webMsgNotifyClose").css("display", "none");

svr/web-res/js/liveShare.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var liveShare = new Vue({
1010
return {
1111
stream: null,
1212
times: 0,
13-
interverlId: 0,
13+
intervalId: 0,
1414
track: null,
1515
}
1616
},
@@ -72,7 +72,7 @@ var liveShare = new Vue({
7272
if(window.navigator.mediaDevices && window.navigator.mediaDevices.getUserMedia){
7373
media = window.navigator.mediaDevices.getUserMedia(defaultConstraints);
7474
} else if (window.navigator.mozGetUserMedia) {
75-
media = navagator.mozGetUserMedia(defaultConstraints);
75+
media = navigator.mozGetUserMedia(defaultConstraints);
7676
} else if (window.navigator.getUserMedia) {
7777
media = window.navigator.getUserMedia(defaultConstraints)
7878
} else if (window.navigator.webkitGetUserMedia) {
@@ -140,7 +140,7 @@ var liveShare = new Vue({
140140
}
141141

142142
//计算时间
143-
this.interverlId = setInterval(() => {
143+
this.intervalId = setInterval(() => {
144144
that.times += 1;
145145
window.Bus.$emit("changeLiveShareTimes", that.times)
146146

@@ -166,7 +166,7 @@ var liveShare = new Vue({
166166
this.stream.getTracks().forEach(track => track.stop());
167167
}
168168

169-
clearInterval(this.interverlId);
169+
clearInterval(this.intervalId);
170170

171171
window.Bus.$emit("changeLiveShareTimes", 0);
172172

svr/web-res/js/screen.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const screen = new Vue({
1313
mediaRecorder: null, //录制对象
1414
recording: null, //录制文件
1515
times: 0, //录制时间
16-
interverlId: 0, //计时器id
16+
intervalId: 0, //计时器id
1717
size: 0, //录制文件大小
1818
isScreen : false, //是否正在录制
1919
}
@@ -89,7 +89,7 @@ const screen = new Vue({
8989
this.mediaRecorder.start(10);
9090

9191
//计算时间
92-
this.interverlId = setInterval(() => {
92+
this.intervalId = setInterval(() => {
9393
that.times += 1;
9494
if(that.times < 10){
9595
$("#screenTimes").text("录制中: 0" + that.times + "秒")
@@ -121,7 +121,7 @@ const screen = new Vue({
121121
this.stream.getTracks().forEach(track => track.stop());
122122
this.recording = window.URL.createObjectURL(new Blob(this.chunks, { type: 'video/webm' }));
123123

124-
clearInterval(this.interverlId);
124+
clearInterval(this.intervalId);
125125

126126
this.mediaRecorder = null;
127127
this.chunks = [];

svr/web-res/js/screenShare.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var screenShare = new Vue({
1111
return {
1212
stream: null,
1313
times: 0,
14-
interverlId: 0,
14+
intervalId: 0,
1515
track: null,
1616
}
1717
},
@@ -82,7 +82,7 @@ var screenShare = new Vue({
8282
}
8383

8484
//计算时间
85-
this.interverlId = setInterval(() => {
85+
this.intervalId = setInterval(() => {
8686
that.times += 1;
8787
window.Bus.$emit("changeScreenShareTimes", that.times)
8888
$("#screenShareIcon").css("color","#fb0404")
@@ -107,7 +107,7 @@ var screenShare = new Vue({
107107
this.stream.getTracks().forEach(track => track.stop());
108108
}
109109

110-
clearInterval(this.interverlId);
110+
clearInterval(this.intervalId);
111111

112112
window.Bus.$emit("changeScreenShareTimes", 0)
113113

svr/web-res/js/videoShare.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var videoShare = new Vue({
1010
return {
1111
stream: null,
1212
times: 0,
13-
interverlId: 0,
13+
intervalId: 0,
1414
track: null,
1515
videoDeviceList: [], // 摄像头列表
1616
audioDeviceList: [], // 麦克风列表
@@ -53,7 +53,7 @@ var videoShare = new Vue({
5353
if(window.navigator.mediaDevices && window.navigator.mediaDevices.getUserMedia){
5454
media = window.navigator.mediaDevices.getUserMedia(defaultConstraints);
5555
} else if (window.navigator.mozGetUserMedia) {
56-
media = navagator.mozGetUserMedia(defaultConstraints);
56+
media = navigator.mozGetUserMedia(defaultConstraints);
5757
} else if (window.navigator.getUserMedia) {
5858
media = window.navigator.getUserMedia(defaultConstraints)
5959
} else if (window.navigator.webkitGetUserMedia) {
@@ -117,7 +117,7 @@ var videoShare = new Vue({
117117
}
118118

119119
//计算时间
120-
this.interverlId = setInterval(() => {
120+
this.intervalId = setInterval(() => {
121121
that.times += 1;
122122
window.Bus.$emit("changeVideoShareTimes", that.times)
123123

@@ -143,7 +143,7 @@ var videoShare = new Vue({
143143
this.stream.getTracks().forEach(track => track.stop());
144144
}
145145

146-
clearInterval(this.interverlId);
146+
clearInterval(this.intervalId);
147147

148148
window.Bus.$emit("changeVideoShareTimes", 0);
149149

0 commit comments

Comments
 (0)