- Added new image assets: image_mode.png, logo-with-bg.png, image-provider.png, and openai.png. - Enhanced presentation generation state to include theme property. - Introduced updateTheme action in presentation generation slice. - Updated user configuration with default LLM and image provider settings. - Modified Tailwind CSS configuration to include new font families. - Improved API utility functions for better handling of URLs in Electron environment. - Adjusted PPTX model utility for border radius handling. - Expanded provider constants to include URLs and icons for LLM providers. - Updated provider utility functions for consistent API URL usage. - Added new quality options for image generation providers. - Updated package-lock.json to include new dependencies for react-colorful and scheduler.
45 lines
No EOL
1.4 KiB
TypeScript
45 lines
No EOL
1.4 KiB
TypeScript
// Utility to get the FastAPI base URL
|
|
export function getFastAPIUrl(): string {
|
|
// Prefer Electron-preload env when available
|
|
if (typeof window !== "undefined" && (window as any).env?.NEXT_PUBLIC_FAST_API) {
|
|
return (window as any).env.NEXT_PUBLIC_FAST_API;
|
|
}
|
|
|
|
// In Electron, NEXT_PUBLIC_FAST_API is set by setupEnv in main.ts
|
|
if (process.env.NEXT_PUBLIC_FAST_API) {
|
|
return process.env.NEXT_PUBLIC_FAST_API;
|
|
}
|
|
|
|
// Safe Electron fallback to local FastAPI
|
|
return "http://127.0.0.1:8000";
|
|
}
|
|
|
|
function isAbsoluteHttpUrl(path: string): boolean {
|
|
return /^https?:\/\//i.test(path);
|
|
}
|
|
|
|
function withLeadingSlash(path: string): string {
|
|
return path.startsWith("/") ? path : `/${path}`;
|
|
}
|
|
|
|
function isElectronRuntime(): boolean {
|
|
return typeof window !== "undefined" && !!(window as any).electron;
|
|
}
|
|
|
|
// Utility to construct API URL that works in both web and Electron.
|
|
export function getApiUrl(path: string): string {
|
|
if (isAbsoluteHttpUrl(path)) {
|
|
return path;
|
|
}
|
|
|
|
const normalizedPath = withLeadingSlash(path);
|
|
const isFastApiEndpoint = normalizedPath.startsWith("/api/v1/");
|
|
|
|
// In web/docker, /api/v1 is typically reverse-proxied by the web server.
|
|
// In Electron, Next and FastAPI run on different ports, so use FastAPI base URL.
|
|
if (isFastApiEndpoint && (isElectronRuntime() || !!process.env.NEXT_PUBLIC_FAST_API)) {
|
|
return `${getFastAPIUrl()}${normalizedPath}`;
|
|
}
|
|
|
|
return normalizedPath;
|
|
} |