v1.6.0 #221

Merged
LukeGus merged 74 commits from dev-1.6.0 into main 2025-09-12 19:42:00 +00:00
7 changed files with 23 additions and 33 deletions
Showing only changes of commit 01da97e86d - Show all commits

View File

@@ -5,6 +5,7 @@ import DesktopApp from './ui/Desktop/DesktopApp.tsx'
import { MobileApp } from './ui/Mobile/MobileApp.tsx'
import {ThemeProvider} from "@/components/theme-provider"
import './i18n/i18n'
import {isElectron} from './ui/main-axios.ts'
function useWindowWidth() {
const [width, setWidth] = useState(window.innerWidth);
@@ -52,9 +53,7 @@ function useWindowWidth() {
function RootApp() {
const width = useWindowWidth();
const isMobile = width < 768;
const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
if (isElectron) {
if (isElectron()) {
return <DesktopApp />;
}

View File

@@ -30,7 +30,8 @@ import {
makeUserAdmin,
removeAdminStatus,
deleteUser,
getCookie
getCookie,
isElectron
} from "@/ui/main-axios.ts";
interface AdminSettingsProps {
@@ -75,8 +76,7 @@ export function AdminSettings({isTopbarOpen = true}: AdminSettingsProps): React.
if (!jwt) return;
// Check if we're in Electron and have a server configured
const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
if (isElectron) {
if (isElectron()) {
// In Electron, check if we have a configured server
const serverUrl = (window as any).configuredServerUrl;
if (!serverUrl) {
@@ -101,8 +101,7 @@ export function AdminSettings({isTopbarOpen = true}: AdminSettingsProps): React.
React.useEffect(() => {
// Check if we're in Electron and have a server configured
const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
if (isElectron) {
if (isElectron()) {
const serverUrl = (window as any).configuredServerUrl;
if (!serverUrl) {
console.log('No server configured in Electron, skipping registration status check');
@@ -130,8 +129,7 @@ export function AdminSettings({isTopbarOpen = true}: AdminSettingsProps): React.
if (!jwt) return;
// Check if we're in Electron and have a server configured
const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
if (isElectron) {
if (isElectron()) {
const serverUrl = (window as any).configuredServerUrl;
if (!serverUrl) {
console.log('No server configured in Electron, skipping user fetch');

View File

@@ -6,7 +6,7 @@ import {Unicode11Addon} from '@xterm/addon-unicode11';
import {WebLinksAddon} from '@xterm/addon-web-links';
import {useTranslation} from 'react-i18next';
import {toast} from 'sonner';
import {getCookie} from '@/ui/main-axios.ts';
import {getCookie, isElectron} from '@/ui/main-axios.ts';
interface SSHTerminalProps {
hostConfig: any;
@@ -197,7 +197,6 @@ export const Terminal = forwardRef<any, SSHTerminalProps>(function SSHTerminal(
const isDev = process.env.NODE_ENV === 'development' &&
(window.location.port === '3000' || window.location.port === '5173' || window.location.port === '');
const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
const wsUrl = isDev
? 'ws://localhost:8082'
@@ -491,7 +490,6 @@ export const Terminal = forwardRef<any, SSHTerminalProps>(function SSHTerminal(
const isDev = process.env.NODE_ENV === 'development' &&
(window.location.port === '3000' || window.location.port === '5173' || window.location.port === '');
const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
const wsUrl = isDev
? 'ws://localhost:8082'

View File

@@ -23,6 +23,7 @@ import {
setCookie,
getCookie,
getServerConfig,
isElectron,
type ServerConfig
} from "../../main-axios.ts";
import {ServerConfig as ServerConfigComponent} from "@/ui/Desktop/ElectronOnly/ServerConfig.tsx";
@@ -413,7 +414,7 @@ export function HomepageAuth({
useEffect(() => {
const checkServerConfig = async () => {
if ((window as any).electronAPI) {
if (isElectron()) {
try {
const config = await getServerConfig();
console.log('Desktop HomepageAuth - Server config check:', config);
@@ -630,8 +631,7 @@ export function HomepageAuth({
<p>{t('auth.loginWithExternalDesc')}</p>
</div>
{(() => {
const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
if (isElectron) {
if (isElectron()) {
return (
<div className="text-center p-4 bg-muted/50 rounded-lg border">
<p className="text-muted-foreground text-sm">
@@ -871,7 +871,7 @@ export function HomepageAuth({
</div>
<LanguageSwitcher />
</div>
{(window as any).electronAPI && currentServerUrl && (
{isElectron() && currentServerUrl && (
<div className="flex items-center justify-between">
<div>
<Label className="text-sm text-muted-foreground">Server</Label>

View File

@@ -3,7 +3,7 @@ import {
ChevronUp, User2, HardDrive, Menu, ChevronRight
} from "lucide-react";
import { useTranslation } from 'react-i18next';
import {getCookie, setCookie} from "@/ui/main-axios.ts";
import {getCookie, setCookie, isElectron} from "@/ui/main-axios.ts";
import {
Sidebar,
@@ -61,10 +61,6 @@ interface SidebarProps {
children?: React.ReactNode;
}
function isElectron() {
const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
return isElectron;
}
function handleLogout() {
if (isElectron()) {

View File

@@ -5,6 +5,7 @@ import {ClipboardAddon} from '@xterm/addon-clipboard';
import {Unicode11Addon} from '@xterm/addon-unicode11';
import {WebLinksAddon} from '@xterm/addon-web-links';
import {useTranslation} from 'react-i18next';
import {isElectron} from '@/ui/main-axios.ts';
interface SSHTerminalProps {
hostConfig: any;
@@ -215,11 +216,10 @@ export const Terminal = forwardRef<any, SSHTerminalProps>(function SSHTerminal(
const isDev = process.env.NODE_ENV === 'development' &&
(window.location.port === '3000' || window.location.port === '5173' || window.location.port === '');
const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
const wsUrl = isDev
? 'ws://localhost:8082'
: isElectron
: isElectron()
? (() => {
// Get configured server URL from window object (set by main-axios)
const baseUrl = (window as any).configuredServerUrl || 'http://127.0.0.1:8081';

View File

@@ -75,6 +75,10 @@ interface OIDCAuthorize {
// UTILITY FUNCTIONS
// ============================================================================
export function isElectron(): boolean {
return (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
}
function getLoggerForService(serviceName: string) {
if (serviceName.includes('SSH') || serviceName.includes('ssh')) {
return sshLogger;
@@ -92,9 +96,7 @@ function getLoggerForService(serviceName: string) {
}
export function setCookie(name: string, value: string, days = 7): void {
const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
if (isElectron) {
if (isElectron()) {
localStorage.setItem(name, value);
} else {
const expires = new Date(Date.now() + days * 864e5).toUTCString();
@@ -103,8 +105,7 @@ export function setCookie(name: string, value: string, days = 7): void {
}
export function getCookie(name: string): string | undefined {
const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
if (isElectron) {
if (isElectron()) {
const token = localStorage.getItem(name) || undefined;
return token;
} else {
@@ -243,8 +244,7 @@ function createApiInstance(baseURL: string, serviceName: string = 'API'): AxiosI
// Handle auth token clearing
if (status === 401) {
const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
if (isElectron) {
if (isElectron()) {
localStorage.removeItem('jwt');
} else {
document.cookie = 'jwt=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
@@ -263,7 +263,6 @@ function createApiInstance(baseURL: string, serviceName: string = 'API'): AxiosI
// API INSTANCES
// ============================================================================
const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true;
const isDev = process.env.NODE_ENV === 'development' &&
(window.location.port === '3000' || window.location.port === '5173' || window.location.port === '');
@@ -334,7 +333,7 @@ if (isElectron) {
}
function getApiUrl(path: string, defaultPort: number): string {
if (isElectron) {
if (isElectron()) {
if (configuredServerUrl) {
// In Electron with configured server, all requests go through nginx reverse proxy
// Use the same base URL for all services (nginx routes to correct backend port)