Changes: nextjs ui to make production ready
This commit is contained in:
parent
1233c34184
commit
0090b0d4aa
2 changed files with 25 additions and 31 deletions
|
|
@ -17,37 +17,34 @@ export function setupExportHandlers() {
|
|||
|
||||
ipcMain.handle("export-as-pdf", async (_, id: string, title: string) => {
|
||||
const ppt_url = `${process.env.NEXT_PUBLIC_URL}/pdf-maker?id=${id}`;
|
||||
const browser = new BrowserWindow({
|
||||
width: 1280,
|
||||
height: 720,
|
||||
icon: path.join(baseDir, "resources/ui/assets/images/presenton_short_filled.png"),
|
||||
webPreferences: {
|
||||
webSecurity: false,
|
||||
const browser = new BrowserWindow({
|
||||
width: 1280,
|
||||
height: 720,
|
||||
icon: path.join(baseDir, "resources/ui/assets/images/presenton_short_filled.png"),
|
||||
webPreferences: {
|
||||
webSecurity: false,
|
||||
|
||||
preload: path.join(__dirname, '../preloads/index.js'),
|
||||
},
|
||||
show: false,
|
||||
});
|
||||
preload: path.join(__dirname, '../preloads/index.js'),
|
||||
},
|
||||
show: false,
|
||||
});
|
||||
browser.loadURL(ppt_url);
|
||||
browser.webContents.on('did-finish-load', async () => {
|
||||
await new Promise(async (resolve, reject) => {
|
||||
setTimeout(async () => {
|
||||
resolve(true);
|
||||
}, 5000);
|
||||
});
|
||||
const pdfBuffer = await browser.webContents.printToPDF({
|
||||
printBackground: true,
|
||||
pageSize:{width:1280/96,height:720/96},
|
||||
margins:{top:0,right:0,bottom:0,left:0}
|
||||
const success = await new Promise((resolve, _) => {
|
||||
browser.webContents.on('did-frame-finish-load', async () => {
|
||||
const pdfBuffer = await browser.webContents.printToPDF({
|
||||
printBackground: true,
|
||||
pageSize: { width: 1280 / 96, height: 720 / 96 },
|
||||
margins: { top: 0, right: 0, bottom: 0, left: 0 }
|
||||
});
|
||||
browser.close();
|
||||
const destinationPath = path.join(downloadsDir, `${title}.pdf`);
|
||||
await fs.promises.writeFile(destinationPath, pdfBuffer);
|
||||
|
||||
const success = await showFileDownloadedDialog(destinationPath);
|
||||
resolve(success);
|
||||
});
|
||||
browser.close();
|
||||
const destinationPath = path.join(downloadsDir, `${title}.pdf`);
|
||||
await fs.promises.writeFile(destinationPath, pdfBuffer);
|
||||
|
||||
const success = await showFileDownloadedDialog(destinationPath);
|
||||
return { success };
|
||||
});
|
||||
return { success: false };
|
||||
return { success };
|
||||
})
|
||||
|
||||
}
|
||||
|
|
@ -241,7 +241,7 @@ const Header = ({
|
|||
};
|
||||
|
||||
const ExportOptions = () => (
|
||||
<div className="space-y-2 max-md:mt-4 bg-white rounded-lg p-2">
|
||||
<div className="space-y-2 max-md:mt-4 bg-white rounded-lg">
|
||||
<Button
|
||||
onClick={handleExportPdf}
|
||||
variant="ghost"
|
||||
|
|
@ -320,9 +320,6 @@ const Header = ({
|
|||
{isStreaming && (
|
||||
<Loader2 className="animate-spin text-white font-bold w-6 h-6" />
|
||||
)}
|
||||
<button onClick={() => router.push(`/pdf-maker?id=${presentation_id}`)}>
|
||||
go there
|
||||
</button>
|
||||
<Select value={currentTheme} onValueChange={handleThemeSelect}>
|
||||
<SelectTrigger className="w-[160px] bg-[#6358fd] text-white border-none hover:bg-[#5146E5] transition-colors">
|
||||
<div className="flex items-center gap-2">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue