Blame view

src/layouts/default/header/components/notify/NoticeList.vue 2.46 KB
chen-xt authored
1
<template>
vben authored
2
  <a-list :class="prefixCls">
chen-xt authored
3
    <template v-for="item in list" :key="item.id">
vben authored
4
5
      <a-list-item class="list-item">
        <a-list-item-meta>
chen-xt authored
6
7
8
9
          <template #title>
            <div class="title">
              {{ item.title }}
              <div class="extra" v-if="item.extra">
vben authored
10
                <a-tag class="tag" :color="item.color">
chen-xt authored
11
                  {{ item.extra }}
vben authored
12
                </a-tag>
chen-xt authored
13
14
15
              </div>
            </div>
          </template>
vben authored
16
chen-xt authored
17
          <template #avatar>
vben authored
18
            <a-avatar v-if="item.avatar" class="avatar" :src="item.avatar" />
chen-xt authored
19
20
            <span v-else> {{ item.avatar }}</span>
          </template>
vben authored
21
chen-xt authored
22
23
          <template #description>
            <div>
24
25
26
27
28
29
              <div class="description">
                {{ item.description }}
              </div>
              <div class="datetime">
                {{ item.datetime }}
              </div>
chen-xt authored
30
31
            </div>
          </template>
vben authored
32
33
        </a-list-item-meta>
      </a-list-item>
chen-xt authored
34
    </template>
vben authored
35
  </a-list>
chen-xt authored
36
37
38
39
</template>
<script lang="ts">
  import { defineComponent, PropType } from 'vue';
  import { ListItem } from './data';
vben authored
40
  import { useDesign } from '/@/hooks/web/useDesign';
vben authored
41
  import { List, Avatar, Tag } from 'ant-design-vue';
chen-xt authored
42
  export default defineComponent({
vben authored
43
44
45
46
47
48
49
    components: {
      [Avatar.name]: Avatar,
      [List.name]: List,
      [List.Item.name]: List.Item,
      AListItemMeta: List.Item.Meta,
      [Tag.name]: Tag,
    },
chen-xt authored
50
51
    props: {
      list: {
vben authored
52
        type: Array as PropType<ListItem[]>,
chen-xt authored
53
54
55
        default: () => [],
      },
    },
vben authored
56
57
58
59
    setup() {
      const { prefixCls } = useDesign('header-notify-list');
      return { prefixCls };
    },
chen-xt authored
60
61
62
  });
</script>
<style lang="less" scoped>
vben authored
63
64
65
  @prefix-cls: ~'@{namespace}-header-notify-list';

  .@{prefix-cls} {
chen-xt authored
66
67
68
69
    &::-webkit-scrollbar {
      display: none;
    }
vben authored
70
    &-item {
chen-xt authored
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
105
106
107
108
      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>