Compare commits
1 Commits
017a2ae5a4
...
react_migr
| Author | SHA1 | Date | |
|---|---|---|---|
| d3d5270889 |
@ -1,8 +1,8 @@
|
|||||||
import { ipcMain } from 'electron';
|
import { dialog, ipcMain } from 'electron';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import AudioChannels from './channels';
|
import AudioChannels from './channels';
|
||||||
import { LoadAudioBufferArgs, LoadAudioBufferResult } from './types';
|
import { LoadAudioBufferArgs, LoadAudioBufferResult } from './types';
|
||||||
import PythonSubprocessManager from '../../main/service';
|
import PythonSubprocessManager from '../main/service';
|
||||||
|
|
||||||
export default function registerAudioIpcHandlers() {
|
export default function registerAudioIpcHandlers() {
|
||||||
ipcMain.handle(
|
ipcMain.handle(
|
||||||
@ -1,8 +0,0 @@
|
|||||||
const SettingsChannels = {
|
|
||||||
GET_DEFAULTS: 'settings:get-defaults',
|
|
||||||
GET_SETTINGS: 'settings:get-settings',
|
|
||||||
SET_SETTINGS: 'settings:set-settings',
|
|
||||||
GET_INPUT_DEVICES: 'settings:get-input-devices',
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
export default SettingsChannels;
|
|
||||||
@ -10,12 +10,20 @@
|
|||||||
*/
|
*/
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { app, BrowserWindow, shell, ipcMain, Tray, Menu } from 'electron';
|
import {
|
||||||
|
app,
|
||||||
|
BrowserWindow,
|
||||||
|
shell,
|
||||||
|
ipcMain,
|
||||||
|
Tray,
|
||||||
|
Menu,
|
||||||
|
dialog,
|
||||||
|
} from 'electron';
|
||||||
import { autoUpdater } from 'electron-updater';
|
import { autoUpdater } from 'electron-updater';
|
||||||
import log from 'electron-log';
|
import log from 'electron-log';
|
||||||
import MenuBuilder from './menu';
|
import MenuBuilder from './menu';
|
||||||
import { resolveHtmlPath } from './util';
|
import { resolveHtmlPath } from './util';
|
||||||
import registerFileIpcHandlers from '../ipc/audio/main';
|
import registerFileIpcHandlers from '../ipc/main';
|
||||||
import PythonSubprocessManager from './service';
|
import PythonSubprocessManager from './service';
|
||||||
|
|
||||||
const pythonManager = new PythonSubprocessManager('src/main.py');
|
const pythonManager = new PythonSubprocessManager('src/main.py');
|
||||||
@ -110,6 +118,21 @@ const createWindow = async () => {
|
|||||||
menuBuilder.buildMenu();
|
menuBuilder.buildMenu();
|
||||||
registerFileIpcHandlers();
|
registerFileIpcHandlers();
|
||||||
|
|
||||||
|
ipcMain.handle('select-directory', async () => {
|
||||||
|
try {
|
||||||
|
const result = await dialog.showOpenDialog(mainWindow, {
|
||||||
|
properties: ['openDirectory'], // Key property to select a folder
|
||||||
|
});
|
||||||
|
if (!result.canceled && result.filePaths.length > 0) {
|
||||||
|
// Send the selected directory path back to the renderer process
|
||||||
|
return result.filePaths[0];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (err: any) {
|
||||||
|
return { error: err.message };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Open urls in the user's browser
|
// Open urls in the user's browser
|
||||||
mainWindow.webContents.setWindowOpenHandler((edata) => {
|
mainWindow.webContents.setWindowOpenHandler((edata) => {
|
||||||
shell.openExternal(edata.url);
|
shell.openExternal(edata.url);
|
||||||
@ -164,7 +187,7 @@ app
|
|||||||
.whenReady()
|
.whenReady()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// if (app.isPackaged) {
|
// if (app.isPackaged) {
|
||||||
// pythonManager.start();
|
pythonManager.start();
|
||||||
// }
|
// }
|
||||||
createWindow();
|
createWindow();
|
||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
// Disable no-unused-vars, broken for spread args
|
// Disable no-unused-vars, broken for spread args
|
||||||
/* eslint no-unused-vars: off */
|
/* eslint no-unused-vars: off */
|
||||||
import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron';
|
import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron';
|
||||||
import { LoadAudioBufferArgs } from '../ipc/audio/types';
|
import { LoadAudioBufferArgs } from '../ipc/types';
|
||||||
import AudioChannels from '../ipc/audio/channels';
|
import AudioChannels from '../ipc/channels';
|
||||||
// import '../ipc/file/preload'; // Import file API preload to ensure it runs and exposes the API
|
// import '../ipc/file/preload'; // Import file API preload to ensure it runs and exposes the API
|
||||||
|
|
||||||
export type Channels = 'ipc-example';
|
export type Channels = 'ipc-example';
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
|
// import { ipcRenderer } from 'electron';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import './App.css';
|
import './App.css';
|
||||||
import TextField from '@mui/material/TextField';
|
import TextField from '@mui/material/TextField';
|
||||||
import Select from '@mui/material/Select';
|
import Select from '@mui/material/Select';
|
||||||
import MenuItem from '@mui/material/MenuItem';
|
import MenuItem from '@mui/material/MenuItem';
|
||||||
|
import { IconButton } from '@mui/material';
|
||||||
|
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
||||||
import { apiFetch } from './api';
|
import { apiFetch } from './api';
|
||||||
|
|
||||||
type AudioDevice = {
|
type AudioDevice = {
|
||||||
@ -123,18 +126,22 @@ export default function SettingsPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleFolderChange = async () => {
|
const handleFolderChange = async () => {
|
||||||
// Replace with actual folder picker
|
await window.electron.ipcRenderer
|
||||||
// Example: const folder = await window.api.selectFolder();
|
.invoke('select-directory')
|
||||||
// const folder = window.prompt(
|
.then((result) => {
|
||||||
// 'Enter output folder path:',
|
if (result) {
|
||||||
// settings.outputFolder,
|
setSettings((prev) => ({
|
||||||
// );
|
...prev,
|
||||||
// if (folder !== null) {
|
save_path: result,
|
||||||
// setSettings((prev) => ({
|
}));
|
||||||
// ...prev,
|
sendSettingsToBackend({
|
||||||
// outputFolder: folder,
|
...settings,
|
||||||
// }));
|
save_path: result,
|
||||||
// }
|
});
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -259,13 +266,22 @@ export default function SettingsPage() {
|
|||||||
value={settings.save_path}
|
value={settings.save_path}
|
||||||
className="ml-2 w-[300px]"
|
className="ml-2 w-[300px]"
|
||||||
/>
|
/>
|
||||||
<button
|
<IconButton
|
||||||
|
component="label"
|
||||||
|
size="small"
|
||||||
|
tabIndex={-1}
|
||||||
|
onClick={handleFolderChange}
|
||||||
|
>
|
||||||
|
<MoreHorizIcon />
|
||||||
|
</IconButton>
|
||||||
|
{/* <button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={handleFolderChange}
|
onClick={handleFolderChange}
|
||||||
className="ml-2 px-3 py-1 rounded bg-plumDark text-offwhite hover:bg-plum"
|
className="ml-2 px-3 py-1 rounded bg-plumDark text-offwhite hover:bg-plum"
|
||||||
>
|
>
|
||||||
|
<VisuallyHiddenInput type="file" />
|
||||||
...
|
...
|
||||||
</button>
|
</button> */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user