NoticeList.vue 2.4 KB
Newer Older
C
chen-xt 已提交
1
<template>
V
vben 已提交
2
  <a-list :class="prefixCls">
C
chen-xt 已提交
3
    <template v-for="item in list" :key="item.id">
V
vben 已提交
4 5
      <a-list-item class="list-item">
        <a-list-item-meta>
C
chen-xt 已提交
6 7 8 9
          <template #title>
            <div class="title">
              {{ item.title }}
              <div class="extra" v-if="item.extra">
V
vben 已提交
10
                <a-tag class="tag" :color="item.color">
C
chen-xt 已提交
11
                  {{ item.extra }}
V
vben 已提交
12
                </a-tag>
C
chen-xt 已提交
13 14 15
              </div>
            </div>
          </template>
V
vben 已提交
16

C
chen-xt 已提交
17
          <template #avatar>
V
vben 已提交
18
            <a-avatar v-if="item.avatar" class="avatar" :src="item.avatar" />
C
chen-xt 已提交
19 20
            <span v-else> {{ item.avatar }}</span>
          </template>
V
vben 已提交
21

C
chen-xt 已提交
22 23 24 25 26 27
          <template #description>
            <div>
              <div class="description">{{ item.description }}</div>
              <div class="datetime">{{ item.datetime }}</div>
            </div>
          </template>
V
vben 已提交
28 29
        </a-list-item-meta>
      </a-list-item>
C
chen-xt 已提交
30
    </template>
V
vben 已提交
31
  </a-list>
C
chen-xt 已提交
32 33 34 35
</template>
<script lang="ts">
  import { defineComponent, PropType } from 'vue';
  import { ListItem } from './data';
V
vben 已提交
36
  import { useDesign } from '/@/hooks/web/useDesign';
V
vben 已提交
37
  import { List, Avatar, Tag } from 'ant-design-vue';
C
chen-xt 已提交
38
  export default defineComponent({
V
vben 已提交
39 40 41 42 43 44 45
    components: {
      [Avatar.name]: Avatar,
      [List.name]: List,
      [List.Item.name]: List.Item,
      AListItemMeta: List.Item.Meta,
      [Tag.name]: Tag,
    },
C
chen-xt 已提交
46 47
    props: {
      list: {
V
vben 已提交
48
        type: Array as PropType<ListItem[]>,
C
chen-xt 已提交
49 50 51
        default: () => [],
      },
    },
V
vben 已提交
52 53 54 55
    setup() {
      const { prefixCls } = useDesign('header-notify-list');
      return { prefixCls };
    },
C
chen-xt 已提交
56 57 58
  });
</script>
<style lang="less" scoped>
V
vben 已提交
59 60 61
  @prefix-cls: ~'@{namespace}-header-notify-list';

  .@{prefix-cls} {
C
chen-xt 已提交
62 63 64 65
    &::-webkit-scrollbar {
      display: none;
    }

V
vben 已提交
66
    &-item {
C
chen-xt 已提交
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
      padding: 6px;
      overflow: hidden;
      cursor: pointer;
      transition: all 0.3s;

      .title {
        margin-bottom: 8px;
        font-weight: normal;

        .extra {
          float: right;
          margin-top: -1.5px;
          margin-right: 0;
          font-weight: normal;

          .tag {
            margin-right: 0;
          }
        }

        .avatar {
          margin-top: 4px;
        }

        .description {
          font-size: 12px;
          line-height: 18px;
        }

        .datetime {
          margin-top: 4px;
          font-size: 12px;
          line-height: 18px;
        }
      }
    }
  }
</style>