Merge branch 'fix/export_function_windows' into 'develop'

Fix/export function windows

See merge request proj-wise2526-video2document/video2document!75
This commit is contained in:
Hughes, Mike
2025-12-22 14:06:44 +01:00
+14 -11
View File
@@ -30,24 +30,27 @@ async function showSaveDialog(defaultName, format) {
throw err; throw err;
} }
} else if (platform === 'win32') { } else if (platform === 'win32') {
// Windows const safeName = decodeURIComponent(defaultName);
const powershell = ` const powershell = `
Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Windows.Forms;
$dialog = New-Object System.Windows.Forms.SaveFileDialog $dialog = New-Object System.Windows.Forms.SaveFileDialog;
$dialog.FileName = "${defaultName}.${format}" $dialog.FileName = '${safeName}.${format}';
$dialog.Filter = "${format.toUpperCase()} Dateien (*.${format})|*.${format}|Alle Dateien (*.*)|*.*" $dialog.Filter = '${format.toUpperCase()} Dateien (*.${format})|*.${format}|Alle Dateien (*.*)|*.*';
$dialog.Title = "Dokument speichern als" $dialog.Title = 'Dokument speichern als';
$result = $dialog.ShowDialog() $result = $dialog.ShowDialog();
if ($result -eq 'OK') { $dialog.FileName } if ($result -eq 'OK') { $dialog.FileName }
`; `;
try { try {
const result = execSync(`powershell -Command "${powershell.replace(/\n/g, '; ')}"`, { const result = execSync(
encoding: 'utf8' `powershell -NoProfile -Command "${powershell.replace(/\r?\n/g, ' ')}"`,
}); { encoding: 'utf8' }
);
return result.trim() || null; return result.trim() || null;
} catch (err) { } catch (err) {
throw err; if (err.status === 1) return null; // User cancelled
throw new Error("Save dialog failed: " + err.message);
} }
} else { } else {
// Linux - zenity oder kdialog // Linux - zenity oder kdialog