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: 100,
  },
  {
    title: '访客',
    align: 'left',
    width: 200,
    render(record) {
      return h('div', [
        h(
          'div',
          {
            style: { marginBottom: '5px' },
          },
          record.username,
        ),
        h(
          'div',
          {
            style: { marginBottom: '5px' },
          },
          record.ip,
        ),
        h(
          NTag,
          {
            type: 'info',
          },
          {
            default: () => record.location,
          },
        ),
      ]);
    },
  },
  {
    title: '请求接口',
    align: 'left',
    width: 200,
    render(record) {
      return h('div', [
        h(
          NTag,
          {
            style: { marginBottom: '5px' },
          },
          {
            default: () => record.requestMethod,
          },
        ),
        h(
          'div',
          {
            style: { marginBottom: '5px' },
          },
          '接口：' + record.url,
        ),
        h('div', '名称：' + record.title),
      ]);
    },
  },
  {
    title: '接口响应',
    align: 'left',
    width: 250,
    render(record) {
      return h('div', [
        h('span', '状态：'),
        h(
          NTag,
          {
            type: record.status == 0 ? 'success' : 'error',
            style: { marginBottom: '5px' },
          },
          {
            default: () => (record.status == 0 ? '正常' : '异常'),
          },
        ),
        h(
          'div',
          {
            style: { marginBottom: '5px' },
          },
          '请求耗时：' + record.consumeTime + 'ms',
        ),
        h('div', '响应时间：' + record.updateTime),
      ]);
    },
  },
  {
    title: '操作来源',
    align: 'left',
    width: 200,
    render(record) {
      return h('div', [
        h('div', '系统：' + record.os),
        h('div', '类型：' + record.typeText),
        h('div', '来源：' + record.sourceText),
      ]);
    },
  },
  {
    title: '创建时间',
    key: 'createTime',
    width: 180,
  },
];
