author-article-item.vue
2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<template>
<div class="wf-item" :class="temporary ? 'wf-temp' : ''">
<div v-if="temporary"></div>
<div v-else class="wf-item-mid">
<div class="layer-image" @click="onClick" :style="`height: ${data.blockWidth * data.scale}px`">
<ImageFormat :mode="1" :src="data.coverImage" :width="imgWidth" :height="Math.floor(data.scale * imgWidth)"></ImageFormat>
</div>
<div v-if="data.content" class="description" @click="onClick">
<p>{{data.content}}</p>
</div>
<div class="attribution">
<div class="auther" @click="onClick">
<span class="avatar">
<WidgetAvatar :src="data.authorHeadIco" :width="70" :height="70"></WidgetAvatar>
</span>
<span class="name">{{data.authorName}}</span>
</div>
<div class="fav">
<WidgetFav :articleId="data.articleId" :num="data.praiseCount" :option="favOption"></WidgetFav>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
imgWidth: 350,
favOption: {
iconFontSize: 26,
textAlign: 'normal'
}
}
},
props: {
data: {
type: Object,
default() {
return {};
}
},
temporary: {
type: Boolean,
default: false
}
},
methods: {
onClick() {
this.$emit('click', this.data);
}
}
};
</script>
<style lang="css">
.wf-item {
width: 100%;
padding: 10px;
font-size: 24px;
.wf-item-mid {
border-radius: 8px;
box-shadow: 0 4px 18px 0 rgba(0, 0, 0, 0.3);
overflow: hidden;
}
.layer-image {
background-color: #f4f4f4;
min-height: 100px;
> img {
width: 100%;
height: 100%;
display: block;
}
}
.description {
line-height: 1.5;
padding: 10px 20px;
> p {
word-break: break-all;
text-overflow: -o-ellipsis-lastline;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
}
}
.attribution {
display: flex;
justify-content: space-between;
padding: 20px;
}
.avatar {
width: 60px;
height: 60px;
border-radius: 50%;
display: inline-block;
vertical-align: middle;
overflow: hidden;
> img {
width: 100%;
height: 100%;
}
}
.name {
max-width: 170px;
display: inline-block;
vertical-align: middle;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.fav {
line-height: 60px;
}
}
.wf-temp {
height: 0;
overflow: hidden;
position: absolute;
}
</style>