import { h } from 'vue';
import { NTag } from 'naive-ui';

export const columns = [
  {
    type: 'selection',
    width: 50,
    fixed: 'left',
  },
  {
    title: 'ID',
    key: 'id',
    fixed: 'left',
    width: 50,
  },
  {
    title: '操作用户',
    key: 'username',
    width: 100,
  },
  {
    title: '请求ip',
    key: 'ip',
    width: 100,
  },
  {
    title: '浏览器',
    key: 'browser',
    width: 100,
  },
  {
    title: '操作系统',
    key: 'os',
    width: 100,
  },
  {
    title: '操作类型',
    key: 'typeText',
    width: 100,
  },
  {
    title: '操作来源',
    key: 'sourceText',
    width: 100,
  },
  {
    title: '请求方式',
    key: 'requestMethod',
    width: 100,
  },
  {
    title: '请求URL',
    key: 'url',
    width: 100,
  },
  {
    title: '请求地区',
    key: 'location',
    width: 100,
  },
  {
    title: '请求耗时',
    key: 'consumeTime',
    width: 100,
  },
  {
    title: '状态',
    key: 'status',
    render(record) {
      return h(
        NTag,
        {
          type: record.status == 0 ? 'success' : 'error',
        },
        {
          default: () => (record.status == 0 ? '正常' : '异常'),
        },
      );
    },
    width: 100,
  },
  {
    title: '创建时间',
    key: 'createTime',
    width: 180,
  },
];
