This commit is contained in:
qingjiao 2025-03-05 19:11:22 +08:00
parent 7d6161e0a1
commit b72a47a31a
7 changed files with 145 additions and 5 deletions

View File

@ -170,3 +170,36 @@ export function deteleLog(data) {
data data
}) })
} }
// 获取网络抓包信息
export function getPacketCaptureInfo(data){
return request({
url: '/pcap/status',
method: 'get',
data
})
}
// 开始抓包
export function startPacketCapture(data){
return request({
url: '/pcap/start',
method: 'post',
data
})
}
// 停止抓包
export function stopPacketCapture(data){
return request({
url: '/pcap/stop',
method: 'post',
data
})
}
// 删除抓包文件
export function deletePacketCapture(data){
return request({
url: '/pcap/delete',
method: 'post',
data
})
}

View File

@ -79,6 +79,13 @@ export default {
toTop: 'Back to top', toTop: 'Back to top',
toBottom: 'Back to bottom', toBottom: 'Back to bottom',
clear: 'Clear Screen', clear: 'Clear Screen',
NetworkPacketCapture: 'Network packet capture',
CapturingPacket: 'Capturing packets (Max 10 MB)......',
PacketCaptureHasBeenStopped: 'Packet capture is stopped and saved as tcpdump.pcap.',
StartPacketCapture: 'Start',
StopPacketCapture: 'Stop',
Download: 'Download',
Delete: 'Delete',
refresh: 'Auto Refresh', refresh: 'Auto Refresh',
update: 'Update', update: 'Update',
choose: 'Choice', choose: 'Choice',

View File

@ -79,6 +79,13 @@ export default {
refresh: '自动刷新', refresh: '自动刷新',
choose: '选择', choose: '选择',
tips: '提示', tips: '提示',
NetworkPacketCapture: '网络抓包',
CapturingPacket: '正在抓包(最大10兆)......',
PacketCaptureHasBeenStopped: '抓包已停止保存为tcpdump.pcap。',
StartPacketCapture: '开始',
StopPacketCapture: '停止',
Download: '下载',
Delete: '删除',
factorySettings: '恢复出厂设置', factorySettings: '恢复出厂设置',
routerRestart: '重启设备', routerRestart: '重启设备',
SIPserver: 'SIP服务器', SIPserver: 'SIP服务器',

View File

@ -23,19 +23,53 @@
<!-- <el-button type="primary" style="margin-top: 48px;" @click="factorySetting"> <!-- <el-button type="primary" style="margin-top: 48px;" @click="factorySetting">
{{ $t('table.factorySettings') }} {{ $t('table.factorySettings') }}
</el-button> --> </el-button> -->
<div class="formbox">
<div class="formbox-l">{{ $t('table.NetworkPacketCapture') }}</div>
<el-button type="primary" v-if="DataDB.status === 0 || DataDB.status === 2" @click.stop="StartPacketCapture(1)">
{{ $t('table.StartPacketCapture') }}
</el-button>
<el-button type="danger" v-else @click.stop="StartPacketCapture(0)">
{{ $t('table.StopPacketCapture') }}
</el-button>
<el-button type="primary" @click.stop="DownloadFile" :disabled="DataDB.status !== 2">
{{ $t('table.Download') }}
</el-button>
<el-button type="primary" @click.stop="DeletePacketCaptureRecords" :disabled="DataDB.status !== 2">
{{ $t('table.Delete') }}
</el-button>
<span v-if="DataDB.status === 1" class="SpanBox1">
{{ $t('table.CapturingPacket') }}
</span>
<span v-else-if="DataDB.status === 2" class="SpanBox1">
{{ $t('table.PacketCaptureHasBeenStopped') }}
</span>
</div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { deviceReset, deviceReboot } from '@/api/index.js' import {
deviceReset,
deviceReboot,
getPacketCaptureInfo,
deletePacketCapture,
startPacketCapture,
stopPacketCapture
} from '@/api/index.js'
export default { export default {
name: 'FactorySetting', name: 'FactorySetting',
data() { data() {
return { return {
DataDB:{
status:0,
file:'',
}
} }
}, },
mounted() {}, mounted() {
this.getPacketInfo();
},
methods: { methods: {
factorySetting() { factorySetting() {
this.$confirm(this.$i18n.t('table.factoryTip') + this.$i18n.t('table.factorySettingsTips'), this.$i18n.t('table.tips'), { this.$confirm(this.$i18n.t('table.factoryTip') + this.$i18n.t('table.factorySettingsTips'), this.$i18n.t('table.tips'), {
@ -103,6 +137,50 @@ export default {
}).catch(() => { }).catch(() => {
}) })
},
StartPacketCapture(Flag){
if(Flag === 1){
startPacketCapture({}).then(res => {
setTimeout(()=>{
this.getPacketInfo();
}, 300);
});
}
else if(Flag === 0){
stopPacketCapture({}).then(res => {
setTimeout(()=>{
this.getPacketInfo();
}, 300);
})
}
},
getPacketInfo(){
getPacketCaptureInfo({}).then(res => {
const data = res.data;
this.DataDB.status = data.status;
this.DataDB.file = data.file;
}).catch(() => {
});
},
DeletePacketCaptureRecords(){
const data = {
name: this.DataDB.file,
};
// console.log(data);
deletePacketCapture(data).then(res => {
this.DataDB.status = 0;
this.$message.success(this.$i18n.t('table.Delete') + this.$i18n.t('table.success'))
}).catch(() => {
});
},
DownloadFile(){
if(this.DataDB.file === ''){
return;
}
const URL = '/prod-api/pcap/' + this.DataDB.file;
window.open(URL);
} }
} }
} }
@ -121,4 +199,7 @@ export default {
.toptipbox{ .toptipbox{
margin-top: 12px; margin-top: 12px;
} }
.SpanBox1{
margin-left: 10px;
}
</style> </style>

View File

@ -32,6 +32,13 @@
> >
{{ $t("table.check") }} {{ $t("table.check") }}
</el-button> </el-button>
<el-button
type="text"
size="mini"
@click="download(scope.row.name)"
>
{{ $t("table.Download") }}
</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
@ -188,7 +195,11 @@ export default {
this.rowName = '' this.rowName = ''
clearInterval(this.timer) clearInterval(this.timer)
this.timer = null this.timer = null
} },
download(name){
const URL = '/prod-api/log/download/' + name;
window.open(URL);
},
} }
} }
</script> </script>

View File

@ -133,7 +133,8 @@ export default {
this.formData.aoVol = parseInt(res.data.aoVol) || 0 this.formData.aoVol = parseInt(res.data.aoVol) || 0
this.formData.dns0 = res.data.dns0 || '' this.formData.dns0 = res.data.dns0 || ''
this.formData.dns1 = res.data.dns1 || '' this.formData.dns1 = res.data.dns1 || ''
} else { }
else {
this.$message.error(res.message) this.$message.error(res.message)
} }
}) })

View File

@ -93,7 +93,7 @@ module.exports = {
pathRewrite: { '^/dev-api': '' } pathRewrite: { '^/dev-api': '' }
}, },
'/prod-api': { '/prod-api': {
target: 'http://192.168.1.91:8080', // http://192.168.1.91:8080 target: 'http://127.0.0.1:8080', // http://192.168.1.91:8080
secure: false, // 如果是https接口需要配置这个参数 secure: false, // 如果是https接口需要配置这个参数
changeOrigin: true, // 如果接口跨域,需要进行这个参数配置 changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
pathRewrite: { '^/prod-api': '' } pathRewrite: { '^/prod-api': '' }