Commit 4d318b46 by wanglizhen

系统控制台

parent 416d32ba
import request from '@/utils/request'
/**
* 系统控制台 - 查询信息
* @param {*} data
* @returns
*/
export function command(data) {
return request({
url: '/system/console/command',
method: 'post',
data: data
})
}
/**
* 系统控制台 - 查询log
* @param {*} data
* @returns
*/
export function commandlog(data) {
return request({
url: '/system/console/commandlog',
method: 'post',
data: data
})
}
\ No newline at end of file
<script setup name="SystemConsole">
import { onMounted, ref, toRefs, onBeforeUnmount } from 'vue'
import { ElMessage } from "element-plus";
import { command, commandlog } from '@/api/systemConfig/systemConsole.js'
const enterValue = ref('') // 命令内容
const requestOptions = ref('') // 返回结果
const timeRef = ref()
// 执行命令
const handelExecute = async () => {
if (!enterValue.value) {
ElMessage.warning('请输入命令')
return false
}
const { flag } = await command({ command: enterValue.value })
if (flag) {
IntervalRequest()
} else {
ElMessage.error('命令执行失败')
}
}
const IntervalRequest = async () => {
const { flag, data } = await commandlog({})
if (flag) {
requestOptions.value = data
timeRef.value = setTimeout(() => {
IntervalRequest()
}, 5000)
} else {
timeRef.value && clearTimeout(timeRef.value)
ElMessage.error('获取命令执行结果失败')
}
}
onBeforeUnmount(() => {
timeRef.value && clearTimeout(timeRef.value)
})
</script>
<template>
<div class="app-container scroller">
<PageTitle>
<template #title>系统控制台</template>
</PageTitle>
<div class="app-container__body">
<el-form-item label="" prop="">
<div style="display: flex;width: 100%;">
<el-input v-model="enterValue" placeholder="请输入请输入命令"></el-input>
<el-button type="primary" style="width: 120px; margin-left: 10px;" @click="handelExecute()">执行</el-button>
</div>
</el-form-item>
<el-input type="textarea" v-model="requestOptions" rows="20" placeholder="返回结果..." disabled></el-input>
</div>
</div>
</template>
<style lang="scss" scoped>
.app-container__body {
:deep(.el-input__wrapper){
background: #f3f5fa;
}
}
</style>
\ No newline at end of file
++ "b/src/views/systemConfig/SystemConsole/\347\263\273\347\273\237\346\216\247\345\210\266\345\217\260.md"
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论