@mytec: iter2.1 ready for testing
This commit is contained in:
47
frontend/src/lib/desktop.ts
Normal file
47
frontend/src/lib/desktop.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
interface RFCPDesktop {
|
||||
getDataPath: () => Promise<string>;
|
||||
getAppVersion: () => Promise<string>;
|
||||
getPlatform: () => Promise<string>;
|
||||
getGpuInfo: () => Promise<{
|
||||
available: boolean;
|
||||
name: string | null;
|
||||
cudaVersion: string | null;
|
||||
}>;
|
||||
selectDirectory: () => Promise<string | null>;
|
||||
selectFile: (options?: { filters?: Array<{ name: string; extensions: string[] }> }) => Promise<string | null>;
|
||||
saveFile: (options?: { defaultPath?: string; filters?: Array<{ name: string; extensions: string[] }> }) => Promise<string | null>;
|
||||
getSetting: (key: string) => Promise<unknown>;
|
||||
setSetting: (key: string, value: unknown) => Promise<void>;
|
||||
openExternal: (url: string) => Promise<void>;
|
||||
openPath: (path: string) => Promise<void>;
|
||||
platform: string;
|
||||
isDesktop: boolean;
|
||||
isMac: boolean;
|
||||
isWindows: boolean;
|
||||
isLinux: boolean;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
rfcp?: RFCPDesktop;
|
||||
}
|
||||
}
|
||||
|
||||
export const isDesktop = (): boolean => {
|
||||
return window.rfcp?.isDesktop === true;
|
||||
};
|
||||
|
||||
export const getDesktopApi = (): RFCPDesktop | null => {
|
||||
return window.rfcp || null;
|
||||
};
|
||||
|
||||
export const getApiBaseUrl = (): string => {
|
||||
if (isDesktop()) {
|
||||
return 'http://127.0.0.1:8888';
|
||||
}
|
||||
return import.meta.env.VITE_API_URL || 'https://api.rfcp.eliah.one';
|
||||
};
|
||||
|
||||
export const isMac = (): boolean => {
|
||||
return window.rfcp?.isMac === true;
|
||||
};
|
||||
@@ -1,8 +1,9 @@
|
||||
/**
|
||||
* Backend API client for RFCP coverage calculation
|
||||
*/
|
||||
import { getApiBaseUrl } from '@/lib/desktop.ts';
|
||||
|
||||
const API_BASE = import.meta.env.VITE_API_URL || 'https://api.rfcp.eliah.one';
|
||||
const API_BASE = getApiBaseUrl();
|
||||
|
||||
// === Request types ===
|
||||
|
||||
|
||||
Reference in New Issue
Block a user