mirror of
https://github.com/khairul169/vaulterm.git
synced 2026-09-15 17:03:30 +07:00
feat: update using gofiber
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { View, Text } from "react-native";
|
||||
import React from "react";
|
||||
import Terminal from "./terminal";
|
||||
import { BASE_WS_URL } from "@/lib/api";
|
||||
@@ -19,7 +18,9 @@ const InteractiveSession = ({ type, options }: Props) => {
|
||||
serverId: options.serverId,
|
||||
token: "token",
|
||||
});
|
||||
return <Terminal wsUrl={BASE_WS_URL + "/ws/ssh?" + params} />;
|
||||
return (
|
||||
<Terminal client="xtermjs" wsUrl={`${BASE_WS_URL}/ws/ssh?${params}`} />
|
||||
);
|
||||
|
||||
default:
|
||||
throw new Error("Unknown interactive session type");
|
||||
|
||||
@@ -26,20 +26,33 @@ const Keys = {
|
||||
Tab: "\x09",
|
||||
};
|
||||
|
||||
type TerminalProps = ComponentPropsWithoutRef<typeof View> & {
|
||||
type XTermJsProps = {
|
||||
client: "xtermjs";
|
||||
wsUrl: string;
|
||||
};
|
||||
|
||||
const Terminal = ({ wsUrl, style, ...props }: TerminalProps) => {
|
||||
const ref = React.useRef<XTermRef>(null);
|
||||
type TerminalProps = ComponentPropsWithoutRef<typeof View> & XTermJsProps;
|
||||
|
||||
const Terminal = ({ client, style, ...props }: TerminalProps) => {
|
||||
const xtermRef = React.useRef<XTermRef>(null);
|
||||
|
||||
const send = (data: string) => {
|
||||
ref.current?.send(data);
|
||||
switch (client) {
|
||||
case "xtermjs":
|
||||
xtermRef.current?.send(data);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={[styles.container, style]} {...props}>
|
||||
<XTermJs ref={ref} dom={{ scrollEnabled: false }} wsUrl={wsUrl} />
|
||||
{client === "xtermjs" && (
|
||||
<XTermJs
|
||||
ref={xtermRef}
|
||||
dom={{ scrollEnabled: false }}
|
||||
wsUrl={props.wsUrl}
|
||||
/>
|
||||
)}
|
||||
|
||||
<ScrollView
|
||||
horizontal
|
||||
|
||||
Reference in New Issue
Block a user