mirror of
https://github.com/chaos-zhu/easynode.git
synced 2026-06-21 17:54:31 +08:00
feat: 统一执行外部脚本方法
This commit is contained in:
@@ -33,7 +33,7 @@ const props = defineProps({
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['resize', 'exec-command', 'height-change',])
|
||||
const emit = defineEmits(['resize', 'exec-script', 'height-change',])
|
||||
|
||||
// 拖拽相关状态
|
||||
const isResizing = ref(false)
|
||||
@@ -73,7 +73,7 @@ const stopResize = () => {
|
||||
}
|
||||
|
||||
const execCommand = (command) => {
|
||||
emit('exec-command', command, 'script')
|
||||
emit('exec-script', command)
|
||||
}
|
||||
|
||||
// 清理事件监听
|
||||
|
||||
@@ -542,7 +542,7 @@ import { useContextMenu } from '@/composables/useContextMenu'
|
||||
import TextEditor from '@/components/text-editor/index.vue'
|
||||
import ImagePreview from '@/components/image-preview/index.vue'
|
||||
|
||||
const emit = defineEmits(['exec-command', ])
|
||||
const emit = defineEmits(['exec-script', ])
|
||||
|
||||
const props = defineProps({
|
||||
hostId: {
|
||||
@@ -1594,7 +1594,7 @@ const onRowContextMenu = (row, _column, event) => {
|
||||
items.push({
|
||||
label: '发送cd指令到终端',
|
||||
onClick: () => {
|
||||
emit('exec-command', cdCommand, 'script')
|
||||
emit('exec-script', cdCommand)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -333,13 +333,13 @@
|
||||
>
|
||||
<SftpV2
|
||||
:host-id="item.id"
|
||||
@exec-command="handleInputCommand"
|
||||
@exec-script="handleExecScript"
|
||||
/>
|
||||
</el-drawer>
|
||||
<div v-else :class="['tab_content_main_sftp', { 'show_sftp': showSftpSide }]">
|
||||
<SftpV2
|
||||
:host-id="item.id"
|
||||
@exec-command="handleInputCommand"
|
||||
@exec-script="handleExecScript"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -352,7 +352,7 @@
|
||||
:show="showFooterBar"
|
||||
:height="footerBarHeight"
|
||||
@resize="resizeTerminal"
|
||||
@exec-command="handleInputCommand"
|
||||
@exec-script="handleExecScript"
|
||||
@height-change="handleFooterBarHeightChange"
|
||||
/>
|
||||
</div>
|
||||
@@ -698,13 +698,19 @@ const handleLinkHost = (hostDescObj) => {
|
||||
}, 100)
|
||||
}
|
||||
|
||||
// scriptDescObj: 脚本库对象或脚本命令
|
||||
const handleExecScript = async (scriptDescObj) => {
|
||||
if (!scriptDescObj) return // clearCheckedNodes二次触发change事件
|
||||
const id = Array.isArray(scriptDescObj) ? scriptDescObj.slice(-1)[0] : scriptDescObj.id
|
||||
const script = scriptList.value.find((item) => item.id === id)
|
||||
if (!script) return $message.warning('未找到对应的脚本')
|
||||
let command = ''
|
||||
const id = Array.isArray(scriptDescObj) ? scriptDescObj.slice(-1)[0] : scriptDescObj?.id
|
||||
if (id) {
|
||||
const script = scriptList.value.find((item) => item.id === id)
|
||||
command = script?.command
|
||||
} else {
|
||||
command = scriptDescObj
|
||||
}
|
||||
if (!command) return $message.warning('未找到对应的脚本')
|
||||
|
||||
const command = script.command
|
||||
if (!isSyncAllSession.value) {
|
||||
// 不同步时,使用 handleInputCommand(会处理分屏同步)
|
||||
await handleInputCommand(command, 'script')
|
||||
|
||||
@@ -300,7 +300,10 @@ const createLocalTerminal = () => {
|
||||
!isMobileScreen.value && terminalInstance.loadAddon(canvasAddon)
|
||||
terminalInstance.writeln('\x1b[1;32mWelcome to EasyNode terminal\x1b[0m.')
|
||||
terminalInstance.writeln('\x1b[1;32mAn experimental Web-SSH Terminal\x1b[0m.')
|
||||
if (props.autoFocus) terminalInstance.focus()
|
||||
if (props.autoFocus) {
|
||||
terminalInstance.focus()
|
||||
emit('tab-focus', uid)
|
||||
}
|
||||
onFindText()
|
||||
onWebLinks()
|
||||
onResize()
|
||||
@@ -668,6 +671,7 @@ const focusTab = () => {
|
||||
term.value.blur()
|
||||
setTimeout(() => {
|
||||
term.value.focus()
|
||||
emit('tab-focus', uid)
|
||||
}, 200)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user