Authored by yyq

widgetBtn

<template>
<div class="icon-btn" @click="onClick" :style="btnStyle">
<i class="iconfont" :class="iconClass" :style="iconStyle"></i>
<p v-if="text" class="icon-btn-text" :style="textStyle">
<p v-if="viewText" class="icon-btn-text" :style="textStyle">
<span class="view-text">{{viewText}}</span>
<span class="placeholder-text">{{text}}</span>
<span class="placeholder-text">{{placText}}</span>
</p>
</div>
</template>
<script>
import {forEach, get} from 'lodash';
import {forEach, get, fill} from 'lodash';
import {createNamespacedHelpers} from 'vuex';
const {mapActions} = createNamespacedHelpers('user');
... ... @@ -125,7 +125,14 @@
return style;
},
viewText() {
return this.editText === null ? this.text : this.editText;
return `${this.editText === null ? this.text : this.editText}`;
},
placText() {
if (!isNaN(Number(this.text)) && this.viewText.length) {
return fill(Array(this.viewText.length), 0).join('');
} else {
return `${this.text}`;
}
}
},
methods: {
... ... @@ -179,7 +186,7 @@
if (this._type === 'fav') {
syncFnName = 'praiseArticle';
} else if (this._type === 'star') {
syncFnName = 'praiseArticle';
syncFnName = 'followArticle';
}
} else if (this.commentId && this._type === 'fav') {
syncFnName = 'praiseComment';
... ...
... ... @@ -32,7 +32,7 @@
</template>
<script>
import {assign} from 'lodash';
import {assign, get} from 'lodash';
export default {
data() {
... ... @@ -91,7 +91,7 @@ export default {
},
list(newList, oldList) {
if (oldList.length > newList.length ||
oldList[0].articleId !== newList[0].articleId) {
get(oldList, '[0].articleId') !== get(newList, '[0].articleId')) {
this.reset();
}
... ... @@ -120,9 +120,6 @@ export default {
this.$emit('calced', nlist);
},
calcCoverImgHeight(w, h) {
return h / w * this.coverImageWidth;
},
calcLayout() {
let $item = this.$el.getElementsByClassName('wf-item-temp');
... ... @@ -189,7 +186,7 @@ export default {
}
}
this.coverImageWidth = imgWidth;
this.coverImageWidth = Math.floor(imgWidth);
},
reset() {
this.offsetTop = this.$el.offsetTop;
... ... @@ -306,6 +303,14 @@ export default {
.description {
line-height: 1.5;
padding: 10px 20px;
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 {
... ...