Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion frontend/src/views/host/file-management/terminal/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,42 @@
:fullScreen="true"
>
<template #content>
<Terminal style="height: calc(100vh - 100px)" ref="terminalRef"></Terminal>
<Terminal style="height: calc(100vh - 120px)" ref="terminalRef"></Terminal>
<div>
<el-select v-model="quickCmd" clearable filterable @change="quickInput" class="w-full -mt-6">
<template #prefix>{{ $t('terminal.quickCommand') }}</template>
<el-option-group v-for="group in commandTree" :key="group.label" :label="group.label">
<el-option
v-for="(cmd, index) in group.children"
:key="index"
:label="cmd.name"
:value="cmd.command"
/>
</el-option-group>
</el-select>
</div>
</template>
</DrawerPro>
</template>

<script lang="ts" setup>
import { ref, nextTick } from 'vue';
import Terminal from '@/components/terminal/index.vue';
import { getCommandTree } from '@/api/modules/command';

const terminalVisible = ref(false);
const terminalRef = ref<InstanceType<typeof Terminal> | null>(null);

let quickCmd = ref();
const commandTree = ref();

interface DialogProps {
cwd: string;
command: string;
}
const acceptParams = async (params: DialogProps): Promise<void> => {
terminalVisible.value = true;
loadCommandTree();
await initTerm(params.cwd);
};

Expand All @@ -39,6 +57,16 @@ const initTerm = async (cwd: string) => {
});
};

const loadCommandTree = async () => {
const res = await getCommandTree('command');
commandTree.value = res.data || [];
};

function quickInput(val: any) {
terminalRef.value?.sendMsg(val + '\n');
quickCmd.value = '';
}

const onClose = () => {
terminalRef.value?.onClose();
};
Expand Down
Loading