mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-26 20:31:03 +00:00
fix: moving constant
This commit is contained in:
@@ -31,6 +31,11 @@ export const logsPath = path.join(
|
|||||||
`logs${isStaging ? "-staging" : ""}`
|
`logs${isStaging ? "-staging" : ""}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const screenshotsPath = path.join(
|
||||||
|
SystemPath.getPath("userData"),
|
||||||
|
"Screenshots"
|
||||||
|
);
|
||||||
|
|
||||||
export const achievementSoundPath = app.isPackaged
|
export const achievementSoundPath = app.isPackaged
|
||||||
? path.join(process.resourcesPath, "achievement.wav")
|
? path.join(process.resourcesPath, "achievement.wav")
|
||||||
: path.join(__dirname, "..", "..", "resources", "achievement.wav");
|
: path.join(__dirname, "..", "..", "resources", "achievement.wav");
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { desktopCapturer, nativeImage, app } from "electron";
|
|||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger";
|
||||||
|
import { screenshotsPath } from "@main/constants";
|
||||||
|
|
||||||
export class ScreenshotService {
|
export class ScreenshotService {
|
||||||
private static readonly SCREENSHOT_QUALITY = 80;
|
private static readonly SCREENSHOT_QUALITY = 80;
|
||||||
@@ -50,6 +51,8 @@ export class ScreenshotService {
|
|||||||
throw new Error("No desktop sources available for screenshot");
|
throw new Error("No desktop sources available for screenshot");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("sources", sources);
|
||||||
|
|
||||||
const primaryScreen = sources[0];
|
const primaryScreen = sources[0];
|
||||||
|
|
||||||
const originalImage = nativeImage.createFromDataURL(
|
const originalImage = nativeImage.createFromDataURL(
|
||||||
@@ -58,15 +61,12 @@ export class ScreenshotService {
|
|||||||
|
|
||||||
const compressedImage = this.compressImage(originalImage);
|
const compressedImage = this.compressImage(originalImage);
|
||||||
|
|
||||||
const userDataPath = app.getPath("userData");
|
let finalDir = screenshotsPath;
|
||||||
const screenshotsDir = path.join(userDataPath, "screenshots");
|
|
||||||
|
|
||||||
let finalDir = screenshotsDir;
|
|
||||||
let filename: string;
|
let filename: string;
|
||||||
|
|
||||||
if (gameTitle && achievementName) {
|
if (gameTitle && achievementName) {
|
||||||
const sanitizedGameTitle = gameTitle.replaceAll(/[<>:"/\\|?*]/g, "_");
|
const sanitizedGameTitle = gameTitle.replaceAll(/[<>:"/\\|?*]/g, "_");
|
||||||
const gameDir = path.join(screenshotsDir, sanitizedGameTitle);
|
const gameDir = path.join(screenshotsPath, sanitizedGameTitle);
|
||||||
finalDir = gameDir;
|
finalDir = gameDir;
|
||||||
|
|
||||||
const sanitizedAchievementName = achievementName.replaceAll(
|
const sanitizedAchievementName = achievementName.replaceAll(
|
||||||
|
|||||||
Reference in New Issue
Block a user