log.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <el-container>
  3. <el-header class="header">
  4. <h3>{{ title }}</h3>
  5. </el-header>
  6. <el-main class="main">
  7. <div class="btnbox">
  8. <el-button type="primary" @click="logdw">下载日志</el-button>
  9. <el-button type="primary" @click="query">刷新日志</el-button>
  10. </div>
  11. <div class="per">{{ logdata }}</div>
  12. </el-main>
  13. </el-container>
  14. </template>
  15. <script>
  16. import { mapActions, mapState } from 'vuex'
  17. export default {
  18. name: 'log',
  19. components: {},
  20. data () {
  21. return {
  22. title: null,
  23. type: null
  24. }
  25. },
  26. computed: {
  27. ...mapState(['logdata'])
  28. },
  29. mounted () {
  30. const type = this.$route.params.type
  31. this.parms(type)
  32. },
  33. methods: {
  34. ...mapActions(['logquery']),
  35. logdw () {
  36. window.open(`/api/logdownload?type=${this.type}`)
  37. },
  38. async query () {
  39. await this.logquery({ type: this.type })
  40. },
  41. parms (type) {
  42. switch (type) {
  43. case 'system':
  44. this.title = '系统日志'
  45. this.type = 'systemct'
  46. break
  47. case 'sslvpn':
  48. this.title = 'SSLVPN日志'
  49. this.type = 'ssl'
  50. break
  51. case 'ipsecvpn':
  52. this.title = 'IPSecVPN日志'
  53. this.type = 'sec'
  54. break
  55. }
  56. this.query()
  57. }
  58. },
  59. watch: {
  60. $route: {
  61. handler () {
  62. const type = this.$route.params.type
  63. this.parms(type)
  64. },
  65. deep: true
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="less" scoped>
  71. h3 {
  72. width: 90%;
  73. text-align: left;
  74. text-indent: 1em;
  75. line-height: 3em;
  76. border-bottom: 2px solid #999;
  77. }
  78. .main {
  79. width: 70%;
  80. margin: 0 auto;
  81. .per {
  82. width: 100%;
  83. height: 85%;
  84. margin: 0 auto;
  85. border: 1px solid #999;
  86. overflow-y: auto;
  87. }
  88. .btnbox {
  89. margin: 2% 0;
  90. width: 100%;
  91. overflow: hidden;
  92. .el-button {
  93. float: right;
  94. margin-left: 2%;
  95. }
  96. }
  97. }
  98. </style>