2023-09-04 21:29:17 +05:30
|
|
|
"use strict";
|
|
|
|
|
2024-12-16 16:18:57 +05:30
|
|
|
import { ipcRenderer } from "electron";
|
|
|
|
import os from "os";
|
2023-09-04 21:29:17 +05:30
|
|
|
|
|
|
|
export const getPlatform = () => {
|
2024-12-16 16:18:57 +05:30
|
|
|
switch (os.platform()) {
|
2023-09-04 21:29:17 +05:30
|
|
|
case "aix":
|
|
|
|
case "freebsd":
|
|
|
|
case "linux":
|
|
|
|
case "openbsd":
|
|
|
|
case "android":
|
|
|
|
return "linux";
|
|
|
|
case "darwin":
|
|
|
|
case "sunos":
|
|
|
|
return "mac";
|
|
|
|
case "win32":
|
|
|
|
return "win";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getArch = () => {
|
2024-12-16 16:18:57 +05:30
|
|
|
switch (os.arch()) {
|
2023-09-04 21:29:17 +05:30
|
|
|
case "x64":
|
|
|
|
return "x64";
|
|
|
|
case "x32":
|
|
|
|
return "x86";
|
|
|
|
case "arm":
|
|
|
|
return "arm";
|
|
|
|
case "arm64":
|
|
|
|
return "arm64";
|
|
|
|
}
|
|
|
|
};
|
2024-12-16 16:18:57 +05:30
|
|
|
|
|
|
|
export const getAppVersion = async () => {
|
|
|
|
let appVersion = process.env.npm_package_version;
|
|
|
|
try {
|
|
|
|
appVersion = await ipcRenderer.invoke("get-app-version");
|
|
|
|
} catch (error) {
|
|
|
|
console.error("Failed to get app version:", error);
|
|
|
|
}
|
|
|
|
|
|
|
|
return appVersion;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getDeviceSpecs = async () => {
|
|
|
|
let gpuInfo;
|
|
|
|
try {
|
|
|
|
gpuInfo = await ipcRenderer.invoke("get-gpu-info");
|
|
|
|
} catch (error) {
|
|
|
|
console.error("Failed to get GPU info:", error);
|
|
|
|
gpuInfo = null;
|
|
|
|
}
|
|
|
|
|
2024-12-21 15:43:09 +05:30
|
|
|
const deviceSpecs = {
|
2024-12-16 16:18:57 +05:30
|
|
|
platform: getPlatform(),
|
|
|
|
release: os.release(),
|
|
|
|
arch: getArch(),
|
|
|
|
model: os.cpus()[0].model.trim(),
|
|
|
|
cpuCount: os.cpus().length,
|
|
|
|
...(gpuInfo && { gpu: gpuInfo.gpuDevice[0] }),
|
|
|
|
};
|
2024-12-21 15:43:09 +05:30
|
|
|
|
|
|
|
return deviceSpecs;
|
2024-12-16 16:18:57 +05:30
|
|
|
};
|