Traffic.vue 942 B

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <div :id="proxy_name" style="width: 600px;height:400px;"></div>
  3. </template>
  4. <script>
  5. import {DrawProxyTrafficChart} from '../utils/chart.js'
  6. export default {
  7. props: ['proxy_name'],
  8. created() {
  9. this.fetchData()
  10. },
  11. //watch: {
  12. //'$route': 'fetchData'
  13. //},
  14. methods: {
  15. fetchData() {
  16. let url = '/api/proxy/traffic/' + this.proxy_name
  17. fetch(url, {credentials: 'include'})
  18. .then(res => {
  19. return res.json()
  20. }).then(json => {
  21. DrawProxyTrafficChart(this.proxy_name, json.traffic_in, json.traffic_out)
  22. }).catch( err => {
  23. this.$message({
  24. showClose: true,
  25. message: 'Get server info from frps failed!' + err,
  26. type: 'warning'
  27. })
  28. })
  29. }
  30. }
  31. }
  32. </script>
  33. <style>
  34. </style>