This commit is contained in:
parent
e285e9f22c
commit
06b624e170
13
main.js
13
main.js
|
|
@ -9,7 +9,7 @@ const {
|
|||
clipboard,
|
||||
dialog,
|
||||
webFrame,
|
||||
Notification
|
||||
Notification,
|
||||
} = require('electron');
|
||||
const path = require('node:path')
|
||||
const { autoUpdater, CancellationToken } = require('electron-updater');
|
||||
|
|
@ -192,6 +192,17 @@ app.on('ready', () => {
|
|||
quitAndInstall()
|
||||
}
|
||||
});
|
||||
// 选择文件夹
|
||||
ipcMain.handle('selectFilePath', async (event) => {
|
||||
const result = await dialog.showOpenDialog({
|
||||
properties: ['openDirectory']
|
||||
});
|
||||
if (result.canceled) {
|
||||
|
||||
} else {
|
||||
mainWindow.webContents.send('onFilePath', result.filePaths[0]);
|
||||
}
|
||||
});
|
||||
// 设置桌面应用基础属性
|
||||
ipcMain.handle('setMainWindowSize', (event, config) => {
|
||||
// 设置最小窗口尺寸
|
||||
|
|
|
|||
17
preload.js
17
preload.js
|
|
@ -1,14 +1,9 @@
|
|||
// // 在 preload 脚本中。
|
||||
const {ipcRenderer, contextBridge} = require('electron')
|
||||
|
||||
// contextBridge.exposeInMainWorld("elecAPI", {
|
||||
// onUpdate: (callback) => ipcRenderer.on("update", callback),
|
||||
// checkForUpdate: () => ipcRenderer.send("checkForUpdate"),
|
||||
// });
|
||||
const { ipcRenderer } = require('electron')
|
||||
window.electron = {
|
||||
// 设置窗口大小
|
||||
setMainWindowSize: (config) => {
|
||||
ipcRenderer.invoke('setMainWindowSize', {...config})
|
||||
ipcRenderer.invoke('setMainWindowSize', { ...config })
|
||||
},
|
||||
// 设置窗口状态
|
||||
setViewStatus: (status) => {
|
||||
|
|
@ -38,4 +33,12 @@ window.electron = {
|
|||
onDownload: (type) => {
|
||||
ipcRenderer.invoke('updateDownload', type)
|
||||
},
|
||||
// 选择文件夹
|
||||
selectFilePath: () => {
|
||||
ipcRenderer.invoke('selectFilePath')
|
||||
},
|
||||
// 发送文件夹路径
|
||||
onFilePath: (callback) => {
|
||||
ipcRenderer.on('onFilePath', callback)
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import styles from '@/components/StupWizard/index.module.scss'
|
||||
import ImageUrl from '@/utils/package/ImageUrl';
|
||||
import { Button, Checkbox, Empty, Input, Modal, Select, Slider } from 'antd';
|
||||
import { Button, Checkbox, Empty, Input, Modal, Select, Slider, message } from 'antd';
|
||||
import { useState, useImperativeHandle, forwardRef, useEffect } from "react";
|
||||
import agora from '@/utils/package/agora'
|
||||
import { CloseOutlined, LoadingOutlined } from '@ant-design/icons';
|
||||
import { storage } from '@/utils';
|
||||
const os = require('os')
|
||||
const fs = require('fs').promises;
|
||||
const { exec } = require('child_process');
|
||||
let userInfo = JSON.parse(storage.getItem('user') as string)
|
||||
const StupWizard = forwardRef((props: any, ref: any) => {
|
||||
useImperativeHandle(ref, () => ({
|
||||
|
|
@ -383,6 +385,12 @@ const RecordingComponents = () => {
|
|||
} else {
|
||||
setFilePath(setting.recordingFilesPath);
|
||||
}
|
||||
window.electron.onFilePath(async (_e: any, filePath: string) => {
|
||||
setFilePath(filePath)
|
||||
const setting = await JSON.parse(storage.getItem('setting') as string)
|
||||
setting.recordingFilesPath = filePath
|
||||
storage.setItem('setting', JSON.stringify(setting))
|
||||
})
|
||||
}, [])
|
||||
return (
|
||||
<>
|
||||
|
|
@ -403,7 +411,25 @@ const RecordingComponents = () => {
|
|||
setFilePath(e.target.value)
|
||||
}}
|
||||
/>
|
||||
<Button type="primary" onClick={() => { }} style={{ backgroundColor: '#31353A' }}>打开</Button>
|
||||
<Button type="primary" onClick={() => {
|
||||
window.electron.selectFilePath()
|
||||
}} style={{ backgroundColor: '#31353A', marginRight: '10px' }}>选择保存目录</Button>
|
||||
<Button type="primary" onClick={async () => {
|
||||
try {
|
||||
await fs.access(filePath, fs.constants.F_OK);
|
||||
if (process.platform === 'win32') {
|
||||
exec(`explorer "${filePath}"`);
|
||||
} else if (process.platform === 'darwin') {
|
||||
exec(`open "${filePath}"`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (error.code === 'ENOENT') {
|
||||
message.error('文件夹不存在!')
|
||||
} else {
|
||||
message.error(error)
|
||||
}
|
||||
}
|
||||
}} style={{ backgroundColor: '#31353A' }}>打开</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -423,6 +449,12 @@ const FileComponents = () => {
|
|||
setFilePath(setting.shareFilesPath);
|
||||
}
|
||||
setIsShareSavePath(setting.isShareSavePath)
|
||||
window.electron.onFilePath(async (_e: any, filePath: string) => {
|
||||
setFilePath(filePath)
|
||||
const setting = await JSON.parse(storage.getItem('setting') as string)
|
||||
setting.shareFilesPath = filePath
|
||||
storage.setItem('setting', JSON.stringify(setting))
|
||||
})
|
||||
}, [])
|
||||
return (
|
||||
<>
|
||||
|
|
@ -443,7 +475,25 @@ const FileComponents = () => {
|
|||
setFilePath(e.target.value)
|
||||
}}
|
||||
/>
|
||||
<Button type="primary" onClick={() => { }} style={{ backgroundColor: '#31353A' }}>选择保存目录</Button>
|
||||
<Button type="primary" onClick={() => {
|
||||
window.electron.selectFilePath()
|
||||
}} style={{ backgroundColor: '#31353A', marginRight: '10px' }}>选择保存目录</Button>
|
||||
<Button type="primary" onClick={async () => {
|
||||
try {
|
||||
await fs.access(filePath, fs.constants.F_OK);
|
||||
if (process.platform === 'win32') {
|
||||
exec(`explorer "${filePath}"`);
|
||||
} else if (process.platform === 'darwin') {
|
||||
exec(`open "${filePath}"`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (error.code === 'ENOENT') {
|
||||
message.error('文件夹不存在!')
|
||||
} else {
|
||||
message.error(error)
|
||||
}
|
||||
}
|
||||
}} style={{ backgroundColor: '#31353A' }}>打开</Button>
|
||||
</div>
|
||||
<div>
|
||||
<Checkbox onChange={async (e) => {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import { VideoSourceType } from 'agora-electron-sdk';
|
|||
import { GetUserList } from '@/api/Home/User';
|
||||
import Avatar from '@/components/Avatar';
|
||||
import SharedFilesModel from '@/components/SharedFilesModel';
|
||||
const fs = require('fs').promises;
|
||||
dayjs.extend(durationPlugin);
|
||||
const Meeting: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
|
|
@ -333,13 +334,24 @@ const Meeting: React.FC = () => {
|
|||
invitingPersonnelRef.current.changeInvitingPersonnelModal()
|
||||
break;
|
||||
case '录制':
|
||||
const setting = await JSON.parse(storage.getItem('setting') as string)
|
||||
if (currentVideoId === user.account) {
|
||||
message.error('请勿自己录制自己!')
|
||||
} else {
|
||||
footerListTemplate[itemIndex][rowIndex].title = '录制中'
|
||||
footerListTemplate[itemIndex][rowIndex].active = true
|
||||
setFooterList(footerListTemplate)
|
||||
agora.startRecording(Number(currentVideoId))
|
||||
try {
|
||||
await fs.access(setting.recordingFilesPath, fs.constants.F_OK)
|
||||
footerListTemplate[itemIndex][rowIndex].title = '录制中'
|
||||
footerListTemplate[itemIndex][rowIndex].active = true
|
||||
setFooterList(footerListTemplate)
|
||||
agora.startRecording(Number(currentVideoId))
|
||||
} catch (error: any) {
|
||||
if (error.code === 'ENOENT') {
|
||||
message.error('文件夹不存在!')
|
||||
return
|
||||
} else {
|
||||
message.error(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '录制中':
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ export interface IElectronAPI {
|
|||
onUpdate: (callBack: Function) => void;
|
||||
joinNotification: (data: { name: string, body: string }) => void;
|
||||
onDownload: (data: string) => void
|
||||
selectFilePath: () => void
|
||||
onFilePath: (callBack: Function) => void;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ const agora = {
|
|||
rtcEngine.initialize({
|
||||
appId: option.appId,
|
||||
});
|
||||
// console.log(rtcEngine.getAudioDeviceManager().enumeratePlaybackDevices());
|
||||
},
|
||||
// 事件回调
|
||||
registerEventHandler: ({ onJoinChannelSuccess, onUserJoined, onUserOffline, onAudioVolumeIndication }: any) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue