|
@@ -95,7 +95,7 @@
|
|
|
import { onMounted, watch, defineEmits, ref, reactive, computed, nextTick } from "vue";
|
|
|
import { useApp, getApp } from "@/app";
|
|
|
import { useStore } from "vuex";
|
|
|
-import { Scrollbar, Dialog } from "@/global_components/";
|
|
|
+import { Dialog } from "@/global_components/";
|
|
|
import common from "@/utils/common";
|
|
|
|
|
|
import { mapGetters } from "vuex";
|
|
@@ -188,6 +188,7 @@ const userGetOut = (item, i) => {
|
|
|
const setUserWords = (res) => {
|
|
|
if (res.userId == user_info.value.UserId) {
|
|
|
user_info.value.IsWords = res.words;
|
|
|
+ Dialog.toast({ content: !user_info.value.IsWords? `主持人設置了禁言` : `主持人已解除禁言` });
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -200,26 +201,24 @@ const handleMuteAduio = () => {
|
|
|
};
|
|
|
|
|
|
const setUserMuted = (res) => {
|
|
|
- if(res.userId){
|
|
|
+ if (res.userId) {
|
|
|
if (res.userId == user_info.value.UserId) {
|
|
|
user_info.value.IsMuted = res.muted;
|
|
|
+ Dialog.toast({ content: !user_info.value.IsMuted? `主持人設置了开麦` : `主持人设置了静音` });
|
|
|
disableMic.value = res.muted;
|
|
|
audioMuted.value = res.muted;
|
|
|
- }
|
|
|
- }else{
|
|
|
- onAllMuted(res)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ onAllMuted(res);
|
|
|
}
|
|
|
-
|
|
|
};
|
|
|
|
|
|
const setAllMuted = (data) => {
|
|
|
- console.log(data,'IsMuted');
|
|
|
- socket.value.emit("action", { type: "users-muted", muted: data});
|
|
|
+ console.log(data, "IsMuted");
|
|
|
+ socket.value.emit("action", { type: "users-muted", muted: data });
|
|
|
};
|
|
|
|
|
|
-
|
|
|
const onAllMuted = (res) => {
|
|
|
-
|
|
|
user_list.value = res.members.reduce(function (tempArr, item) {
|
|
|
if (tempArr.findIndex((ele) => ele.UserId === item.UserId) === -1) {
|
|
|
tempArr.push(item);
|
|
@@ -233,6 +232,7 @@ const onAllMuted = (res) => {
|
|
|
|
|
|
user_list.value.forEach((item) => {
|
|
|
user_info.value.IsMuted = res.muted;
|
|
|
+ Dialog.toast({ content: !user_info.value.IsMuted? `主持人設置了开麦` : `主持人设置了静音` });
|
|
|
disableMic.value = res.muted;
|
|
|
audioMuted.value = res.muted;
|
|
|
item.IsMuted = res.muted;
|
|
@@ -372,9 +372,7 @@ const onMemberMuted = (item) => {
|
|
|
socket.value.emit("action", { type: "users-muted", muted: item.IsMuted, userId: item.UserId });
|
|
|
};
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-const onMemberLeave = (res) => {
|
|
|
+const onMemberLeave = async (res) => {
|
|
|
console.log("有人離開了", res);
|
|
|
user_list.value = res.members.reduce(function (tempArr, item) {
|
|
|
if (tempArr.findIndex((ele) => ele.UserId === item.UserId) === -1) {
|
|
@@ -382,10 +380,23 @@ const onMemberLeave = (res) => {
|
|
|
}
|
|
|
return tempArr;
|
|
|
}, []);
|
|
|
+ let name = res.user.Nickname;
|
|
|
if (res.user.Role == "leader") {
|
|
|
+ name = "主持人";
|
|
|
Dialog.toast({ content: `主持人離開了房間` });
|
|
|
- // emit("closeSocket");
|
|
|
}
|
|
|
+ let data = {
|
|
|
+ role: res.user.Role,
|
|
|
+ mode: mode.value,
|
|
|
+ Nickname: name,
|
|
|
+ UserId: res.user.UserId,
|
|
|
+ text: "离开房間",
|
|
|
+ };
|
|
|
+ chatList.value.push(data);
|
|
|
+ await nextTick();
|
|
|
+ try {
|
|
|
+ chatAutoScroll();
|
|
|
+ } catch (error) {}
|
|
|
};
|
|
|
|
|
|
const userCanSpeak = (item) => {
|
|
@@ -396,7 +407,7 @@ const userCanSpeak = (item) => {
|
|
|
const onGetOuT = (data) => {
|
|
|
if (data.id == user_info.UserId) {
|
|
|
emit("closeSocket");
|
|
|
- Dialog.toast({ content: `你已被移除` });
|
|
|
+ Dialog.toast({ content: `您已被移除` });
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -511,6 +522,10 @@ const startFollow = (app) => {
|
|
|
} else if (data.type == "user-leave") {
|
|
|
// 房間解散
|
|
|
onMemberLeave(data);
|
|
|
+ } else if (data.type == "leader-dismiss") {
|
|
|
+ emit("closeSocket");
|
|
|
+ Dialog.toast({ content: `主持人已解散房间` });
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
|