<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      k8s的容器的webssh實現

      Vite2.x + Vue3.x + Xtermjs4

      相關信息

      安裝依賴

      npm install
      # or
      yarn add
      

      啟動項目

      npm run dev
      

      項目打包

      npm run build
      

      功能完成

      2021/6/8

      具體代碼在:https://github.com/haozheyu/k8sResourceDisplay
      排坑不易,大家給給?※?,好讓我在排坑的路上樂此不疲

      <template>
        <div ref="terminal" id="terminal"></div>
      </template>
      
      <script>
      
      import {defineComponent, reactive, toRefs, onMounted, ref, markRaw, onBeforeUnmount, onUnmounted} from 'vue'
      import { useRouter } from 'vue-router'
      import { Terminal } from 'xterm';
      import { FitAddon  } from 'xterm-addon-fit';
      import 'xterm/css/xterm.css'
      import { ElMessage } from 'element-plus'
      
      export default defineComponent({
        name: 'Xterm',
        setup(){
          //實例化路由
          const shellWs = ref(null)
          const rows = ref(null)
          const cols = ref(null)
      
          const term = new Terminal({
            rendererType: 'canvas',
            cursorBlink: true,
            convertEol: true,
            scrollback: 800,
            row: 70,
            theme: {
              foreground: 'white',
              background: '#181E29'
            }
          })
          const fitAddon = new FitAddon();
          // canvas背景全屏
          term.loadAddon(fitAddon);
          fitAddon.fit();
          const router = useRouter();
          const podName = router.currentRoute.value.query.podName
          const podNamespace = router.currentRoute.value.query.podNamespace
          const containerName = router.currentRoute.value.query.containerName
          const SHELL = router.currentRoute.value.query.shell
          const querystring = "ws://localhost:8080/resource/websocket?" + "podNs="+ podNamespace + "&podName=" + podName + "&containerName=" + containerName + "&shell=" + SHELL
          const ws = new WebSocket(querystring)
          onMounted(()=>{
            term.open(document.getElementById('terminal'));  //綁定dom節點
            term.focus() // 取得輸入焦點
            term.writeln('Connecting...');  // 寫一行測試
            ws.onclose = function (e) {
              ElMessage.warning({
                message: '鏈接已關閉',
                type: 'warning',
                center: true,
              });
            }
            ws.onmessage = function (e) { // 服務端ssh輸出, 寫到web shell展示
              term.write(e.data)
            }
            ws.onerror = function (e) {
              ElMessage.error({
                message: '請更換,shell環境再試一下',
                type: 'error',
                center: true,
              });
            }
            // 當瀏覽器窗口變化時, 重新適配終端
            window.addEventListener("resize", function () {
              fitAddon.fit();
              // 把web終端的尺寸term.rows和term.cols發給服務端, 通知sshd調整輸出寬度
              var msg = {type: "resize", rows: term.rows, cols: term.cols}
              ws.send(JSON.stringify(msg))
            })
            // 當向web終端敲入字符時候的回調
            // term.onKey(e => {  //給后端發送數據
            //   // 寫給服務端, 由服務端發給container
            //   console.log(e.key)
            //   var msg = {type: "input", input: e.key }
            //   ws.send(JSON.stringify(msg))
            // })
            // 支持輸入與粘貼方法
            term.onData(function(input) {
              // 寫給服務端, 由服務端發給container
              var msg = {type: "input", input: input}
              ws.send(JSON.stringify(msg))
            })
          })
          onUnmounted(()=>{
            ws.close()
          })
          return {
            shellWs, term, rows, cols
          }
        },
      })
      </script>
      
      <style>
      
      </style>
      
      
      

      posted @ 2021-06-09 00:43  聽_風~  閱讀(551)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 久久精品女人天堂av免费观看| 国产精品日韩av在线播放| 中文字幕无码免费不卡视频 | 久久婷婷五月综合色和啪| 亚洲欧美牲交| 在线一区二区中文字幕| 久久精品蜜芽亚洲国产av| 国产伦码精品一区二区| 精品人妻av区乱码| 在线中文一区字幕对白| 亚洲欧美人成人综合在线播放 | 99国产精品白浆在线观看免费 | 超碰伊人久久大香线蕉综合| 2021亚洲国产精品无码| 免费人成视频在线观看不卡| 亚洲欧美日韩高清一区二区三区| 国产精品一区二区日韩精品| 亚洲阿v天堂网2021| 日本三级香港三级三级人!妇久| 精品久久亚洲中文无码| 日本夜爽爽一区二区三区| 亚洲精品日韩在线丰满| 国产精品一区二区av片| 中文字幕人妻中出制服诱惑| 国产中文字幕精品视频| 在线视频观看| 中文字字幕在线中文乱码| 国产精品无码不卡在线播放 | 叙永县| 中文 在线 日韩 亚洲 欧美| 精品无码黑人又粗又大又长| 大庆市| 最新国产精品好看的精品| 成人免费A级毛片无码片2022| 日韩大片高清播放器| 狠狠躁夜夜躁人人爽天天5| 日韩精品一区二区三免费| 亚洲自偷自偷在线成人网站传媒| 国产精品欧美福利久久| 国产精品美女一区二三区| 成人午夜福利免费专区无码|