UNPKG

@tencentcloud/roomkit-web-vue3

Version:

<h1 align="center"> TUIRoomKit</h1> Conference (TUIRoomKit) is a product suitable for multi-person audio and video conversation scenarios such as business meetings, webinars, and online education. By integrating this product, you can add room management,

207 lines (206 loc) 5.64 kB
import { defineStore } from "pinia"; import { getLanguage } from "../utils/common.mjs"; import { LAYOUT } from "../constants/render.mjs"; import { isUndefined } from "../utils/utils.mjs"; import { isMobile, isElectron, isWeChat } from "../utils/environment.mjs"; function getDefaultLayout() { if (isMobile) { return isWeChat ? LAYOUT.SIX_EQUAL_POINTS : LAYOUT.LARGE_SMALL_WINDOW; } return LAYOUT.NINE_EQUAL_POINTS; } const useBasicStore = defineStore("basic", { state: () => ({ sdkAppId: 0, userId: "", userSig: "", userName: "", avatarUrl: "", useStringRoomId: false, roomId: "", roomMode: "FreeSpeech", isSidebarOpen: false, layout: getDefaultLayout(), showSettingDialog: false, showApplyUserList: false, activeSettingTab: "audio", isLocalStreamMirror: true, isFrontCamera: true, sidebarName: "", masterUserId: "", localQuality: 0, networkInfo: { userId: "", downLoss: 0, quality: 0, upLoss: 0, delay: 0 }, lang: getLanguage(), defaultTheme: "dark", isSupportSwitchTheme: true, showHeaderTool: true, shareLink: "", isRoomLinkVisible: !isElectron && !isWeChat, isSchemeLinkVisible: !isMobile, isShowScreenShareAntiFraud: false, isCheckMessageLimitLink: false, isExperiencedAI: false, componentConfig: { SwitchTheme: { visible: true }, InviteControl: { visible: true }, RoomLink: { visible: true } }, scene: "default", showRoomTool: true }), getters: {}, actions: { setSdkAppId(sdkAppId) { this.sdkAppId = sdkAppId; }, setUserId(userId) { this.userId = userId; }, setUserSig(userSig) { this.userSig = userSig; }, setUserName(userName) { this.userName = userName; }, setAvatarUrl(avatarUrl) { this.avatarUrl = avatarUrl; }, setRoomId(roomId) { this.roomId = roomId; this.useStringRoomId = typeof roomId === "string"; }, setSidebarOpenStatus(isOpen) { this.isSidebarOpen = isOpen; }, setSidebarName(name) { this.sidebarName = name; }, setLayout(layout) { this.layout = layout; }, setShowSettingDialog(show) { this.showSettingDialog = show; }, setShowApplyUserList(show) { this.showApplyUserList = show; }, setActiveSettingTab(tabName) { this.activeSettingTab = tabName; }, setIsLocalStreamMirror(mirror) { this.isLocalStreamMirror = mirror; }, setIsFrontCamera(isFront) { this.isFrontCamera = isFront; }, setDefaultTheme(defaultTheme) { this.defaultTheme = defaultTheme; }, setIsSupportSwitchTheme(isSupportSwitchTheme) { this.isSupportSwitchTheme = isSupportSwitchTheme; }, setShowHeaderTool(showHeaderTool) { this.showHeaderTool = showHeaderTool; }, setShareLink(shareLink) { this.shareLink = shareLink; }, setIsRoomLinkVisible(isRoomLinkVisible) { this.isRoomLinkVisible = isRoomLinkVisible; }, setIsSchemeLinkVisible(isSchemeLinkVisible) { this.isSchemeLinkVisible = isSchemeLinkVisible; }, setIsShowScreenShareAntiFraud(isShowScreenShareAntiFraud) { this.isShowScreenShareAntiFraud = isShowScreenShareAntiFraud; }, setIsExperiencedAI(isExperiencedAI) { this.isExperiencedAI = isExperiencedAI; }, setIsCheckMessageLimitLink(isCheckMessageLimitLink) { this.isCheckMessageLimitLink = isCheckMessageLimitLink; }, setBasicInfo(infoObj) { if (!infoObj) { return; } const { sdkAppId, userId, userSig, userName, avatarUrl, roomId, theme, showHeaderTool } = infoObj; sdkAppId && this.setSdkAppId(sdkAppId); userId && this.setUserId(userId); userSig && this.setUserSig(userSig); userName && this.setUserName(userName); avatarUrl && this.setAvatarUrl(avatarUrl); roomId && this.setRoomId(roomId); theme && !isUndefined(theme.defaultTheme) && this.setDefaultTheme(theme.defaultTheme); theme && !isUndefined(theme.isSupportSwitchTheme) && this.setIsSupportSwitchTheme(theme.isSupportSwitchTheme); !isUndefined(showHeaderTool) && this.setShowHeaderTool(showHeaderTool); }, setMasterUserId(userId) { this.masterUserId = userId; }, setLocalQuality(userNetworkList) { const localUser = userNetworkList.find( (item) => item.userId === this.userId ); this.localQuality = localUser.quality; }, setNetworkInfo(networkInfo) { if (networkInfo.userId === this.userId) { this.networkInfo = networkInfo; } }, setLang(lang) { this.lang = lang; }, setScene(scene) { this.scene = scene; }, setShowRoomTool(isShow) { this.showRoomTool = isShow; }, reset() { this.isSidebarOpen = false; this.layout = getDefaultLayout(); this.showSettingDialog = false; this.activeSettingTab = "audio"; this.isLocalStreamMirror = true; this.sidebarName = ""; this.masterUserId = ""; this.localQuality = 0; this.roomId = ""; this.useStringRoomId = false; this.roomMode = "FreeSpeech"; this.showApplyUserList = false; this.isFrontCamera = true; this.showHeaderTool = true; this.shareLink = ""; this.showRoomTool = false; this.isExperiencedAI = false; this.isCheckMessageLimitLink = false; } } }); export { useBasicStore };