mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-04-19 10:32:16 +00:00
Update terminal panel
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import type React from "react"
|
||||
import { useEffect, useRef, useState } from "react"
|
||||
import { API_PORT, fetchApi, getWebSocketUrl as getWebSocketUrlFromConfig, getApiUrl as getApiUrlFromConfig } from "@/lib/api-config"
|
||||
import { API_PORT, fetchApi } from "@/lib/api-config" // Unificando importaciones de api-config en una sola línea con alias @/
|
||||
import {
|
||||
Activity,
|
||||
Trash2,
|
||||
@@ -46,13 +46,31 @@ interface TerminalInstance {
|
||||
pingInterval?: ReturnType<typeof setInterval> | null // Heartbeat interval to keep connection alive
|
||||
}
|
||||
|
||||
// Use centralized functions from api-config.ts for SSL/proxy support
|
||||
function getWebSocketUrl(): string {
|
||||
return getWebSocketUrlFromConfig("/ws/terminal")
|
||||
if (typeof window === "undefined") {
|
||||
return "ws://localhost:8008/ws/terminal"
|
||||
}
|
||||
|
||||
const { protocol, hostname, port } = window.location
|
||||
const isStandardPort = port === "" || port === "80" || port === "443"
|
||||
|
||||
const wsProtocol = protocol === "https:" ? "wss:" : "ws:"
|
||||
|
||||
if (isStandardPort) {
|
||||
return `${wsProtocol}//${hostname}/ws/terminal`
|
||||
} else {
|
||||
return `${wsProtocol}//${hostname}:${API_PORT}/ws/terminal`
|
||||
}
|
||||
}
|
||||
|
||||
function getApiUrl(endpoint?: string): string {
|
||||
return getApiUrlFromConfig(endpoint || "")
|
||||
if (typeof window === "undefined") {
|
||||
return "http://localhost:8008"
|
||||
}
|
||||
|
||||
const { protocol, hostname } = window.location
|
||||
const apiProtocol = protocol === "https:" ? "https:" : "http:"
|
||||
return `${apiProtocol}//${hostname}:${API_PORT}${endpoint || ""}`
|
||||
}
|
||||
|
||||
const proxmoxCommands = [
|
||||
|
||||
Reference in New Issue
Block a user