import { h } from 'vue';
import { Tag } from 'ant-design-vue';

export const columns = [
  {
    title: 'ID',
    dataIndex: 'id',
    fixed: 'left',
    width: 50,
  },
  {
    title: '日志标题',
    dataIndex: 'title',
    width: 100,
  },
  {
    title: '操作用户',
    dataIndex: 'createUser',
    width: 100,
  },
  {
    title: '请求ip',
    dataIndex: 'ip',
    width: 140,
  },
  {
    title: '浏览器',
    dataIndex: 'browser',
    width: 100,
  },
  {
    title: '操作系统',
    dataIndex: 'os',
    width: 100,
  },
  {
    title: '操作类型',
    dataIndex: 'typeText',
    width: 100,
  },
  {
    title: '操作来源',
    dataIndex: 'sourceText',
    width: 100,
  },
  {
    title: '请求方式',
    dataIndex: 'requestMethod',
    width: 100,
  },
  {
    title: '请求URL',
    dataIndex: 'url',
    width: 150,
  },
  {
    title: '请求地区',
    dataIndex: 'location',
    width: 100,
  },
  {
    title: '请求耗时',
    dataIndex: 'consumeTime',
    width: 100,
  },
  {
    title: '状态',
    dataIndex: 'status',
    customRender({ record }) {
      return h(
        Tag,
        {
          color: record.status == 0 ? 'success' : 'error',
        },
        {
          default: () => (record.status == 0 ? '正常' : '异常'),
        },
      );
    },
    width: 100,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
  },
  {
    title: '操作',
    fixed: 'right',
    dataIndex: 'action',
    key: 'action',
    width: 200,
  },
];
