yangjie #22
20
main.js
20
main.js
|
|
@ -52,26 +52,6 @@ class AppWindow extends BrowserWindow {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showWindow() {
|
|
||||||
// 如果主窗口已经存在但被最小化了,则恢复显示
|
|
||||||
if (mainWindow && mainWindow.isMinimized()) {
|
|
||||||
mainWindow.show();
|
|
||||||
console.log(3);
|
|
||||||
}
|
|
||||||
// 如果主窗口已存在但不是焦点窗口,则将其置为焦点
|
|
||||||
if (mainWindow && !mainWindow.isFocused()) {
|
|
||||||
console.log(2);
|
|
||||||
mainWindow.show();
|
|
||||||
mainWindow.focus();
|
|
||||||
}
|
|
||||||
// 如果主窗口还没有被创建,则创建它
|
|
||||||
if (!mainWindow) {
|
|
||||||
console.log(1);
|
|
||||||
createWindow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function quit() {
|
function quit() {
|
||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import { agora } from '@/utils/package/agora'
|
||||||
import { onInvoke, onSignalr, offSignalr } from '@/utils/package/signalr';
|
import { onInvoke, onSignalr, offSignalr } from '@/utils/package/signalr';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import durationPlugin from 'dayjs/plugin/duration';
|
import durationPlugin from 'dayjs/plugin/duration';
|
||||||
import { AudioVolumeInfo, ConnectionChangedReasonType, ConnectionStateType, QualityType, RtcConnection, RtcStats, UserOfflineReasonType, VideoSourceType, VideoStreamType } from 'agora-electron-sdk';
|
import { AudioVolumeInfo, ConnectionChangedReasonType, ConnectionStateType, LocalVideoStreamReason, LocalVideoStreamState, QualityType, RtcConnection, RtcStats, UserOfflineReasonType, VideoSourceType, VideoStreamType } from 'agora-electron-sdk';
|
||||||
import Avatar from '@/components/Avatar';
|
import Avatar from '@/components/Avatar';
|
||||||
import SharedFilesModel from '@/components/SharedFilesModel';
|
import SharedFilesModel from '@/components/SharedFilesModel';
|
||||||
import StupWizard from '@/components/StupWizard';
|
import StupWizard from '@/components/StupWizard';
|
||||||
|
|
@ -190,7 +190,6 @@ const Meeting: React.FC = () => {
|
||||||
const channel = new BroadcastChannel('meeting_channel');
|
const channel = new BroadcastChannel('meeting_channel');
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let time: NodeJS.Timeout;
|
let time: NodeJS.Timeout;
|
||||||
let getDesktopCapturerVideoTime: NodeJS.Timeout;
|
|
||||||
setUser(userInfo)
|
setUser(userInfo)
|
||||||
window.electron.getIsMaximized().then((res: boolean) => {
|
window.electron.getIsMaximized().then((res: boolean) => {
|
||||||
if (!res) {
|
if (!res) {
|
||||||
|
|
@ -227,7 +226,7 @@ const Meeting: React.FC = () => {
|
||||||
} = event.data;
|
} = event.data;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'shareScreenWindowGetTime':
|
case 'shareScreenWindowGetTime':
|
||||||
setCurrentSeconds((res=>{
|
setCurrentSeconds((res => {
|
||||||
channel.postMessage({
|
channel.postMessage({
|
||||||
type: 'time',
|
type: 'time',
|
||||||
time: res,
|
time: res,
|
||||||
|
|
@ -395,28 +394,10 @@ const Meeting: React.FC = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, 10000);
|
}, 10000);
|
||||||
getDesktopCapturerVideoTime = setInterval(() => {
|
|
||||||
setSharedScreenItem((i: any) => {
|
|
||||||
if (i && i.type === 0) {
|
|
||||||
agora.getDesktopCapturerVideo({ width: 0, height: 0 }, { width: 0, height: 0 }, false).then(res => {
|
|
||||||
if (res.length) {
|
|
||||||
let row = res.find((item: any) => item.sourceId === i.sourceId)
|
|
||||||
if (!row) {
|
|
||||||
stopScreenCapture()
|
|
||||||
setSharedScreenItem('')
|
|
||||||
allUserLook(userInfo.uid, userInfo.userName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return i
|
|
||||||
})
|
|
||||||
}, 3000)
|
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener('customStorageChange', handleCustomStorageChange);
|
window.removeEventListener('customStorageChange', handleCustomStorageChange);
|
||||||
window.removeEventListener('wheel', handleWheelChange);
|
window.removeEventListener('wheel', handleWheelChange);
|
||||||
clearInterval(time)
|
clearInterval(time)
|
||||||
clearInterval(getDesktopCapturerVideoTime)
|
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
@ -1023,6 +1004,13 @@ const Meeting: React.FC = () => {
|
||||||
message.error('网络断开,请检查网络')
|
message.error('网络断开,请检查网络')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onLocalVideoStateChanged: async (source: VideoSourceType, _state: LocalVideoStreamState, reason: LocalVideoStreamReason) => {
|
||||||
|
if (source === 2 && reason === 12) {
|
||||||
|
stopScreenCapture()
|
||||||
|
setSharedScreenItem('')
|
||||||
|
allUserLook(userInfo.uid, userInfo.userName)
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (state.enableCamera) {
|
if (state.enableCamera) {
|
||||||
await agora.startCameraCapture()
|
await agora.startCameraCapture()
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@ import {
|
||||||
AudioVolumeInfo,
|
AudioVolumeInfo,
|
||||||
UserOfflineReasonType,
|
UserOfflineReasonType,
|
||||||
ConnectionStateType,
|
ConnectionStateType,
|
||||||
ConnectionChangedReasonType
|
ConnectionChangedReasonType,
|
||||||
|
LocalVideoStreamReason,
|
||||||
|
LocalVideoStreamState
|
||||||
} from "agora-electron-sdk";
|
} from "agora-electron-sdk";
|
||||||
import { GetRoomRtcToken, GetAgoraConf } from "@/api/Home/Index";
|
import { GetRoomRtcToken, GetAgoraConf } from "@/api/Home/Index";
|
||||||
import { storage } from '@/utils';
|
import { storage } from '@/utils';
|
||||||
|
|
@ -111,7 +113,7 @@ export const agora = {
|
||||||
}, 1000);
|
}, 1000);
|
||||||
},
|
},
|
||||||
// 事件回调
|
// 事件回调
|
||||||
registerEventHandler: ({ onJoinChannelSuccess, onUserJoined, onUserOffline, onAudioVolumeIndication, onNetworkQuality, onRtcStats, onConnectionStateChanged }: any) => {
|
registerEventHandler: ({ onJoinChannelSuccess, onUserJoined, onUserOffline, onAudioVolumeIndication, onNetworkQuality, onRtcStats, onConnectionStateChanged, onLocalVideoStateChanged }: any) => {
|
||||||
rtcEngine.registerEventHandler({
|
rtcEngine.registerEventHandler({
|
||||||
// 监听本地用户加入频道事件
|
// 监听本地用户加入频道事件
|
||||||
onJoinChannelSuccess: async (connection: RtcConnection, elapsed: number) => {
|
onJoinChannelSuccess: async (connection: RtcConnection, elapsed: number) => {
|
||||||
|
|
@ -153,6 +155,10 @@ export const agora = {
|
||||||
onConnectionStateChanged: async (connection: RtcConnection, state: ConnectionStateType, reason: ConnectionChangedReasonType) => {
|
onConnectionStateChanged: async (connection: RtcConnection, state: ConnectionStateType, reason: ConnectionChangedReasonType) => {
|
||||||
await onConnectionStateChanged?.(connection, state, reason)
|
await onConnectionStateChanged?.(connection, state, reason)
|
||||||
},
|
},
|
||||||
|
// 本地视频状态发生改变回调。
|
||||||
|
onLocalVideoStateChanged: async (source: VideoSourceType, state: LocalVideoStreamState, reason: LocalVideoStreamReason) => {
|
||||||
|
await onLocalVideoStateChanged?.(source, state, reason)
|
||||||
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 获取视图模式
|
// 获取视图模式
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,9 @@ export default defineConfig({
|
||||||
AudioVolumeInfo,
|
AudioVolumeInfo,
|
||||||
UserOfflineReasonType,
|
UserOfflineReasonType,
|
||||||
ConnectionStateType,
|
ConnectionStateType,
|
||||||
ConnectionChangedReasonType
|
ConnectionChangedReasonType,
|
||||||
|
LocalVideoStreamState,
|
||||||
|
LocalVideoStreamReason
|
||||||
} = require("agora-electron-sdk")
|
} = require("agora-electron-sdk")
|
||||||
export {
|
export {
|
||||||
createAgoraRtcEngine,
|
createAgoraRtcEngine,
|
||||||
|
|
@ -89,7 +91,9 @@ export default defineConfig({
|
||||||
AudioVolumeInfo,
|
AudioVolumeInfo,
|
||||||
UserOfflineReasonType,
|
UserOfflineReasonType,
|
||||||
ConnectionStateType,
|
ConnectionStateType,
|
||||||
ConnectionChangedReasonType
|
ConnectionChangedReasonType,
|
||||||
|
LocalVideoStreamState,
|
||||||
|
LocalVideoStreamReason
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue