|
|
@@ -0,0 +1,61 @@
|
|
|
+<template>
|
|
|
+ <div class="ssh">
|
|
|
+ <!-- <div
|
|
|
+ v-for="(item, index) in data"
|
|
|
+ :key="index"
|
|
|
+ v-html="item"
|
|
|
+ /> -->
|
|
|
+ <textarea
|
|
|
+ v-model="data"
|
|
|
+ style="width: 100%;height: 100%;"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang='ts'>
|
|
|
+import { onMounted, ref } from 'vue'
|
|
|
+
|
|
|
+const data = ref('')
|
|
|
+const conn = ref()
|
|
|
+
|
|
|
+function newClient(option: { host: string, port: number, username: string, password: string }) {
|
|
|
+ const conn = window.$ssh
|
|
|
+ conn.on('ready', () => {
|
|
|
+ console.log('Client :: ready')
|
|
|
+ conn.shell((err: string, stream: any) => {
|
|
|
+ if (err) throw err
|
|
|
+
|
|
|
+ stream.on('close', () => {
|
|
|
+ console.log('Stream :: close')
|
|
|
+ conn.end()
|
|
|
+ })
|
|
|
+
|
|
|
+ stream.on('data', (db: string) => {
|
|
|
+ console.log(`OUTPUT: ${db}`)
|
|
|
+ const a = JSON.stringify(db)
|
|
|
+ data.value += db
|
|
|
+ })
|
|
|
+
|
|
|
+ stream.end('ls -l\nexit\n')
|
|
|
+ })
|
|
|
+ })
|
|
|
+ conn.connect({ ...option })
|
|
|
+ return conn
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ conn.value = newClient({
|
|
|
+ host: 'caner.top', port: 49657, username: 'root', password: 'dongdong0707'
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.ssh {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background: black;
|
|
|
+ color: white;
|
|
|
+ font-size: 12px;
|
|
|
+}
|
|
|
+</style>
|