Распаковал архив Proxmox-VPS-Panel.rar и добавил содержимое в репозиторий

This commit is contained in:
root
2026-07-24 15:10:47 +00:00
parent 0372e2c5f1
commit ac74a700ce
37 changed files with 2353 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
import React, { useEffect, useRef, useState } from "react";
import { api } from "../api.js";
const NOVNC_CDN = "https://cdn.jsdelivr.net/npm/@novnc/novnc@1.4.0/lib/rfb.js";
export default function ConsoleViewer({ instanceId }) {
const containerRef = useRef(null);
const rfbRef = useRef(null);
const [status, setStatus] = useState("Подключение…");
const [error, setError] = useState("");
useEffect(() => {
let cancelled = false;
async function connect() {
try {
const info = await api.getConsole(instanceId);
const { default: RFB } = await import(/* @vite-ignore */ NOVNC_CDN);
if (cancelled) return;
const proto = window.location.protocol === "https:" ? "wss" : "ws";
const wsUrl =
`${proto}://${window.location.host}/api/console/ws?` +
`node=${encodeURIComponent(info.node)}&vmid=${info.vmid}&guest_type=${info.guest_type}` +
`&port=${info.port}&ticket=${encodeURIComponent(info.ticket)}`;
const rfb = new RFB(containerRef.current, wsUrl);
rfb.addEventListener("connect", () => !cancelled && setStatus("Подключено"));
rfb.addEventListener("disconnect", () => !cancelled && setStatus("Соединение закрыто"));
rfbRef.current = rfb;
} catch (err) {
if (!cancelled) setError(err.message || String(err));
}
}
connect();
return () => {
cancelled = true;
rfbRef.current?.disconnect?.();
};
}, [instanceId]);
return (
<div>
<div className="status-row" style={{ marginBottom: 8 }}>
<span className={`dot ${error ? "error" : "running"}`} /> {error ? "Ошибка консоли" : status}
</div>
{error && (
<div className="error-box">
{error}. Консоль VNC зависит от версии Proxmox и настроек аутентификации см. README, раздел
«Консоль VNC».
</div>
)}
<div className="console-frame" ref={containerRef} style={{ width: "100%", height: 480 }} />
</div>
);
}