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

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