mirror of
https://github.com/khairul169/vaulterm.git
synced 2026-09-15 17:03:30 +07:00
feat: init api, db, app
This commit is contained in:
@@ -6,7 +6,7 @@ import VNCViewer from "./vncviewer";
|
||||
type SSHSessionProps = {
|
||||
type: "ssh";
|
||||
params: {
|
||||
serverId: string;
|
||||
hostId: string;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ type PVESessionProps = {
|
||||
type: "pve";
|
||||
params: {
|
||||
client: "vnc" | "xtermjs";
|
||||
serverId: string;
|
||||
hostId: string;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ type IncusSessionProps = {
|
||||
type: "incus";
|
||||
params: {
|
||||
client: "vnc" | "xtermjs";
|
||||
serverId: string;
|
||||
hostId: string;
|
||||
shell?: string;
|
||||
};
|
||||
};
|
||||
@@ -33,29 +33,19 @@ export type InteractiveSessionProps =
|
||||
| IncusSessionProps;
|
||||
|
||||
const InteractiveSession = ({ type, params }: InteractiveSessionProps) => {
|
||||
let url = "";
|
||||
const query = new URLSearchParams({
|
||||
...params,
|
||||
});
|
||||
const query = new URLSearchParams(params);
|
||||
const url = `${BASE_WS_URL}/ws/term?${query}`;
|
||||
|
||||
switch (type) {
|
||||
case "ssh":
|
||||
return <Terminal wsUrl={`${BASE_WS_URL}/ws/ssh?${query}`} />;
|
||||
return <Terminal url={url} />;
|
||||
|
||||
case "pve":
|
||||
url = `${BASE_WS_URL}/ws/pve?${query}`;
|
||||
return params.client === "vnc" ? (
|
||||
<VNCViewer url={url} />
|
||||
) : (
|
||||
<Terminal wsUrl={url} />
|
||||
);
|
||||
|
||||
case "incus":
|
||||
url = `${BASE_WS_URL}/ws/incus?${query}`;
|
||||
return params.client === "vnc" ? (
|
||||
<VNCViewer url={url} />
|
||||
) : (
|
||||
<Terminal wsUrl={url} />
|
||||
<Terminal url={url} />
|
||||
);
|
||||
|
||||
default:
|
||||
|
||||
@@ -28,7 +28,7 @@ const Keys = {
|
||||
|
||||
type XTermJsProps = {
|
||||
client?: "xtermjs";
|
||||
wsUrl: string;
|
||||
url: string;
|
||||
};
|
||||
|
||||
type TerminalProps = ComponentPropsWithoutRef<typeof View> & XTermJsProps;
|
||||
@@ -50,7 +50,7 @@ const Terminal = ({ client = "xtermjs", style, ...props }: TerminalProps) => {
|
||||
<XTermJs
|
||||
ref={xtermRef}
|
||||
dom={{ scrollEnabled: false }}
|
||||
wsUrl={props.wsUrl}
|
||||
wsUrl={props.url}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
@@ -19,6 +19,12 @@ const VNCViewer = ({ ...props }: VNCViewerProps) => {
|
||||
const rfb = new RFB(screenRef.current!, props.url);
|
||||
rfb.scaleViewport = true;
|
||||
|
||||
const canvas: HTMLCanvasElement | null =
|
||||
rfb._target?.querySelector("canvas");
|
||||
if (canvas) {
|
||||
canvas.style.cursor = "default";
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
const ws: WebSocket = rfb._sock._websocket;
|
||||
let password: string | null = null;
|
||||
|
||||
Reference in New Issue
Block a user