refactor: 数组比较方法优化等

This commit is contained in:
meilin.huang
2024-01-13 13:38:53 +08:00
parent bfd346e65a
commit 9c524292f0
15 changed files with 72 additions and 73 deletions

View File

@@ -33,7 +33,7 @@
"splitpanes": "^3.1.5",
"sql-formatter": "^14.0.0",
"uuid": "^9.0.1",
"vue": "^3.4.10",
"vue": "^3.4.12",
"vue-router": "^4.2.5",
"xterm": "^5.3.0",
"xterm-addon-fit": "^0.8.0",
@@ -48,7 +48,7 @@
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"@vitejs/plugin-vue": "^5.0.3",
"@vue/compiler-sfc": "^3.4.8",
"@vue/compiler-sfc": "^3.4.12",
"dotenv": "^16.3.1",
"eslint": "^8.35.0",
"eslint-plugin-vue": "^9.19.2",

View File

@@ -19,6 +19,7 @@ import { ref, nextTick, reactive, onMounted, onBeforeUnmount, watch } from 'vue'
import TerminalSearch from './TerminalSearch.vue';
import { debounce } from 'lodash';
import { TerminalStatus } from './common';
import { useEventListener } from '@vueuse/core';
const props = defineProps({
/**
@@ -145,7 +146,7 @@ const onConnected = () => {
state.status = TerminalStatus.Connected;
// 注册窗口大小监听器
window.addEventListener('resize', debounce(fitTerminal, 400));
useEventListener('resize', debounce(fitTerminal, 400));
focus();
@@ -178,7 +179,7 @@ const clear = () => {
function initSocket() {
if (props.socketUrl) {
let socketUrl = `${props.socketUrl}&rows=${term.rows}&cols=${term.cols}`;
let socketUrl = `${props.socketUrl}&rows=${term?.rows}&cols=${term?.cols}`;
socket = new WebSocket(socketUrl);
}
@@ -196,8 +197,6 @@ function initSocket() {
socket.onclose = (e: CloseEvent) => {
console.log('terminal socket close...', e.reason);
// 关闭窗口大小监听器
window.removeEventListener('resize', debounce(fitTerminal, 100));
// 清除 ping
pingInterval && clearInterval(pingInterval);
state.status = TerminalStatus.Disconnected;

View File

@@ -58,7 +58,7 @@
</div>
</div>
</template>
<div class="terminal-wrapper" :style="{ height: `calc(100vh - ${openTerminal.fullscreen ? '47px' : '200px'})` }">
<div class="terminal-wrapper" :style="{ height: `calc(100vh - ${openTerminal.fullscreen ? '49px' : '200px'})` }">
<TerminalBody
@status-change="terminalStatusChange(openTerminal.terminalId, $event)"
:ref="(el) => setTerminalRef(el, openTerminal.terminalId)"