mirror of
https://github.com/chaos-zhu/easynode.git
synced 2026-06-20 16:56:05 +08:00
feat: 右键添加重新连接
This commit is contained in:
@@ -16,20 +16,16 @@
|
||||
:show-message="false"
|
||||
>
|
||||
<el-form-item label="自动重连" prop="autoReconnect">
|
||||
<PlusSupportTip>
|
||||
<span>
|
||||
<el-switch
|
||||
v-model="autoReconnect"
|
||||
class="switch"
|
||||
inline-prompt
|
||||
:disabled="!isPlusActive"
|
||||
style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
|
||||
active-text="开启"
|
||||
inactive-text="关闭"
|
||||
/>
|
||||
<span class="plus_support_tip_text">(Plus专属功能)</span>
|
||||
</span>
|
||||
</PlusSupportTip>
|
||||
<span>
|
||||
<el-switch
|
||||
v-model="autoReconnect"
|
||||
class="switch"
|
||||
inline-prompt
|
||||
style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
|
||||
active-text="开启"
|
||||
inactive-text="关闭"
|
||||
/>
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="脚本执行" prop="autoExecuteScript">
|
||||
<el-tooltip
|
||||
@@ -75,7 +71,6 @@
|
||||
<script setup>
|
||||
import { computed, getCurrentInstance } from 'vue'
|
||||
import useMobileWidth from '@/composables/useMobileWidth'
|
||||
import PlusSupportTip from '@/components/common/PlusSupportTip.vue'
|
||||
|
||||
const { proxy: { $store } } = getCurrentInstance()
|
||||
const { isMobileScreen } = useMobileWidth()
|
||||
@@ -87,7 +82,7 @@ const props = defineProps({
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:show'])
|
||||
const emit = defineEmits(['update:show',])
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.show,
|
||||
@@ -109,7 +104,6 @@ const autoShowContextMenu = computed({
|
||||
set: (newVal) => $store.setTerminalSetting({ autoShowContextMenu: newVal })
|
||||
})
|
||||
|
||||
const isPlusActive = computed(() => $store.isPlusActive)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -125,8 +119,4 @@ const isPlusActive = computed(() => $store.isPlusActive)
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
}
|
||||
.plus_support_tip_text {
|
||||
margin-left: 5px;
|
||||
color: var(--el-text-color-placeholder);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -335,14 +335,14 @@ const reconnectTerminal = (isCommonTips = false, tips) => {
|
||||
socket.value = null
|
||||
socketConnected.value = false
|
||||
if (isCommonTips) {
|
||||
if (isPlusActive.value && autoReconnect.value) {
|
||||
if (autoReconnect.value) {
|
||||
term.value.write(`\r\n\x1b[91m${ tips },自动重连中...\x1b[0m \r\n`)
|
||||
connectIO()
|
||||
} else {
|
||||
term.value.write(`\r\n\x1b[91mError: ${ tips },请重新连接。([终端设置->其他设置]中开启自动重连)\x1b[0m \r\n`)
|
||||
}
|
||||
} else {
|
||||
term.value.write(`\n${ tips } \n`)
|
||||
term.value.write(`\r\n\x1b[91m${ tips }\x1b[0m \r\n`)
|
||||
connectIO()
|
||||
}
|
||||
}
|
||||
@@ -633,6 +633,14 @@ const handleRightClick = async (e) => {
|
||||
handleClear()
|
||||
}
|
||||
}
|
||||
const reconnect = {
|
||||
label: '重新连接',
|
||||
onClick: () => {
|
||||
reconnectTerminal(false, '重新连接中...')
|
||||
term.value.clearSelection()
|
||||
focusTab()
|
||||
}
|
||||
}
|
||||
const dockerId = isDockerId(str) ? {
|
||||
label: 'docker容器ID',
|
||||
children: [
|
||||
@@ -755,6 +763,7 @@ const handleRightClick = async (e) => {
|
||||
pasteSelection,
|
||||
search,
|
||||
clear,
|
||||
reconnect,
|
||||
dockerId,
|
||||
dockerComposeYml,
|
||||
].filter(Boolean)
|
||||
|
||||
Reference in New Issue
Block a user