frp/web/frps/src/components/Traffic.vue

44 lines
881 B
Vue
Raw Normal View History

2017-03-27 02:15:31 +08:00
<template>
2020-11-23 15:26:56 +08:00
<div :id="proxyName" style="width: 600px; height: 400px" />
2017-03-27 02:15:31 +08:00
</template>
<script>
2020-11-23 15:26:56 +08:00
import { DrawProxyTrafficChart } from '../utils/chart.js'
2017-03-27 02:15:31 +08:00
export default {
2020-11-23 15:26:56 +08:00
props: {
proxyName: {
type: String,
required: true
2017-03-27 02:15:31 +08:00
}
2020-11-23 15:26:56 +08:00
},
created() {
this.fetchData()
},
// watch: {
// '$route': 'fetchData'
// },
methods: {
fetchData() {
const url = '/api/traffic/' + this.proxyName
fetch(url, { credentials: 'include' })
.then(res => {
return res.json()
})
.then(json => {
DrawProxyTrafficChart(this.proxyName, json.traffic_in, json.traffic_out)
})
.catch(err => {
this.$message({
showClose: true,
message: 'Get server info from frps failed!' + err,
type: 'warning'
})
})
}
}
2017-03-27 02:15:31 +08:00
}
</script>
<style>
</style>