|
@@ -5,6 +5,7 @@ import { useApp } from '/@/hooks/userApp';
|
|
|
import consola from 'consola';
|
|
|
import { useSocket } from '/@/hooks/userSocket';
|
|
|
import { useRoom, SceneItemType } from '/@/hooks/useRoom';
|
|
|
+import { useI18n } from '/@/hooks/useI18n';
|
|
|
|
|
|
interface ActionDataType {
|
|
|
type: string;
|
|
@@ -115,14 +116,16 @@ async function handleUserInit() {
|
|
|
|
|
|
// 被动处理弹幕
|
|
|
function handleDanMumSg(data: ChatContentType) {
|
|
|
+ const { t } = useI18n();
|
|
|
const rtcStore = useRtcStore();
|
|
|
if (data.role == 'leader') {
|
|
|
- data.Nickname = '主持人';
|
|
|
+ data.Nickname = t('action.hoster');
|
|
|
}
|
|
|
rtcStore.addToChatList(data);
|
|
|
}
|
|
|
// 其他用户进入
|
|
|
function handleUserJoin(members?: UserInfoType[], user?: UserInfoType) {
|
|
|
+ const { t } = useI18n();
|
|
|
consola.info({
|
|
|
tag: 'socket',
|
|
|
message: '有人进来了',
|
|
@@ -135,8 +138,8 @@ function handleUserJoin(members?: UserInfoType[], user?: UserInfoType) {
|
|
|
let name = user.Nickname;
|
|
|
if (user.Role === 'leader') {
|
|
|
const { socket } = useSocket();
|
|
|
- name = '主持人';
|
|
|
- Dialog.toast({ content: `主持人进入房间` });
|
|
|
+ name = t('action.hoster');
|
|
|
+ Dialog.toast({ content: t('action.hosterEnterRoom') });
|
|
|
socket.emit('action', { type: 'user-init' });
|
|
|
}
|
|
|
const data: ChatContentType = {
|
|
@@ -144,7 +147,7 @@ function handleUserJoin(members?: UserInfoType[], user?: UserInfoType) {
|
|
|
mode: rtcStore.mode,
|
|
|
Nickname: name,
|
|
|
UserId: user?.UserId,
|
|
|
- text: '进入房间',
|
|
|
+ text: t('action.enterRoom'),
|
|
|
};
|
|
|
if (rtcStore.isLeader) {
|
|
|
rtcStore.addToChatList(data);
|
|
@@ -155,6 +158,7 @@ function handleUserJoin(members?: UserInfoType[], user?: UserInfoType) {
|
|
|
// 其他用户开起画笔通知
|
|
|
|
|
|
async function handleUserPaint(open: boolean | undefined) {
|
|
|
+ const { t } = useI18n();
|
|
|
const app = await useApp();
|
|
|
const rtcStore = useRtcStore();
|
|
|
if (!rtcStore.isLeader) {
|
|
@@ -164,9 +168,9 @@ async function handleUserPaint(open: boolean | undefined) {
|
|
|
role: rtcStore.role,
|
|
|
paint: false,
|
|
|
});
|
|
|
- Dialog.toast({ content: `主持人开启画笔` });
|
|
|
+ Dialog.toast({ content: t('action.hosterOpenDraw') });
|
|
|
} else {
|
|
|
- Dialog.toast({ content: `主持人关闭画笔` });
|
|
|
+ Dialog.toast({ content: t('action.hosterCloseDraw') });
|
|
|
app.Connect.paint.hide();
|
|
|
}
|
|
|
}
|
|
@@ -174,7 +178,8 @@ async function handleUserPaint(open: boolean | undefined) {
|
|
|
|
|
|
const handleChangeScene = (data: SceneItemType) => {
|
|
|
const { changeScene } = useRoom();
|
|
|
- changeScene(data);
|
|
|
+ console.log('handleChangeScene', data);
|
|
|
+ data && changeScene(data);
|
|
|
};
|
|
|
//
|
|
|
const handleAskCurrentscene = (data) => {
|
|
@@ -187,6 +192,7 @@ const handleTagImageIndex = (data) => {
|
|
|
|
|
|
const handleUserSetWords = (UserId?: string, words?: boolean, members?: UserInfoType[]) => {
|
|
|
console.log('members', members);
|
|
|
+ const { t } = useI18n();
|
|
|
const rtcStore = useRtcStore();
|
|
|
console.log('handleUserSetWords', UserId, words);
|
|
|
UserId &&
|
|
@@ -195,7 +201,7 @@ const handleUserSetWords = (UserId?: string, words?: boolean, members?: UserInfo
|
|
|
});
|
|
|
if (UserId == rtcStore.userId) {
|
|
|
Dialog.toast({
|
|
|
- content: !words ? `主持人设置了禁言` : `主持人已解除禁言`,
|
|
|
+ content: !words ? t('action.hostBanInput') : t('action.hostAllowInput'),
|
|
|
});
|
|
|
}
|
|
|
};
|
|
@@ -214,13 +220,14 @@ const handleUserMuted = (UserId?: string, muted?: boolean, members?: UserInfoTyp
|
|
|
|
|
|
//被动处理用离开
|
|
|
const handleUserLeave = (user?: UserInfoType, members?: UserInfoType[]) => {
|
|
|
+ const { t } = useI18n();
|
|
|
console.log('有人离开了', user?.UserId);
|
|
|
const rtcStore = useRtcStore();
|
|
|
if (user) {
|
|
|
let name = user.Nickname;
|
|
|
if (user.Role == 'leader') {
|
|
|
- name = '主持人';
|
|
|
- Dialog.toast({ content: `主持人离开了房间` });
|
|
|
+ name = t('action.hoster');
|
|
|
+ Dialog.toast({ content: t('action.hostExitRoom') });
|
|
|
}
|
|
|
|
|
|
const data = {
|
|
@@ -228,7 +235,7 @@ const handleUserLeave = (user?: UserInfoType, members?: UserInfoType[]) => {
|
|
|
mode: '',
|
|
|
Nickname: name,
|
|
|
UserId: user.UserId,
|
|
|
- text: '离开房间',
|
|
|
+ text: t('action.exitRoom'),
|
|
|
};
|
|
|
|
|
|
console.log('members', user, members);
|
|
@@ -239,7 +246,8 @@ const handleUserLeave = (user?: UserInfoType, members?: UserInfoType[]) => {
|
|
|
//被动处理用离开 全员解散
|
|
|
const handleLeaderDismiss = () => {
|
|
|
const { closeSocket } = useSocket();
|
|
|
- Dialog.toast({ content: `主持人已解散房间` });
|
|
|
+ const { t } = useI18n();
|
|
|
+ Dialog.toast({ content: t('action.hosterDismissRoom') });
|
|
|
closeSocket();
|
|
|
};
|
|
|
|
|
@@ -247,12 +255,13 @@ const handleLeaderDismiss = () => {
|
|
|
|
|
|
const handleError = () => {
|
|
|
const rtcStore = useRtcStore();
|
|
|
+ const { t } = useI18n();
|
|
|
rtcStore.showBaseDialog(
|
|
|
{
|
|
|
- title: '温馨提示',
|
|
|
- desc: '带看已结束',
|
|
|
- okTxt: '确定',
|
|
|
- closeTxt: '取消',
|
|
|
+ title: t('base.tips'),
|
|
|
+ desc: t('action.endUpRoom'),
|
|
|
+ okTxt: t('base.confirm'),
|
|
|
+ closeTxt: t('base.cancel'),
|
|
|
isSingle: true,
|
|
|
},
|
|
|
() => {
|
|
@@ -260,4 +269,4 @@ const handleError = () => {
|
|
|
closeSocket();
|
|
|
},
|
|
|
);
|
|
|
-}
|
|
|
+};
|