Skip to content

Commit

Permalink
feat: web message notify
Browse files Browse the repository at this point in the history
fix: values name err
  • Loading branch information
iamtsm committed Mar 26, 2024
1 parent f86e2ad commit 77727c0
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 20 deletions.
2 changes: 1 addition & 1 deletion svr/conf/cfg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "10.5.1",
"version": "10.5.2",
"socket": {
"port": "请到 tlrtcfile.env 中进行配置",
"host": "请到 tlrtcfile.env 中进行配置"
Expand Down
8 changes: 4 additions & 4 deletions svr/web-res/js/audioShare.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var audioShare = new Vue({
return {
stream: null,
times: 0,
interverlId: 0,
intervalId: 0,
track: null,
}
},
Expand All @@ -29,7 +29,7 @@ var audioShare = new Vue({
if(window.navigator.mediaDevices && window.navigator.mediaDevices.getUserMedia){
media = window.navigator.mediaDevices.getUserMedia(defaultConstraints);
} else if (window.navigator.mozGetUserMedia) {
media = navagator.mozGetUserMedia(defaultConstraints);
media = navigator.mozGetUserMedia(defaultConstraints);
} else if (window.navigator.getUserMedia) {
media = window.navigator.getUserMedia(defaultConstraints)
} else if (window.navigator.webkitGetUserMedia) {
Expand Down Expand Up @@ -87,7 +87,7 @@ var audioShare = new Vue({
video.play();

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

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

clearInterval(this.interverlId);
clearInterval(this.intervalId);

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

Expand Down
43 changes: 42 additions & 1 deletion svr/web-res/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let useLocalNetworkRoomShare = (window.localStorage.getItem("tl-rtc-file-use-loc
// 是否开启消息红点
let useMessageDot = (window.localStorage.getItem("tl-rtc-file-use-message-dot") || "true") === 'true';
// 是否开启浏览器系统消息通知
let useWebMsgNotify = (window.localStorage.getItem("tl-rtc-file-use-web-msg-notify") || "true") === 'true';
let useWebMsgNotify = (window.localStorage.getItem("tl-rtc-file-use-web-msg-notify") || "") === 'true';

axios.get("/api/comm/initData?turn="+useTurn, {}).then(async (initData) => {
let { data : {
Expand Down Expand Up @@ -1136,6 +1136,36 @@ axios.get("/api/comm/initData?turn="+useTurn, {}).then(async (initData) => {
return
}

//如果开启了系统弹窗 && 当前页面没有焦点
if(this.webMsgNotify && !document.hasFocus()){
//修改标签页title
let title = document.title;
let msg = data.title + " " + data.message;
let time = 0;
let timer = null;
timer = setInterval(() => {
time++;
if(time % 2 === 0){
document.title = msg;
}else{
document.title = title;
}
if(time > 10){
clearInterval(timer);
document.title = title;
}
}, 500);

//浏览器系统桌面消息通知
if(window.Notification && Notification.permission === 'granted'){
new Notification("tl-rtc-file通知" + data.title, {
body: data.message,
dir: 'auto',
icon: '../image/44826979.png'
})
}
}

let levelTime = 1800;
for(let len in lengthLevel){
if(len > this.popUpList.length){
Expand Down Expand Up @@ -4669,6 +4699,17 @@ axios.get("/api/comm/initData?turn="+useTurn, {}).then(async (initData) => {
this.useWebMsgNotify = !this.useWebMsgNotify;

if (this.useWebMsgNotify) {
// 开启通知开关的时候,如果没有通知权限,请求浏览器通知权限
if (window.Notification) {
if(Notification.permission !== "granted"){
Notification.requestPermission(function (status) {
if (Notification.permission !== status) {
Notification.permission = status;
}
});
}
}

window.localStorage.setItem("tl-rtc-file-use-web-message-notify", true)
$("#webMsgNotifyOpen").css("display", "inline");
$("#webMsgNotifyClose").css("display", "none");
Expand Down
8 changes: 4 additions & 4 deletions svr/web-res/js/liveShare.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var liveShare = new Vue({
return {
stream: null,
times: 0,
interverlId: 0,
intervalId: 0,
track: null,
}
},
Expand Down Expand Up @@ -72,7 +72,7 @@ var liveShare = new Vue({
if(window.navigator.mediaDevices && window.navigator.mediaDevices.getUserMedia){
media = window.navigator.mediaDevices.getUserMedia(defaultConstraints);
} else if (window.navigator.mozGetUserMedia) {
media = navagator.mozGetUserMedia(defaultConstraints);
media = navigator.mozGetUserMedia(defaultConstraints);
} else if (window.navigator.getUserMedia) {
media = window.navigator.getUserMedia(defaultConstraints)
} else if (window.navigator.webkitGetUserMedia) {
Expand Down Expand Up @@ -140,7 +140,7 @@ var liveShare = new Vue({
}

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

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

clearInterval(this.interverlId);
clearInterval(this.intervalId);

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

Expand Down
6 changes: 3 additions & 3 deletions svr/web-res/js/screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const screen = new Vue({
mediaRecorder: null, //录制对象
recording: null, //录制文件
times: 0, //录制时间
interverlId: 0, //计时器id
intervalId: 0, //计时器id
size: 0, //录制文件大小
isScreen : false, //是否正在录制
}
Expand Down Expand Up @@ -89,7 +89,7 @@ const screen = new Vue({
this.mediaRecorder.start(10);

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

clearInterval(this.interverlId);
clearInterval(this.intervalId);

this.mediaRecorder = null;
this.chunks = [];
Expand Down
6 changes: 3 additions & 3 deletions svr/web-res/js/screenShare.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var screenShare = new Vue({
return {
stream: null,
times: 0,
interverlId: 0,
intervalId: 0,
track: null,
}
},
Expand Down Expand Up @@ -82,7 +82,7 @@ var screenShare = new Vue({
}

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

clearInterval(this.interverlId);
clearInterval(this.intervalId);

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

Expand Down
8 changes: 4 additions & 4 deletions svr/web-res/js/videoShare.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var videoShare = new Vue({
return {
stream: null,
times: 0,
interverlId: 0,
intervalId: 0,
track: null,
videoDeviceList: [], // 摄像头列表
audioDeviceList: [], // 麦克风列表
Expand Down Expand Up @@ -53,7 +53,7 @@ var videoShare = new Vue({
if(window.navigator.mediaDevices && window.navigator.mediaDevices.getUserMedia){
media = window.navigator.mediaDevices.getUserMedia(defaultConstraints);
} else if (window.navigator.mozGetUserMedia) {
media = navagator.mozGetUserMedia(defaultConstraints);
media = navigator.mozGetUserMedia(defaultConstraints);
} else if (window.navigator.getUserMedia) {
media = window.navigator.getUserMedia(defaultConstraints)
} else if (window.navigator.webkitGetUserMedia) {
Expand Down Expand Up @@ -117,7 +117,7 @@ var videoShare = new Vue({
}

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

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

clearInterval(this.interverlId);
clearInterval(this.intervalId);

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

Expand Down

0 comments on commit 77727c0

Please sign in to comment.