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

export const columns = [
  {
    title: 'ID',
    dataIndex: 'id',
    fixed: 'left',
    width: 50,
  },
  {
    title: '友链名称',
    dataIndex: 'name',
    width: 150,
  },
  {
    title: '友链类型',
    dataIndex: 'type',
    width: 100,
    customRender({ record }) {
      return h('span', record.type === 1 ? '友情链接' : '合作伙伴');
    },
  },
  {
    title: '友链形式',
    dataIndex: 'form',
    width: 100,
    customRender({ record }) {
      return h('span', record.form === 1 ? '文字链接' : '图片链接');
    },
  },
  {
    title: '友链地址',
    dataIndex: 'url',
    width: 200,
    customRender({ record }) {
      return h(
        'a',
        {
          href: record.url,
          target: '_blank',
        },
        record.url,
      );
    },
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 100,
    customRender({ record }) {
      return h(
        Tag,
        {
          color: record.status == 1 ? 'success' : 'error',
        },
        {
          default: () => (record.status == 1 ? '正常' : '停用'),
        },
      );
    },
  },
  {
    title: '排序',
    dataIndex: 'sort',
    width: 100,
  },
  {
    title: '创建人',
    dataIndex: 'createUser',
    width: 100,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
  },
  {
    title: '操作',
    fixed: 'right',
    dataIndex: 'action',
    key: 'action',
    width: 200,
  },
];
