Files
PORTAL_COD2/front/src/components/news-list.vue
T
2023-09-05 16:07:55 +03:00

98 lines
1.7 KiB
Vue

<template>
<v-container class="py-1 newsVH bg-transparent overflow-auto">
<v-card
class="mx-auto mb-0 "
v-for="(x, i) in newss" :key= i
>
<v-img
:src="`${burl}${x.link}`"
height="164px"
cover
/>
<v-card-title>
{{x.title}}
</v-card-title>
<v-card-subtitle>
{{limitText(x.text)}}
</v-card-subtitle>
<v-card-actions>
<v-btn
color="teal-accent-4"
variant="text"
>
{{x.author.fio}}
</v-btn>
<v-spacer></v-spacer>
<v-btn
:icon="x.show ? 'mdi-chevron-up' : 'mdi-chevron-down'"
@click="x.show = !x.show"
></v-btn>
</v-card-actions>
<v-expand-transition>
<div v-show="x.show">
<v-divider></v-divider>
<v-card-text>
{{x.text}}
</v-card-text>
</div>
</v-expand-transition>
</v-card>
</v-container>
</template>
<script>
import { ref,computed,watch } from 'vue'
import {useAccountStore} from '@/store/AccountStore'
import {getfromserver} from '@/utils/universal_functions'
import { baseURL } from '@/utils/axios-api'
const accountStore = useAccountStore()
export default {
setup(){
const newss=ref([])
const show=ref(false)
const burl = baseURL.slice(0,-1)
const limitText=(text)=> {
return text.split(' ').slice(0, 10).join(' ')
}
getfromserver("api/navigation/news/", newss)
watch(()=>accountStore.cod2user ,(newValue,oldValue)=>{
if(newValue){
getfromserver("api/navigation/news/",newss)
}
}, {deep:true})
return {
newss,
show,
burl,
limitText
}
}
}
</script>
<style>
.newsVH {
height: 93vh;
}
</style>