import { h } from 'vue';
import { ElAvatar, ElTag } from 'element-plus';

export const columns = [
  {
    type: 'selection',
  },
  {
    label: 'ID',
    prop: 'id',
    fixed: 'left',
    width: 50,
  },
  {
    label: '文章标题',
    prop: 'title',
    minWidth: 250,
    render(record) {
      return h(
        'a',
        {
          href: 'http://www.baidu.com',
          target: '_blank',
        },
        record.row.title,
      );
    },
  },
  {
    label: '文章封面',
    prop: 'cover',
    minWidth: 100,
    render(record) {
      return h(ElAvatar, {
        size: 48,
        src: record.row.cover,
        shape: 'square',
        fit: 'fill',
      });
    },
  },
  {
    label: '文章分类',
    prop: 'categoryName',
    minWidth: 100,
  },
  {
    label: '文章作者',
    prop: 'author',
    minWidth: 100,
  },
  // {
  //   label: '文章链接',
  //   value:'articelLink',
  //   isSlot:true,
  // },
  {
    label: '文章状态',
    prop: 'status',
    minWidth: 100,
    render(record) {
      return h(
        ElTag,
        {
          type: record.row.status === 0 ? 'success' : 'danger',
        },
        {
          default: () => (record.row.status === 0 ? '正常' : '下架'),
        },
      );
    },
  },
  {
    label: '点击率',
    prop: 'click',
    minWidth: 100,
  },
  {
    label: '文章排序',
    prop: 'sort',
    minWidth: 100,
  },
  {
    label: '创建人',
    prop: 'createUser',
    minWidth: 100,
  },
  {
    label: '创建时间',
    prop: 'createTime',
    width: 180,
  },
];
