Новая галерея

This commit is contained in:
iriska-gri committed 2023-12-13 09:21:21 +03:00
1 parent 8a10f2aa46
commit 46ed1e68e0
9 files changed
+356 -37

No files matched your search

+226
View File
@@ -0,0 +1,226 @@
<template>
<v-card
class="rounded-0 h-100 flex-column d-flex"
min-height="404"
max-height="404"
>
<v-card-title class="pt-0 pb-1">
{{news.title}}
</v-card-title>
<v-row class="flex-grow-0">
<v-col>
<v-img
:src="`${burl}${news.link}`"
height="175px"
width="92%"
class="mx-auto"
cover
/>
<v-list-item class="w-100 ">
<div class="justify-self-start mt-1">
<v-icon size="x-small" class="me-1" icon="mdi-account"/>
<span class="text-caption me-2">
{{splitname(news.author)}}
</span>
</div>
<template v-slot:append>
<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"
icon="mdi-image"
/>
<span class="subheading">
{{ news.gallery.length }}
</span>
</div>
</template>
</v-list-item>
<v-divider/>
</v-col>
</v-row>
<v-row>
<v-col class="py-0">
<v-card-text class="py-0">
<div v-html=limitText(news.text)></div>
</v-card-text>
</v-col>
</v-row>
<v-divider/>
<v-row class="flex-grow-0 ma-0">
<v-col>
<v-btn
color="more_details_btn"
variant="text"
:to='`/news?id=${news.id}`'
size="small"
append-icon="mdi-step-forward-2"
>
Подробнее
</v-btn>
</v-col>
</v-row>
<!-- <v-card-text
class="pb-0 "
>
<v-img
:src="`${burl}${news.link}`"
height="175px"
width="100%"
class="mx-auto"
cover
/>
<v-list-item class="w-100 px-0">
<div class="justify-self-start mt-1">
<v-icon size="x-small" class="me-1" icon="mdi-account"/>
<span class="text-caption me-2">
{{splitname(news.author)}}
</span>
</div>
<template v-slot:append>
<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"
icon="mdi-image"
/>
<span class="subheading">
{{ news.gallery.length }}
</span>
</div>
</template>
</v-list-item>
<v-divider/>
<div v-html=limitText(news.text)></div>
</v-card-text>
<v-divider/>
<v-card-actions>
<v-btn
color="more_details_btn"
variant="text"
:to='`/news?id=${news.id}`'
size="small"
append-icon="mdi-step-forward-2"
>
Подробнее
</v-btn>
</v-card-actions> -->
</v-card>
</template>
<script>
import { baseURL } from '@/utils/axios-api'
import {useAccountStore} from '@/store/AccountStore'
const accountStore = useAccountStore()
export default {
props: {
news: {
type: Object,
default: {}
}
},
setup(){
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, 15)
return `${doc.split(' ').slice(0, 15).join(' ')} ${t.length<15?'':'...'}`
}
const splitname = (name) => {
return name.familyname + ' ' + name.name[0] + '.' + name.parentname[0]+ '.'
}
return {
accountStore,
burl,
limitText,
splitname,
}
}
}
</script>
<style>
</style>
+130 -35
View File
@@ -1,58 +1,134 @@
<template>
<v-row>
<v-col class="d-flex flex-column">
<v-row>
<v-col>
1
<v-row class=" flex-grow-1 d-flex h-0 overflow-auto">
<v-col
v-for="(x, key) in newsAll.result"
:key="key"
xl=3
lg=4
md=12
sm=12
xs=12
cols=12
class="d-flex flex-column "
>
<news-card :news="x"/>
<!-- <v-card
class="h-100 rounded-0"
>
<v-card-title class="pt-0 pb-1">
{{x.title}}
</v-card-title>
<v-img
:src="`${burl}${x.link}`"
height="175px"
width="96%"
class="mx-auto"
cover
/>
<v-list-item class="w-100">
<div class="justify-self-start mt-1">
<v-icon size="x-small" class="me-1" icon="mdi-account"/>
<span class="text-caption me-2">
{{splitname(x.author)}}
</span>
</div>
<template v-slot:append>
<div class="justify-self-end">
<v-icon
size="x-small"
class="me-1"
:icon="x.scores.filter(e=> e.user==accountStore.user.login && e.score == true).length>0?'mdi-thumb-up':'mdi-thumb-up-outline'"
@click="toggleIncrementLike(x.id, true)"
/>
<span class="subheading me-2">
{{x.scores.filter(e=> e.score==true).length}}
</span>
<span class="me-1">
·
</span>
<v-icon
size="x-small"
class="me-1"
:icon="x.scores.filter(e=> e.user==accountStore.user.login && e.score == false).length>0?'mdi-thumb-down':'mdi-thumb-down-outline'"
@click="toggleIncrementLike(x.id, false)"
/>
<span class="subheading me-2">
{{x.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">
{{ x.comment.length }}
</span>
</div>
</template>
</v-list-item>
<v-divider/>
<v-card-text
class="pb-0"
>
<div v-html=limitText(x.text)></div>
</v-card-text>
<v-card-actions>
<v-btn
color="more_details_btn"
variant="text"
:to='`/news?id=${x.id}`'
size="small"
append-icon="mdi-step-forward-2"
>
Подробнее
</v-btn>
</v-card-actions>
</v-card> -->
</v-col>
</v-row>
<v-row class="flex-grow-0">
<v-col class="bg-red">
<v-row class="flex-grow-0 ">
<v-col class="pa-0" >
<v-pagination
v-model="page"
:length=newsAll.countpage
:length=newsAll.countpage+1
:total-visible="7"
@update:modelValue="loadNewsAll"
/>
</v-col>
<v-col class="flex-grow-0" LG=2>
<v-col class="flex-grow-0 py-0">
<v-select
style="width:53px"
hide-details
hide-selected
density="compact"
v-model="countpage"
rounded
variant="underlined"
:items="[1, 8, 16, 24, 32, 40]"
:items="[8, 16, 24, 32, 40]"
@update:modelValue="loadNewsAll"
/>
</v-col>
</v-row>
</v-col>
</v-row>
<!-- <div>
<div>
{{newsAll.result}}
</div>
<div class="text-center">
<v-pagination
v-model="page"
:length=newsAll.countpage
:total-visible="7"
@update:modelValue="loadNewsAll"
/>
<v-select
hide-details
density="compact"
v-model="countpage"
variant="underlined"
:items="[1, 8, 16, 24, 32, 40]"
@update:modelValue="loadNewsAll"
/>
</div>
</div> -->
</template>
@@ -61,13 +137,24 @@ import { ref } from 'vue'
import { axiosApiInstance } from '@/utils/axios-api'
import { useRoute } from 'vue-router'
import myHelper from './UI/my-helper.vue'
import newsCard from './UI/news-card.vue'
export default {
components: {
myHelper,
newsCard
},
setup(){
const newsAll=ref([])
const page = ref(1)
const countpage = ref(1)
const countpage = ref(8)
const route = useRoute()
const loadNewsAll = () => {
@@ -79,11 +166,19 @@ export default {
loadNewsAll()
return {
newsAll,
page,
countpage,
loadNewsAll
loadNewsAll,
}
}
}
@@ -702,9 +702,7 @@ export default {
const toggleIncrementLike = (news, scores) => {
axiosApiInstance.post(`api/navigation/news/`, {news: news, scores: scores}).then(result => {
newss.value.result[newss.value.result.findIndex(e=> e.id==news)].scores= result.data
})
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 578 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB