Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | <template>
<v-card
class="rounded-0 h-100 flex-column d-flex"
min-height="400"
max-height="400"
>
<v-card-title class="">
{{news.title}}
</v-card-title>
<v-row class="flex-grow-0">
<v-col class="d-flex flex-column ">
<v-img
:src="`${burl}${news.link}`"
height="170px"
width="92%"
class="mx-auto"
cover
@click="openOneImg(news.link)"
/>
</v-col>
</v-row>
<v-row class="ma-0 flex-grow-0">
<v-col
class="py-1 pl-4"
lg=5
md=12
sm=12
>
<ico-user :author="news.author"/>
</v-col>
<v-col
lg=7
md=12
sm=12
class="py-1 text-end pr-4">
<div class="justify-self-end">
<v-icon
size="x-small"
class="me-1"
:icon="news.scores.filter(e=> e.user==accountStore.user.login && e.score == true).length>0?'mdi-thumb-up':'mdi-thumb-up-outline'"
@click="toggleIncrementLike(news.id, true)"
/>
<span class="subheading me-2">
{{news.scores.filter(e=> e.score==true).length}}
</span>
<span class="me-1">
·
</span>
<v-icon
size="x-small"
class="me-1"
:icon="news.scores.filter(e=> e.user==accountStore.user.login && e.score == false).length>0?'mdi-thumb-down':'mdi-thumb-down-outline'"
@click="toggleIncrementLike(news.id, false)"
/>
<span class="subheading me-2">
{{news.scores.filter(e=> e.score==false).length}}
</span>
<span class="me-1">
·
</span>
<v-icon
size="x-small"
class="me-1"
icon="mdi-message-text-outline"
/>
<span class="subheading">
{{ news.comment.length }}
</span>
<span class="me-1">
·
</span>
<v-icon
size="x-small"
class="me-1 mb-1"
icon="mdi-image"
/>
<span class="subheading">
{{ news.gallery.length }}
</span>
</div>
</v-col>
</v-row>
<v-divider class="mx-4"/>
<v-row class="ma-0 overflow-auto">
<v-col
class="py-0"
:class="news.text.length==0?'align-self-center':'my-3'"
>
<v-card-text class="py-0 px-2">
<div v-if="news.text.length>0" v-html=limitText(news.text)></div>
<div v-else class="text-h6 text-grey text-center align-self-center text--lighten-1 font-weight-light">Без описания</div>
</v-card-text>
</v-col>
</v-row>
<v-divider class="mx-4"/>
<v-row class="flex-grow-0 ma-0">
<v-col class="d-flex justify-space-between">
<v-btn
color="more_details_btn"
:to='`/newsfull?id=${news.id}`'
size="small"
rounded="xl"
append-icon="mdi-step-forward-2"
>
Подробнее
</v-btn>
<span class="text-caption align-self-center">{{formatDate(news.cdate)}}</span>
</v-col>
</v-row>
</v-card>
</template>
<script>
import { baseURL } from '@/utils/axios-api'
import {useAccountStore} from '@/store/AccountStore'
import { axiosApiInstance } from '@/utils/axios-api'
import {splitname} from '@/utils/universal_functions'
import moment from 'moment'
import icoUser from '@/components/UI/fiousercard/icoUser.vue'
const accountStore = useAccountStore()
export default {
components: { icoUser },
name:'NewsCard',
props: {
news: {
type: Object,
default: {}
}
},
setup(props, {emit}){
const burl = baseURL.slice(0,-1)
const limitText=(text)=> {
let parser = new DOMParser().parseFromString(text, "text/html");
let doc = parser.body.textContent || ""
doc = doc.replaceAll('src="/media/uploads', `src="${baseURL}media/uploads`)
const t = doc.split(' ').slice(0, 50)
return `${doc.split(' ').slice(0, 50).join(' ')} ${t.length<50?'':'...'}`
}
const toggleIncrementLike = (newss, scores) => {
axiosApiInstance.post(`api/navigation/newscrossroad/`, {news: newss, scores: scores}).then(result => {
props.news.scores = result.data
})
}
const openOneImg = () => {
emit('openOneImg')
}
function formatDate(date) {
return moment(date).format('DD.MM.YYYY')
}
return {
accountStore,
burl,
limitText,
splitname,
toggleIncrementLike,
openOneImg,
formatDate
}
}
}
</script>
<style>
</style> |