appid修改为动态设置

This commit is contained in:
yj 2024-09-13 10:42:37 +08:00
parent 90a0a5f0d0
commit 0f164b9cca
2 changed files with 16 additions and 7 deletions

View File

@ -30,3 +30,9 @@ export const GetRoomInfo = (roomNum: string) =>
method: 'get',
})
export const GetAgoraConf = () =>
request({
url: `/home/agora-conf`,
method: 'get',
})

View File

@ -10,10 +10,10 @@ import {
SimulcastStreamMode,
VideoStreamType
} from "agora-electron-sdk";
import { GetRoomRtcToken } from "@/api/Home/Index";
import { GetRoomRtcToken, GetAgoraConf } from "@/api/Home/Index";
import { storage } from '@/utils';
const option: any = {
appId: 'dcfc466a6ecb4a1f972630065dfb1e75',
appId: '',
token: '',
tokenA: '',
channelId: '',
@ -24,11 +24,14 @@ let rtcEngine: any = '';
export const agora = {
// 初始化
init: async (bool: boolean = false) => {
rtcEngine = createAgoraRtcEngine();
await rtcEngine.initialize({
appId: option.appId,
});
await agora.setDeviceManager(bool)
const { data } = await GetAgoraConf();
if (data) {
rtcEngine = createAgoraRtcEngine();
await rtcEngine.initialize({
appId: data,
});
await agora.setDeviceManager(bool)
}
},
// 获取rtcEngine
getRtcEngine: () => {