add get platform API

This commit is contained in:
Abhinav 2023-10-27 12:38:57 +05:30
parent 18fbabe56c
commit 7d3c0b3c09
3 changed files with 15 additions and 0 deletions

View file

@ -27,6 +27,15 @@ export const openDirectory = async (dirPath: string): Promise<void> => {
}
};
export const getPlatform = async (): Promise<'mac' | 'windows' | 'linux'> => {
try {
return await ipcRenderer.invoke('get-platform');
} catch (e) {
logError(e, 'failed to get platform');
throw e;
}
};
export {
logToDisk,
openLogDirectory,

View file

@ -41,6 +41,7 @@ import {
getAppVersion,
openDirectory,
updateOptOutOfCrashReports,
getPlatform,
} from './api/common';
import { fixHotReloadNext12 } from './utils/preload';
import {
@ -117,4 +118,5 @@ windowObject['ElectronAPIs'] = {
updateOptOutOfCrashReports,
computeImageEmbedding,
computeTextEmbedding,
getPlatform,
};

View file

@ -31,6 +31,7 @@ import {
computeImageEmbedding,
computeTextEmbedding,
} from '../services/clipService';
import { getPlatform } from './common/platform';
export default function setupIpcComs(
tray: Tray,
@ -176,4 +177,7 @@ export default function setupIpcComs(
ipcMain.handle('compute-text-embedding', (_, text) => {
return computeTextEmbedding(text);
});
ipcMain.handle('get-platform', () => {
return getPlatform();
});
}