🔨 优化前端逻辑.

This commit is contained in:
lijiahangmax
2025-04-02 13:33:21 +08:00
parent 10624b42c4
commit cdc3c88507
8 changed files with 17 additions and 17 deletions

View File

@@ -75,7 +75,7 @@ export interface LogAppenderConfig {
// appender 视口 // appender 视口
export interface LogAppenderView { export interface LogAppenderView {
id: number; id: number;
el: HTMLElement; viewport: HTMLElement;
opened: boolean; opened: boolean;
openSearch: () => {}; openSearch: () => {};
terminal: Terminal; terminal: Terminal;

View File

@@ -59,7 +59,7 @@ export default class LogAppender implements ILogAppender {
// 初始化插件 // 初始化插件
const addons = this.initAddons(terminal); const addons = this.initAddons(terminal);
// 打开终端 // 打开终端
terminal.open(config.el); terminal.open(config.viewport);
// 自适应 // 自适应
addons.fit.fit(); addons.fit.fit();
this.appenderViews[config.id] = { this.appenderViews[config.id] = {

View File

@@ -105,7 +105,7 @@
<!-- 日志面板 --> <!-- 日志面板 -->
<div class="log-wrapper"> <div class="log-wrapper">
<!-- terminal --> <!-- terminal -->
<div class="log-appender" ref="appenderRef" /> <div class="log-viewport" ref="viewport" />
<!-- 搜索框 --> <!-- 搜索框 -->
<xterm-search-modal ref="searchRef" <xterm-search-modal ref="searchRef"
class="search-modal" class="search-modal"
@@ -187,7 +187,7 @@
const { getDictValue } = useDictStore(); const { getDictValue } = useDictStore();
const appenderRef = ref(); const viewport = ref();
const searchRef = ref(); const searchRef = ref();
// 打开搜索 // 打开搜索
@@ -197,7 +197,7 @@
defineExpose({ defineExpose({
id: props.host.id, id: props.host.id,
appenderRef, viewport,
openSearch openSearch
}); });
@@ -265,7 +265,7 @@
background: #1C1C1C; background: #1C1C1C;
padding: 4px 0 4px 4px; padding: 4px 0 4px 4px;
.log-appender { .log-viewport {
width: 100%; width: 100%;
height: 100%; height: 100%;

View File

@@ -70,7 +70,7 @@
nextTick(() => { nextTick(() => {
logRefs.value.push({ logRefs.value.push({
id: ref.id, id: ref.id,
el: ref.appenderRef, viewport: ref.viewport,
opened: false, opened: false,
openSearch: ref.openSearch, openSearch: ref.openSearch,
} as LogAppenderView); } as LogAppenderView);

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class="terminal-example" ref="terminalRef" /> <div class="terminal-example" ref="viewport" />
</template> </template>
<script lang="ts"> <script lang="ts">
@@ -17,7 +17,7 @@
schema: TerminalThemeSchema | Record<string, any>; schema: TerminalThemeSchema | Record<string, any>;
}>(); }>();
const terminalRef = ref(); const viewport = ref();
const term = ref(); const term = ref();
onMounted(() => { onMounted(() => {
@@ -28,7 +28,7 @@
fontSize: 15, fontSize: 15,
cursorInactiveStyle: 'none', cursorInactiveStyle: 'none',
}); });
terminal.open(terminalRef.value); terminal.open(viewport.value);
terminal.write( terminal.write(
'[root@OrionServer usr]#\r\n' + '[root@OrionServer usr]#\r\n' +
'dr-xr-xr-x. 2 root root bin\r\n' + 'dr-xr-xr-x. 2 root root bin\r\n' +

View File

@@ -11,7 +11,7 @@
<div class="ssh-wrapper" <div class="ssh-wrapper"
:style="{ background: preference.theme.schema.background }"> :style="{ background: preference.theme.schema.background }">
<!-- 终端实例 --> <!-- 终端实例 -->
<div class="ssh-inst" ref="terminalRef" /> <div class="ssh-viewport" ref="viewport" />
<!-- 搜索模态框 --> <!-- 搜索模态框 -->
<xterm-search-modal ref="searchModal" <xterm-search-modal ref="searchModal"
class="search-modal" class="search-modal"
@@ -59,7 +59,7 @@
const editorModal = ref(); const editorModal = ref();
const searchModal = ref(); const searchModal = ref();
const uploadModal = ref(); const uploadModal = ref();
const terminalRef = ref(); const viewport = ref();
const session = ref<ISshSession>(); const session = ref<ISshSession>();
// 发送命令 // 发送命令
@@ -88,7 +88,7 @@
onMounted(async () => { onMounted(async () => {
// 创建终端处理器 // 创建终端处理器
session.value = await sessionManager.openSsh(props.tab, { session.value = await sessionManager.openSsh(props.tab, {
el: terminalRef.value, viewport: viewport.value,
editorModal: editorModal.value, editorModal: editorModal.value,
searchModal: searchModal.value, searchModal: searchModal.value,
uploadModal: uploadModal.value, uploadModal: uploadModal.value,
@@ -117,7 +117,7 @@
position: relative; position: relative;
padding: 8px 4px 4px 8px; padding: 8px 4px 4px 8px;
.ssh-inst { .ssh-viewport {
width: 100%; width: 100%;
height: 100%; height: 100%;

View File

@@ -65,11 +65,11 @@ export default class SshSession extends BaseSession<TerminalStatus> implements I
// 注册快捷键 // 注册快捷键
this.registerShortcut(preference); this.registerShortcut(preference);
// 注册事件 // 注册事件
this.registerEvent(domRef.el, preference); this.registerEvent(domRef.viewport, preference);
// 注册插件 // 注册插件
this.registerAddons(preference); this.registerAddons(preference);
// 打开终端 // 打开终端
this.inst.open(domRef.el); this.inst.open(domRef.viewport);
// 自适应 // 自适应
this.addons.fit.fit(); this.addons.fit.fit();
} }

View File

@@ -176,7 +176,7 @@ export interface ITerminalOutputProcessor {
// xterm dom 元素引用 // xterm dom 元素引用
export interface XtermDomRef { export interface XtermDomRef {
el: HTMLElement; viewport: HTMLElement;
searchModal: any; searchModal: any;
editorModal: any; editorModal: any;
uploadModal: any; uploadModal: any;