index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <avue-crud :data="logsList"
  3. :option="option">
  4. <template slot="menuLeft">
  5. <el-button type="primary"
  6. size="small"
  7. icon="el-icon-upload"
  8. @click="send">上传服务器</el-button>
  9. <el-button type="danger"
  10. size="small"
  11. icon="el-icon-delete"
  12. @click="clear">清空本地日志</el-button>
  13. </template>
  14. <template slot-scope="scope"
  15. slot="type">
  16. <el-tag type="danger"
  17. size="small">{{scope.label}}</el-tag>
  18. </template>
  19. <template slot-scope="props"
  20. slot="expand">
  21. <pre class="code">
  22. {{props.row.stack}}
  23. </pre>
  24. </template>
  25. </avue-crud>
  26. </template>
  27. <script>
  28. import { mapGetters } from "vuex";
  29. export default {
  30. name: "errLogs",
  31. data() {
  32. return {
  33. option: {
  34. menu: false,
  35. addBtn: false,
  36. page: false,
  37. border: true,
  38. expand: true,
  39. refreshBtn: false,
  40. headerAlign: "center",
  41. column: [
  42. {
  43. label: "类型",
  44. prop: "type",
  45. width: 80,
  46. align: "center",
  47. slot: true,
  48. dicData: [
  49. {
  50. label: "bug",
  51. value: "error"
  52. }
  53. ]
  54. },
  55. {
  56. label: "地址",
  57. width: 200,
  58. prop: "url",
  59. overHidden: true
  60. },
  61. {
  62. label: "内容",
  63. prop: "message",
  64. overHidden: true
  65. },
  66. {
  67. label: "错误堆栈",
  68. prop: "stack",
  69. hide: true
  70. },
  71. {
  72. label: "时间",
  73. align: "center",
  74. prop: "time",
  75. width: 200
  76. }
  77. ]
  78. }
  79. };
  80. },
  81. created() {},
  82. mounted() {},
  83. computed: {
  84. ...mapGetters(["logsList"])
  85. },
  86. props: [],
  87. methods: {
  88. send() {
  89. this.$confirm("确定上传本地日志到服务器?", "提示", {
  90. confirmButtonText: "确定",
  91. cancelButtonText: "取消",
  92. type: "warning"
  93. })
  94. .then(() => {
  95. this.$store.dispatch("SendLogs").then(() => {
  96. this.$parent.$parent.box = false;
  97. this.$message({
  98. type: "success",
  99. message: "发送成功!"
  100. });
  101. });
  102. })
  103. .catch(() => {});
  104. },
  105. clear() {
  106. this.$confirm("确定清空本地日志记录?", "提示", {
  107. confirmButtonText: "确定",
  108. cancelButtonText: "取消",
  109. type: "warning"
  110. })
  111. .then(() => {
  112. this.$store.commit("CLEAR_LOGS");
  113. window.console.log(this);
  114. this.$parent.$parent.box = false;
  115. this.$message({
  116. type: "success",
  117. message: "清空成功!"
  118. });
  119. })
  120. .catch(() => {});
  121. }
  122. }
  123. };
  124. </script>
  125. <style lang="scss" scoped>
  126. .code {
  127. font-size: 12px;
  128. display: block;
  129. font-family: monospace;
  130. white-space: pre;
  131. margin: 1em 0px;
  132. }
  133. </style>