Blame view

src/views/sys/error-log/data.tsx 1.47 KB
vben authored
1
2
3
import { Tag } from 'ant-design-vue';
import { BasicColumn } from '/@/components/Table/index';
import { ErrorTypeEnum } from '/@/enums/exceptionEnum';
vben authored
4
import { useI18n } from '/@/hooks/web/useI18n';
vben authored
5
6
const { t } = useI18n();
vben authored
7
vben authored
8
9
10
11
export function getColumns(): BasicColumn[] {
  return [
    {
      dataIndex: 'type',
12
      title: t('sys.errorLog.tableColumnType'),
vben authored
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
      width: 80,
      customRender: ({ text }) => {
        const color =
          text === ErrorTypeEnum.VUE
            ? 'green'
            : text === ErrorTypeEnum.RESOURCE
            ? 'cyan'
            : text === ErrorTypeEnum.PROMISE
            ? 'blue'
            : ErrorTypeEnum.AJAX
            ? 'red'
            : 'purple';
        return <Tag color={color}>{() => text}</Tag>;
      },
    },
    {
      dataIndex: 'url',
vben authored
30
      title: 'URL',
vben authored
31
32
33
34
      width: 200,
    },
    {
      dataIndex: 'time',
35
      title: t('sys.errorLog.tableColumnDate'),
vben authored
36
37
38
39
      width: 160,
    },
    {
      dataIndex: 'file',
40
      title: t('sys.errorLog.tableColumnFile'),
vben authored
41
42
43
44
45
46
47
48
49
      width: 200,
    },
    {
      dataIndex: 'name',
      title: 'Name',
      width: 200,
    },
    {
      dataIndex: 'message',
50
      title: t('sys.errorLog.tableColumnMsg'),
vben authored
51
52
53
54
      width: 300,
    },
    {
      dataIndex: 'stack',
55
      title: t('sys.errorLog.tableColumnStackMsg'),
vben authored
56
57
58
59
    },
  ];
}
Vben authored
60
export function getDescSchema(): any {
vben authored
61
62
63
64
65
66
67
  return getColumns().map((column) => {
    return {
      field: column.dataIndex!,
      label: column.title,
    };
  });
}