mirror of
https://github.com/khairul169/vaulterm.git
synced 2026-09-15 17:03:30 +07:00
feat: multi tab session
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { View, Text } from "react-native";
|
||||
import React from "react";
|
||||
import Terminal from "./terminal";
|
||||
import { BASE_WS_URL } from "@/lib/api";
|
||||
|
||||
type SSHSessionProps = {
|
||||
type: "ssh";
|
||||
options: {
|
||||
serverId: string;
|
||||
};
|
||||
};
|
||||
|
||||
type Props = SSHSessionProps;
|
||||
|
||||
const InteractiveSession = ({ type, options }: Props) => {
|
||||
switch (type) {
|
||||
case "ssh":
|
||||
const params = new URLSearchParams({
|
||||
serverId: options.serverId,
|
||||
token: "token",
|
||||
});
|
||||
return <Terminal wsUrl={BASE_WS_URL + "/ws/ssh?" + params} />;
|
||||
|
||||
default:
|
||||
throw new Error("Unknown interactive session type");
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export default InteractiveSession;
|
||||
@@ -69,10 +69,13 @@ const XTermJs = forwardRef<XTermRef, XTermJsProps>((props, ref) => {
|
||||
}
|
||||
|
||||
function onOpen() {
|
||||
console.log("WS Open");
|
||||
resizeTerminal();
|
||||
}
|
||||
|
||||
function onClose(e: CloseEvent) {
|
||||
console.log("WS Closed", e.reason, e.code);
|
||||
|
||||
// Check if the close event was abnormal
|
||||
if (!e.wasClean) {
|
||||
const reason = e.reason || `Code: ${e.code}`;
|
||||
|
||||
Reference in New Issue
Block a user