From 06b624e170d1ba238779205bfc02e67441f6e7c7 Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Fri, 26 Jul 2024 16:38:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 13 ++++++- preload.js | 17 +++++---- src/components/StupWizard/index.tsx | 56 +++++++++++++++++++++++++++-- src/page/Meeting/index.tsx | 20 ++++++++--- src/render.d.ts | 2 ++ src/utils/package/agora.ts | 1 - 6 files changed, 93 insertions(+), 16 deletions(-) diff --git a/main.js b/main.js index 0cb9550..46a22f5 100644 --- a/main.js +++ b/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) => { // 设置最小窗口尺寸 diff --git a/preload.js b/preload.js index 39122e2..b759da7 100644 --- a/preload.js +++ b/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) + }, } diff --git a/src/components/StupWizard/index.tsx b/src/components/StupWizard/index.tsx index d74c9c2..dceefc5 100644 --- a/src/components/StupWizard/index.tsx +++ b/src/components/StupWizard/index.tsx @@ -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) }} /> - + + @@ -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) }} /> - + +