|
@@ -1,18 +1,22 @@
|
|
|
-import { UserInfoType, useRtcStore } from "/@/store/modules/rtc";
|
|
|
-import type { ChatContentType } from "/@/store/modules/rtc";
|
|
|
+import { useRtcStore } from "/@/store/modules/rtc";
|
|
|
+import type { ChatContentType, UserInfoType } from "/@/store/modules/rtc";
|
|
|
import Dialog from '/@/components/basic/dialog'
|
|
|
import { getApp, useApp } from "/@/hooks/userApp";
|
|
|
+import consola from 'consola'
|
|
|
+import { useSocket } from "/@/hooks/userSocket";
|
|
|
|
|
|
interface ActionDataType {
|
|
|
type: string;
|
|
|
data: any,
|
|
|
members?: UserInfoType[],
|
|
|
- open?: boolean
|
|
|
+ open?: boolean,
|
|
|
+ user?: UserInfoType
|
|
|
}
|
|
|
|
|
|
-export function handleActions({ data, type, members, open }: ActionDataType) {
|
|
|
+export function handleActions({ data, type, members, open, user }: ActionDataType) {
|
|
|
switch (type) {
|
|
|
case 'user-init':
|
|
|
+ handleUserInit()
|
|
|
break;
|
|
|
case 'danmumsg':
|
|
|
handleDanMumSg(data)
|
|
@@ -22,11 +26,14 @@ export function handleActions({ data, type, members, open }: ActionDataType) {
|
|
|
break;
|
|
|
|
|
|
case 'user-join':
|
|
|
- handleUserJoin(members)
|
|
|
+ handleUserJoin(members, user)
|
|
|
break;
|
|
|
case "user-leave":
|
|
|
break;
|
|
|
|
|
|
+ case "users-muted":
|
|
|
+ break
|
|
|
+
|
|
|
case "users-words":
|
|
|
break;
|
|
|
case "leader-dismiss":
|
|
@@ -49,6 +56,40 @@ export function handleActions({ data, type, members, open }: ActionDataType) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+//被动处理初始化
|
|
|
+async function handleUserInit() {
|
|
|
+ const rtcStore = useRtcStore();
|
|
|
+ if (rtcStore.role === 'leader') {
|
|
|
+ const app = await useApp();
|
|
|
+ app.Connect.follow.sync();
|
|
|
+ // setTimeout(() => {
|
|
|
+ // socket.value.emit("action", {
|
|
|
+ // type: "leader-avatar",
|
|
|
+ // data: { avatar: leaderAvatar.value },
|
|
|
+ // });
|
|
|
+ // if (tagclick.value && tagclick.value.type == "goodlist") {
|
|
|
+ // socket.value.emit("action", {
|
|
|
+ // type: "tagclick",
|
|
|
+ // data: {
|
|
|
+ // sid: tagclick.value.data.sid,
|
|
|
+ // },
|
|
|
+ // });
|
|
|
+ // if (tagImageIndex.value != null) {
|
|
|
+ // setTimeout(() => {
|
|
|
+ // socket.value.emit("action", {
|
|
|
+ // type: "tag-image-index",
|
|
|
+ // data: {
|
|
|
+ // index: tagImageIndex.value,
|
|
|
+ // },
|
|
|
+ // });
|
|
|
+ // }, 200);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }, 200);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
// 被动处理弹幕
|
|
|
function handleDanMumSg(data: ChatContentType) {
|
|
|
const rtcStore = useRtcStore();
|
|
@@ -58,14 +99,40 @@ function handleDanMumSg(data: ChatContentType) {
|
|
|
rtcStore.addToChatList(data)
|
|
|
}
|
|
|
// 其他用户进入
|
|
|
-function handleUserJoin(members?: UserInfoType[]) {
|
|
|
+function handleUserJoin(members?: UserInfoType[], user?: UserInfoType) {
|
|
|
+
|
|
|
+ consola.info({
|
|
|
+ tag: 'socket',
|
|
|
+ message: '有人进来了'
|
|
|
+ })
|
|
|
const rtcStore = useRtcStore();
|
|
|
+
|
|
|
members && rtcStore.setMemberList(members)
|
|
|
+ if (user) {
|
|
|
+ let name = user.Nickname;
|
|
|
+ if (user.Role === 'leader') {
|
|
|
+ const socket = useSocket()
|
|
|
+ name = "主持人";
|
|
|
+ Dialog.toast({ content: `主持人进入房间` });
|
|
|
+ socket.emit("action", { type: "user-init" });
|
|
|
+ }
|
|
|
+ let data: ChatContentType = {
|
|
|
+ role: user?.Role,
|
|
|
+ mode: rtcStore.mode,
|
|
|
+ Nickname: name,
|
|
|
+ UserId: user?.UserId,
|
|
|
+ text: "进入房间",
|
|
|
+ };
|
|
|
+ if (rtcStore.isLeader) {
|
|
|
+ rtcStore.addToChatList(data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 其他用户开起画笔通知
|
|
|
|
|
|
-async function handleUserPaint(open: boolean) {
|
|
|
+async function handleUserPaint(open: boolean | undefined) {
|
|
|
const app = await useApp();
|
|
|
const rtcStore = useRtcStore();
|
|
|
if (!rtcStore.isLeader) {
|