Update src/main/services/ScreenshotService.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
SuYao 2025-12-15 02:10:07 +08:00 committed by GitHub
parent ef41317ccd
commit 9f16630512
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -285,8 +285,13 @@ export class Screenshot {
this.screenshotBuffer = buffer
this.currentFileName = fileName
// Convert to base64 data URL for the renderer
this.screenshotData = `data:image/png;base64,${buffer.toString('base64')}`
// Write buffer to a temporary file and store the file URL for the renderer
const os = await import('os');
const tempDir = os.tmpdir();
const tempFileName = `screenshot-${uuidv4()}.png`;
const tempFilePath = path.join(tempDir, tempFileName);
await fs.promises.writeFile(tempFilePath, buffer);
this.screenshotData = `file://${tempFilePath}`;
// Create or show selection window
if (!this.selectionWindow || this.selectionWindow.isDestroyed()) {