<template>
  <a-card :title="linkType" :bordered="false" :body-style="{ padding: '2px' }">
    <template #extra
      ><a @click="openNew('/oa/link')" class="ele-text-placeholder"
        >更多<RightOutlined /></a
    ></template>
    <a-list :size="`small`" :split="false" :data-source="list">
      <template #renderItem="{ item }">
        <a-list-item>
          <a-list-item-meta>
            <template #avatar>
              <a-avatar :src="item.icon" />
            </template>
            <template #title>
              <a @click="openUrl(item.url)">{{ item.name }}</a>
            </template>
          </a-list-item-meta>
        </a-list-item>
      </template>
    </a-list>
  </a-card>
</template>

<script lang="ts" setup>
  import { ref } from 'vue';
  import { openNew, openUrl } from '@/utils/common';
  import { pageLink } from '@/api/oa/link';
  import { RightOutlined } from '@ant-design/icons-vue';
  const list = ref<any[]>([]);

  const props = defineProps<{
    linkType: string;
  }>();

  /**
   * 加载数据
   */
  const reload = () => {
    const { linkType } = props;
    // 加载文章列表
    pageLink({ linkType, limit: 5 }).then((data) => {
      if (data?.list) {
        list.value = data.list;
      }
    });
  };
  reload();
</script>

<script lang="ts">
  export default {
    name: 'DashboardArticleList'
  };
</script>
