⚡ 优化自动聚焦逻辑.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<a-drawer v-model:visible="visible"
|
||||
:width="388"
|
||||
:footer="false"
|
||||
@close="onClose">
|
||||
@close="emits('closed')">
|
||||
<!-- 标题 -->
|
||||
<template #title>
|
||||
<span class="snippet-drawer-title usn">
|
||||
@@ -103,7 +103,6 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { ISshSession } from '../../types/define';
|
||||
import type { CommandSnippetQueryResponse } from '@/api/asset/command-snippet';
|
||||
import type { CommandSnippetGroupQueryResponse } from '@/api/asset/command-snippet-group';
|
||||
import { ref, watch } from 'vue';
|
||||
@@ -111,14 +110,15 @@
|
||||
import useLoading from '@/hooks/loading';
|
||||
import { deleteCommandSnippet } from '@/api/asset/command-snippet';
|
||||
import { useCacheStore, useTerminalStore } from '@/store';
|
||||
import { PanelSessionType } from '../../types/const';
|
||||
import { copy } from '@/hooks/copy';
|
||||
import CommandSnippetItem from './command-snippet-item.vue';
|
||||
import CommandSnippetFormDrawer from './command-snippet-form-drawer.vue';
|
||||
|
||||
const emits = defineEmits(['closed']);
|
||||
|
||||
const { loading, setLoading } = useLoading();
|
||||
const { visible, setVisible } = useVisible();
|
||||
const { getCurrentSession, appendCommandToCurrentSession } = useTerminalStore();
|
||||
const { appendCommandToCurrentSession } = useTerminalStore();
|
||||
|
||||
const cacheStore = useCacheStore();
|
||||
|
||||
@@ -297,12 +297,6 @@
|
||||
filterSnippet();
|
||||
};
|
||||
|
||||
// 关闭回调
|
||||
const onClose = () => {
|
||||
// 关闭时候如果打开的是终端 则聚焦终端
|
||||
getCurrentSession<ISshSession>(PanelSessionType.SSH.type)?.focus();
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<a-drawer v-model:visible="visible"
|
||||
:width="388"
|
||||
:footer="false"
|
||||
@close="onClose">
|
||||
@close="emits('closed')">
|
||||
<!-- 标题 -->
|
||||
<template #title>
|
||||
<span class="path-drawer-title usn">
|
||||
@@ -105,7 +105,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { ISftpSession, ISshSession } from '../../types/define';
|
||||
import type { ISftpSession } from '../../types/define';
|
||||
import type { PathBookmarkQueryResponse } from '@/api/asset/path-bookmark';
|
||||
import type { PathBookmarkGroupQueryResponse } from '@/api/asset/path-bookmark-group';
|
||||
import { ref, watch } from 'vue';
|
||||
@@ -118,6 +118,8 @@
|
||||
import PathBookmarkItem from './path-bookmark-item.vue';
|
||||
import PathBookmarkFormDrawer from './path-bookmark-form-drawer.vue';
|
||||
|
||||
const emits = defineEmits(['closed']);
|
||||
|
||||
const { loading, setLoading } = useLoading();
|
||||
const { visible, setVisible } = useVisible();
|
||||
const { getCurrentSession, appendCommandToCurrentSession } = useTerminalStore();
|
||||
@@ -302,12 +304,6 @@
|
||||
filterPath();
|
||||
};
|
||||
|
||||
// 关闭回调
|
||||
const onClose = () => {
|
||||
// 关闭时候如果打开的是终端 则聚焦终端
|
||||
getCurrentSession<ISshSession>(PanelSessionType.SSH.type)?.focus();
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@@ -86,6 +86,8 @@
|
||||
import { getFileSize } from '@/utils/file';
|
||||
import useVisible from '@/hooks/visible';
|
||||
|
||||
const emits = defineEmits(['closed']);
|
||||
|
||||
const { visible, setVisible } = useVisible();
|
||||
const { transferManager } = useTerminalStore();
|
||||
|
||||
@@ -130,6 +132,7 @@
|
||||
// 清空
|
||||
const handlerClear = () => {
|
||||
fileList.value = [];
|
||||
emits('closed');
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
class="search-modal"
|
||||
@find="findWords"
|
||||
@close="focus" />
|
||||
<!-- 上传文件模态框 -->
|
||||
<sftp-upload-modal ref="uploadModal" @closed="focus" />
|
||||
</div>
|
||||
</ssh-context-menu>
|
||||
<!-- 命令编辑器 -->
|
||||
@@ -76,6 +78,7 @@
|
||||
import ShellEditorModal from '@/components/view/shell-editor/modal/index.vue';
|
||||
import IconActions from '../layout/icon-actions.vue';
|
||||
import SshContextMenu from './ssh-context-menu.vue';
|
||||
import SftpUploadModal from '../sftp/sftp-upload-modal.vue';
|
||||
import XtermSearchModal from '@/components/xtrem/search-modal/index.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -87,6 +90,7 @@
|
||||
|
||||
const editorModal = ref();
|
||||
const searchModal = ref();
|
||||
const uploadModal = ref();
|
||||
const commandInput = ref();
|
||||
const terminalRef = ref();
|
||||
const session = ref<ISshSession>();
|
||||
@@ -141,7 +145,8 @@
|
||||
session.value = await sessionManager.openSsh(props.tab, {
|
||||
el: terminalRef.value,
|
||||
editorModal: editorModal.value,
|
||||
searchModal: searchModal.value
|
||||
searchModal: searchModal.value,
|
||||
uploadModal: uploadModal.value,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
class="transfer-drawer"
|
||||
:width="388"
|
||||
:unmount-on-close="false"
|
||||
:footer="false">
|
||||
:footer="false"
|
||||
@close="emits('closed')">
|
||||
<!-- 标题 -->
|
||||
<template #title>
|
||||
<span class="path-drawer-title usn">
|
||||
@@ -76,6 +77,8 @@
|
||||
import { transferStatusKey } from '../../types/const';
|
||||
import TransferItem from './transfer-item.vue';
|
||||
|
||||
const emits = defineEmits(['closed']);
|
||||
|
||||
const { transferManager } = useTerminalStore();
|
||||
const { toOptions } = useDictStore();
|
||||
const { visible, setVisible } = useVisible();
|
||||
@@ -110,16 +113,6 @@
|
||||
transferManager.cancelAllTransfer();
|
||||
};
|
||||
|
||||
// 关闭
|
||||
const handleClose = () => {
|
||||
handlerClear();
|
||||
};
|
||||
|
||||
// 清空
|
||||
const handlerClear = () => {
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
|
||||
@@ -89,6 +89,7 @@ export default class SshSessionHandler implements ISshSessionHandler {
|
||||
case 'enter':
|
||||
case 'commandEditor':
|
||||
case 'openSftp':
|
||||
case 'uploadFile':
|
||||
case 'checkAppendMissing':
|
||||
return this.session.canWrite;
|
||||
case 'disconnect':
|
||||
@@ -217,6 +218,11 @@ export default class SshSessionHandler implements ISshSessionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// 上传文件
|
||||
uploadFile(): void {
|
||||
this.domRef.uploadModal.open(this.session.hostId, '/');
|
||||
}
|
||||
|
||||
// ctrl + c
|
||||
interrupt() {
|
||||
this.inst.paste(String.fromCharCode(3));
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
</div>
|
||||
</main>
|
||||
<!-- 命令片段列表抽屉 -->
|
||||
<command-snippet-drawer ref="snippetRef" />
|
||||
<command-snippet-drawer ref="snippetRef" @closed="autoFocus" />
|
||||
<!-- 路径书签列表抽屉 -->
|
||||
<path-bookmark-drawer ref="pathRef" />
|
||||
<path-bookmark-drawer ref="pathRef" @closed="autoFocus" />
|
||||
<!-- 传输列表 -->
|
||||
<transfer-drawer ref="transferRef" />
|
||||
<transfer-drawer ref="transferRef" @closed="autoFocus" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -88,6 +88,11 @@
|
||||
event.returnValue = confirm('系统可能不会保存您所做的更改');
|
||||
};
|
||||
|
||||
// 自动聚焦
|
||||
const autoFocus = () => {
|
||||
getCurrentSession<ISshSession>(PanelSessionType.SSH.type)?.focus();
|
||||
};
|
||||
|
||||
// 打开默认打开页面
|
||||
onBeforeMount(() => {
|
||||
// 打开默认 tab
|
||||
|
||||
@@ -172,6 +172,10 @@ export const ActionBarItems = [
|
||||
item: 'openSftp',
|
||||
icon: 'icon-folder',
|
||||
content: '打开 SFTP',
|
||||
}, {
|
||||
item: 'uploadFile',
|
||||
icon: 'icon-upload',
|
||||
content: '上传文件',
|
||||
}, {
|
||||
item: 'clear',
|
||||
icon: 'icon-delete',
|
||||
@@ -301,6 +305,10 @@ export const TerminalShortcutItems: Array<ShortcutKeyItem> = [
|
||||
item: 'search',
|
||||
content: '搜索',
|
||||
type: TerminalShortcutType.TERMINAL
|
||||
}, {
|
||||
item: 'uploadFile',
|
||||
content: '上传文件',
|
||||
type: TerminalShortcutType.TERMINAL
|
||||
}, {
|
||||
item: 'fontSizePlus',
|
||||
content: '增大字号',
|
||||
|
||||
@@ -192,6 +192,7 @@ export interface XtermDomRef {
|
||||
el: HTMLElement;
|
||||
searchModal: any;
|
||||
editorModal: any;
|
||||
uploadModal: any;
|
||||
}
|
||||
|
||||
// 终端会话定义
|
||||
@@ -280,6 +281,8 @@ export interface ISshSessionHandler {
|
||||
commandEditor: () => void;
|
||||
// 打开 sftp
|
||||
openSftp: () => void;
|
||||
// 上传文件
|
||||
uploadFile: () => void;
|
||||
// 中断
|
||||
interrupt: () => void;
|
||||
// 回车
|
||||
|
||||
Reference in New Issue
Block a user