我来帮您找到Rocket.Chat中video call按钮的代码位置。让我先搜索相关的代码。
Search files... 让我继续搜索更多相关的代码,特别是主要的video call按钮实现:
Ran tool Search files... 现在让我查看房间工具栏的实现,找到video call按钮是如何被渲染的:
Search files... 现在让我查看房间工具栏的hook,了解video call按钮是如何被注册的:
Search files... 基于我的搜索结果,我现在可以为您详细说明Rocket.Chat中video call按钮的代码位置和实现方式。
Rocket.Chat Video Call按钮代码位置总结
主要实现文件
1. 主要的Video Call按钮Hook:
12:15:apps/meteor/client/hooks/roomActions/useVideoCallRoomAction.tsx
export const useVideoCallRoomAction = () => {
const { t } = useTranslation();
const room = useRoom();
const user = useUser();
这个hook定义了主要的video call按钮,包括:
- 按钮ID:
start-video-call
- 标题:
Video_call
- 图标:
video
- 设置为featured(优先显示)
- 支持多种房间类型(DM、频道、群组、团队、LiveChat)
2. WebRTC Video Call按钮Hook:
12:15:apps/meteor/client/hooks/roomActions/useWebRTCVideoRoomAction.ts
export const useWebRTCVideoRoomAction = () => {
const enabled = useSetting('WebRTC_Enabled', false);
const room = useRoom();
const federated = isRoomFederated(room);
这个hook专门用于WebRTC视频通话,主要针对LiveChat房间。
3. 房间工具栏组件:
13:15:apps/meteor/client/views/room/HeaderV2/RoomToolbox/RoomToolbox.tsx
const RoomToolbox = ({ className }: RoomToolboxProps) => {
const { t } = useTranslation();
const toolbox = useRoomToolbox();
4. 房间工具栏Actions Hook:
7:10:apps/meteor/client/views/room/HeaderV2/RoomToolbox/hooks/useRoomToolboxActions.ts
export const useRoomToolboxActions = ({ actions, openTab }: Pick<RoomToolboxContextValue, 'actions' | 'openTab'>) => {
const { t } = useTranslation();
const { roomToolboxExpanded } = useLayout();
按钮注册和渲染流程
1. 按钮注册: 在 apps/meteor/client/ui.ts
中,video call相关的hooks被注册到 roomActionHooks
数组中:
67:70:apps/meteor/client/ui.ts
useWebRTCVideoRoomAction,
useAppsRoomStarActions,
useVideoCallRoomAction,
useVoiceCallRoomAction,
2. 按钮渲染:
RoomToolbox
组件使用useRoomToolboxActions
hook来获取所有可用的工具栏动作featuredActions
包含优先显示的动作(如video call按钮)visibleActions
包含在展开模式下显示的动作hiddenActions
包含在菜单中显示的动作
3. 按钮配置: Video call按钮的主要配置:
id: 'start-video-call'
title: 'Video_call'
(会通过i18n翻译)icon: 'video'
featured: true
(优先显示)order: -1
(高优先级排序)- 支持多种房间类型组
用户信息卡片中的Video Call按钮
还有一个在用户信息卡片中显示的video call按钮,实现在:
16:18:apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useVideoCallAction.tsx
export const useVideoCallAction = (user: Pick<IUser, '_id' | 'username'>): UserInfoAction | undefined => {
const t = useTranslation();
const usernameSubscription = useSubscriptionByName(user.username ?? '');
总结
要找到video call按钮的代码位置,主要关注这些文件:
apps/meteor/client/hooks/roomActions/useVideoCallRoomAction.tsx
- 主要的video call按钮逻辑apps/meteor/client/views/room/HeaderV2/RoomToolbox/RoomToolbox.tsx
- 按钮渲染组件apps/meteor/client/ui.ts
- 按钮注册配置apps/meteor/client/views/room/HeaderV2/RoomToolbox/hooks/useRoomToolboxActions.ts
- 按钮显示逻辑
这些文件共同工作,实现了Rocket.Chat中房间工具栏的video call按钮功能。
Rocket.Chat\apps\meteor\client\views\room\contextualBar\VideoConference\VideoConfPopups\VideoConfPopup\StartCallPopup.tsx 开始通话 按钮
home\Rocket.Chat\apps\meteor\client\views\room\contextualBar\VideoConference\VideoConfPopups\VideoConfPopup\TimedVideoConfPopup.tsx import StartCallPopup from './StartCallPopup';