mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-01-13 18:44:14 +08:00
parent
98d01556c2
commit
58c994a3e2
1 changed files with 29 additions and 1 deletions
|
|
@ -8,7 +8,20 @@
|
|||
: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>
|
||||
|
|
@ -16,16 +29,21 @@
|
|||
<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);
|
||||
};
|
||||
|
||||
|
|
@ -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();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue