yangys
2025-05-27 81060ec4cc3ead9080d4bdb3875920e257583de4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<template>
  <span @click="logsFlag ? '' : handleOpen()">
    <el-badge :value="logsFlag ? '' : logsLen" :max="99">
      <i class="icon-rizhi1"></i>
    </el-badge>
    <el-dialog title="日志" v-model="box" width="60%" append-to-body>
      <el-button type="primary" icon="el-icon-upload" @click="send">上传服务器</el-button>
      <el-button type="danger" icon="el-icon-delete" @click="clear">清空本地日志</el-button>
      <el-table :data="logsList">
        <el-table-column prop="type" label="类型" width="50px"> </el-table-column>
        <el-table-column prop="url" label="地址" show-overflow-tooltip width="180">
        </el-table-column>
        <el-table-column prop="message" show-overflow-tooltip label="内容"> </el-table-column>
        <el-table-column prop="stack" show-overflow-tooltip label="错误堆栈"> </el-table-column>
        <el-table-column prop="time" label="时间"> </el-table-column>
      </el-table>
    </el-dialog>
  </span>
</template>
 
<script>
import { mapGetters } from 'vuex';
 
export default {
  name: 'top-logs',
  data() {
    return {
      box: false,
    };
  },
  created() {},
  mounted() {},
  computed: {
    ...mapGetters(['logsList', 'logsFlag', 'logsLen']),
  },
  props: [],
  methods: {
    handleOpen() {
      this.box = true;
    },
    send() {
      this.$confirm('确定上传本地日志到服务器?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          this.$store.dispatch('SendLogs').then(() => {
            this.box = false;
            this.$message({
              type: 'success',
              message: '发送成功!',
            });
          });
        })
        .catch(() => {});
    },
    clear() {
      this.$confirm('确定清空本地日志记录?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          this.$store.commit('CLEAR_LOGS');
          this.box = false;
          this.$message({
            type: 'success',
            message: '清空成功!',
          });
        })
        .catch(() => {});
    },
  },
};
</script>
 
<style lang="scss" scoped>
.code {
  font-size: 12px;
  display: block;
  font-family: monospace;
  white-space: pre;
  margin: 1em 0px;
}
</style>