index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div v-if="errorLogs.length > 0">
  3. <el-badge :value="errorLogs.length" @click.native="dialogTableVisible = true">
  4. <el-button type="danger">
  5. <vab-icon :icon="['fas', 'bug']" />
  6. </el-button>
  7. </el-badge>
  8. <el-dialog :visible.sync="dialogTableVisible" append-to-body title="轻马智能体异常捕获(温馨提示:错误必须解决)" width="70%">
  9. <el-table :data="errorLogs">
  10. <el-table-column label="报错路由">
  11. <template slot-scope="{ row }">
  12. <a :href="row.url" target="_blank">
  13. <el-tag type="success">{{ row.url }}</el-tag>
  14. </a>
  15. </template>
  16. </el-table-column>
  17. <el-table-column label="错误信息">
  18. <template slot-scope="{ row }">
  19. <el-tag type="danger">{{ decodeUnicode(row.err.message) }}</el-tag>
  20. </template>
  21. </el-table-column>
  22. <el-table-column label="错误详情" width="120">
  23. <template slot-scope="scope">
  24. <el-popover placement="top-start" trigger="hover">
  25. <div style="color: red">
  26. {{ scope.row.err.stack }}
  27. </div>
  28. <el-button slot="reference">查看</el-button>
  29. </el-popover>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="操作" width="380">
  33. <template slot-scope="{ row }">
  34. <a v-for="(item, index) in searchList" :key="index" :href="item.url + decodeUnicode(row.err.message)"
  35. target="_blank">
  36. <el-button style="margin-left: 5px" type="primary">
  37. <vab-icon :icon="['fas', 'search']" />
  38. {{ item.title }}
  39. </el-button>
  40. </a>
  41. </template>
  42. </el-table-column>
  43. </el-table>
  44. <span slot="footer" class="dialog-footer">
  45. <el-button @click="dialogTableVisible = false">取 消</el-button>
  46. <el-button icon="el-icon-delete" type="danger" @click="clearAll">
  47. 暂不显示
  48. </el-button>
  49. </span>
  50. </el-dialog>
  51. </div>
  52. </template>
  53. <script>
  54. import { abbreviation, title } from '@/config'
  55. import { mapGetters } from 'vuex'
  56. export default {
  57. name: 'VabErrorLog',
  58. data() {
  59. return {
  60. dialogTableVisible: false,
  61. title: title,
  62. abbreviation: abbreviation,
  63. searchList: [
  64. {
  65. title: '百度搜索',
  66. url: 'https://www.baidu.com/baidu?wd=',
  67. },
  68. {
  69. title: '谷歌搜索',
  70. url: 'https://www.google.com/search?q=',
  71. },
  72. {
  73. title: 'Magi搜索',
  74. url: 'https://magi.com/search?q=',
  75. },
  76. ],
  77. }
  78. },
  79. computed: {
  80. ...mapGetters({
  81. errorLogs: 'errorLog/errorLogs',
  82. }),
  83. },
  84. methods: {
  85. clearAll() {
  86. this.dialogTableVisible = false
  87. this.$store.dispatch('errorLog/clearErrorLog')
  88. },
  89. decodeUnicode(str) {
  90. str = str.replace(/\\/g, '%')
  91. str = unescape(str)
  92. str = str.replace(/%/g, '\\')
  93. str = str.replace(/\\/g, '')
  94. return str
  95. },
  96. },
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. ::v-deep {
  101. .el-badge {
  102. .el-button {
  103. display: flex;
  104. align-items: center;
  105. justify-items: center;
  106. height: 28px;
  107. }
  108. }
  109. }
  110. </style>