mirror of
https://github.com/labring/sealos.git
synced 2026-10-28 02:27:18 +08:00
feat(terminal):auto switch namespace (#3959)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
$_salt = (kubectl.exe get secret/desktop-frontend-secret -nsealos -o json |
|
||||
ConvertFrom-Json).data.jwt_secret
|
||||
Write-Host $_salt
|
||||
$salt = ConvertFrom-Base64ToString $_salt
|
||||
Write-Host $salt
|
||||
@@ -81,13 +81,13 @@ export function CommonBillingTable({ data }: { data: BillingItem[] }) {
|
||||
minW={'max-content'}
|
||||
{...(item.type === BillingType.RECHARGE
|
||||
? {
|
||||
bg: '#E6F6F6',
|
||||
color: '#00A9A6'
|
||||
}
|
||||
bg: '#E6F6F6',
|
||||
color: '#00A9A6'
|
||||
}
|
||||
: {
|
||||
bg: '#EBF7FD',
|
||||
color: '#0884DD'
|
||||
})}
|
||||
bg: '#EBF7FD',
|
||||
color: '#0884DD'
|
||||
})}
|
||||
borderRadius="24px"
|
||||
align={'center'}
|
||||
justify={'space-evenly'}
|
||||
|
||||
@@ -1,21 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"./src/*"
|
||||
]
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx"
|
||||
],
|
||||
"include": ["next-env.d.ts", "src/**/*.ts", "src/**/*.tsx"],
|
||||
"extends": "../../tsconfig.web.json"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@ module.exports = {
|
||||
locales: ['en', 'zh'],
|
||||
localeDetection: false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,21 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"./src/*"
|
||||
]
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx"
|
||||
],
|
||||
"include": ["next-env.d.ts", "src/**/*.ts", "src/**/*.tsx"],
|
||||
"extends": "../../tsconfig.web.json"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { nanoid } from 'nanoid';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import styles from './index.module.scss';
|
||||
import useSessionStore from '@/stores/session';
|
||||
|
||||
type Terminal = {
|
||||
id: string;
|
||||
@@ -16,7 +17,7 @@ function Terminal({ url, site }: { url: string; site: string }) {
|
||||
const router = useRouter();
|
||||
const iframeRef = useRef<HTMLIFrameElement>(null);
|
||||
const { query } = router;
|
||||
|
||||
const session = useSessionStore((s) => s.session);
|
||||
const [tabContents, setTabContents] = useState<Terminal[]>([
|
||||
{
|
||||
id: tabId,
|
||||
@@ -37,7 +38,13 @@ function Terminal({ url, site }: { url: string; site: string }) {
|
||||
}
|
||||
if (e.data?.ttyd === 'ready') {
|
||||
const command = iframeRef.current?.getAttribute('data-command');
|
||||
iframeRef?.current?.contentWindow?.postMessage({ command: command }, url);
|
||||
iframeRef?.current?.contentWindow?.postMessage({ command }, url);
|
||||
iframeRef.current?.contentWindow?.postMessage(
|
||||
{
|
||||
command: `kubectl config set-context --current --namespace=${session.user.nsid}`
|
||||
},
|
||||
url
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error, 'error');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Session } from '@/interfaces/session';
|
||||
import { sessionKey } from '@/interfaces/session';
|
||||
import type { SessionV1 as Session } from 'sealos-desktop-sdk/*';
|
||||
import * as yaml from 'js-yaml';
|
||||
import { create } from 'zustand';
|
||||
import { devtools } from 'zustand/middleware';
|
||||
|
||||
Reference in New Issue
Block a user