Новости с галереей

This commit is contained in:
iriska-gri committed 2023-12-14 12:39:45 +03:00
1 parent f9b5b7853b
commit 6505affae8
3 files changed
+195 -22

No files matched your search

@@ -7,6 +7,14 @@
<v-card-title class="pb-1"> <v-card-title class="pb-1">
{{news.title}} {{news.title}}
</v-card-title> </v-card-title>
<!-- <my-helper :pretext="userlinks"/> -->
<!-- <v-avatar
color="loading_avatar"
:image="checkremote( `${spravURL}${x.author.login}.jpg`)"
size="25"
>
</v-avatar> -->
<v-row class="flex-grow-0"> <v-row class="flex-grow-0">
<v-col> <v-col>
<v-img <v-img
+1 -1
View File
@@ -15,7 +15,7 @@
> >
<news-card :news="x"/> <news-card :news="x"/>
<my-helper :pretext="x"/>
</v-col> </v-col>
</v-row> </v-row>
<v-row class="flex-grow-0 "> <v-row class="flex-grow-0 ">
+186 -21
View File
@@ -1,8 +1,8 @@
<template> <template>
<div class="d-flex flex-column flex-fill"> <div v-if="Object.keys(newsFull).length>0" class="d-flex flex-column flex-fill">
<v-row class="d-flex flex-column ma-0"> <v-row class="d-flex flex-row ma-0">
<v-col class=" flex-column d-flex "> <v-col class=" flex-column d-flex ">
<v-row class="flex-grow-0"> <v-row class="flex-grow-0">
<v-col class="pb-0 pr-0 "> <v-col class="pb-0 pr-0 ">
@@ -12,11 +12,11 @@
> >
<v-card-title class="pt-0 pb-1 flex-column d-flex"> <v-card-title class="pt-0 pb-1 flex-column d-flex">
<v-row> <v-row>
<v-col lg=10 class="pt-4"> <v-col lg=9 class="pt-4">
{{newsFull.title}} {{newsFull.title}}
</v-col> </v-col>
<v-col class="pa-0 pr-3 pt-1 flex-grow-1 d-flex flex-column flex-wrap"> <v-col class="pa-0 pr-3 pt-1 flex-grow-1 d-flex flex-column flex-wrap">
<!-- <my-helper :pretext="newsFull.text.length"/> -->
<v-switch <v-switch
v-model="gallery" v-model="gallery"
class="align-self-end comgal" class="align-self-end comgal"
@@ -25,11 +25,13 @@
<template v-slot:prepend> <template v-slot:prepend>
<v-tooltip location="top"> <v-tooltip location="top">
<template v-slot:activator="{ props }"> <template v-slot:activator="{ props }">
<v-icon <v-icon
v-bind="props" v-bind="props"
icon='mdi-message-text-outline' icon='mdi-message-text-outline'
color="pink-darken-4" color="pink-darken-4"
/> />
<span class="pl-3">{{ newsFull.comment.length }}</span>
</template> </template>
<span>Чат</span> <span>Чат</span>
</v-tooltip> </v-tooltip>
@@ -42,7 +44,9 @@
:icon="'mdi-image'" :icon="'mdi-image'"
color="teal-darken-2" color="teal-darken-2"
/> />
<span class="pl-3">{{newsFull.gallery.length}}</span>
</template> </template>
<span>Галерея</span> <span>Галерея</span>
</v-tooltip> </v-tooltip>
</template> </template>
@@ -66,7 +70,7 @@
<v-card <v-card
class="rounded-t-0 flex-column d-flex h-100 Line truncated class="rounded-t-0 flex-column d-flex h-100 Line truncated
> >
<!-- <v-list-item class="w-100"> <v-list-item class="w-100">
<template v-slot:prepend> <template v-slot:prepend>
<v-avatar <v-avatar
color="loading_avatar" color="loading_avatar"
@@ -76,19 +80,16 @@
</v-avatar> </v-avatar>
<v-list-item-title class="text-caption">{{splitname(newsFull.author)}}</v-list-item-title> <v-list-item-title class="text-caption">{{splitname(newsFull.author)}}</v-list-item-title>
</template> </template>
<template v-slot:append> <template v-slot:append>
<div class="justify-self-end"> <div class="justify-self-end">
<v-icon class="me-1" :icon="newsFull.scores.filter(e=> e.user==accountStore.user.login && e.score == true).length>0?'mdi-thumb-up':'mdi-thumb-up-outline'" @click="toggleIncrementLike(newsFull.id, true)"></v-icon> <v-icon class="me-1" :icon="newsFull.scores.filter(e=> e.user==accountStore.user.login && e.score == true).length>0?'mdi-thumb-up':'mdi-thumb-up-outline'" @click="toggleIncrementLike(newsFull.id, true)"></v-icon>
<span class="subheading me-2">{{newsFull.scores.filter(e=> e.score==true).length}}</span> <span class="subheading me-2">{{newsFull.scores.filter(e=> e.score==true).length}}</span>
<span class="me-1">·</span> <span class="me-1">·</span>
<v-icon class="me-1" :icon="newsFull.scores.filter(e=> e.user==accountStore.user.login && e.score == false).length>0?'mdi-thumb-down':'mdi-thumb-down-outline'" @click="toggleIncrementLike(newsFull.id, false)"/> <v-icon class="me-1" :icon="newsFull.scores.filter(e=> e.user==accountStore.user.login && e.score == false).length>0?'mdi-thumb-down':'mdi-thumb-down-outline'" @click="toggleIncrementLike(newsFull.id, false)"/>
<span class="subheading me-2">{{newsFull.scores.filter(e=> e.score==false).length}}</span> <span class="subheading me-2">{{newsFull.scores.filter(e=> e.score==false).length}}</span>
<span class="me-1">·</span>
<v-icon class="me-1" icon="mdi-message-text-outline"/>
<span class="subheading">{{ newsFull.comment.length }}</span>
</div> </div>
</template> </template>
</v-list-item> --> </v-list-item>
<v-divider/> <v-divider/>
<v-row class="ma-0 my-3 overflow-auto h-0"> <v-row class="ma-0 my-3 overflow-auto h-0">
<v-col class="pa-0"> <v-col class="pa-0">
@@ -111,22 +112,22 @@
</v-card> </v-card>
</v-col> </v-col>
</v-row> </v-row>
<!--</v-col> </v-col>
<v-col class="flex-column d-flex " <v-col class="flex-column d-flex "
> >
<v-row <v-row
class="d-flex flex-column " class="d-flex flex-column "
v-if="gallery" v-if="gallery"
> >
<v-col class="d-flex flex-column"> <v-col class="d-flex flex-column">
<v-card <v-card
class="h-100 flex-column d-flex overflow-auto overflow-x-hidden" class="h-100 flex-column pa-3 d-flex overflow-auto overflow-x-hidden"
> >
<div <div
class="flex-column d-flex ma-3" class="flex-column d-flex ma-3"
@@ -282,7 +283,7 @@
label="Комментарий" label="Комментарий"
no-resize no-resize
variant="underlined" variant="underlined"
rows="2" rows="1"
row-height="25" row-height="25"
shaped shaped
hide-details hide-details
@@ -304,10 +305,86 @@
</v-row> </v-row>
</v-card> </v-card>
</v-col> </v-col>
</v-row>--> </v-row>
</v-col> </v-col>
</v-row> </v-row>
<v-dialog
v-model="dialogfoto"
width="w-100"
height="900"
class="flex-column "
>
<v-card class="pa-4 h-100 flex-column d-flex">
<v-row class="flex-grow-0 justify-space-between">
<v-col class="py-0 flex-grow-0">
<v-btn
density="compact"
variant="text"
icon="mdi-cloud-download"
/>
</v-col>
<v-col class="pa-0 flex-grow-0">
<v-btn
density="compact"
variant="text"
icon="mdi-close"
@click="dialogfoto = false"
/>
</v-col>
</v-row>
<v-row>
<v-col class="flex-grow-0 align-self-center">
<v-btn
density="compact"
variant="text"
icon="mdi-chevron-left"
@click = "indximg !=0? indximg -=1:indximg=newsFull.gallery.length-1"
/>
</v-col>
<v-col class="flex-column h_cards pa-0">
<v-img
class="d-flex"
:src="`${burl}${galleryimges.img}`"
/>
</v-col>
<v-col class="d-flex flex-column flex-grow-0">
<v-row>
<v-col class="flex-column d-flex align-end align-self-center">
<v-btn
density="compact"
variant="text"
icon="mdi-chevron-right"
@click = "indximg !=newsFull.gallery.length-1? indximg +=1:indximg=0"
/>
</v-col>
</v-row>
</v-col>
</v-row>
<v-row class="flex-grow-1 align-self-center d-flex placeIt">
<v-col class="pa-0">
<v-btn
density="compact"
variant="text"
:color="heartIco()?'red':'black'"
:icon= "heartIco()?'mdi-heart':'mdi-heart-outline'"
@click = toggleLike(galleryimges.id)
/>
</v-col>
<v-col class="pa-0 text-overline">
{{galleryimges.likes.length}}
</v-col>
</v-row>
</v-card>
</v-dialog>
</div> </div>
</template> </template>
@@ -315,11 +392,12 @@
<script> <script>
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { axiosApiInstance } from '@/utils/axios-api' import { axiosApiInstance } from '@/utils/axios-api'
import { ref } from 'vue' import { ref, watch } from 'vue'
import { baseURL } from '@/utils/axios-api' import { baseURL } from '@/utils/axios-api'
import {checkremote} from '@/utils/universal_functions' import {checkremote} from '@/utils/universal_functions'
import { spravURL } from '@/utils/axios-api' import { spravURL } from '@/utils/axios-api'
import {useAccountStore} from '@/store/AccountStore' import {useAccountStore} from '@/store/AccountStore'
import { format } from 'date-fns'
const accountStore = useAccountStore() const accountStore = useAccountStore()
@@ -330,7 +408,7 @@ export default {
setup(){ setup(){
const textcomment = ref('')
const route = useRoute() const route = useRoute()
const newsFull=ref([]) const newsFull=ref([])
const gallery = ref(false) const gallery = ref(false)
@@ -371,6 +449,77 @@ export default {
} }
const dateformat = (datas) => {
return format(new Date(datas), 'dd.MM.yyyy HH:mm')
}
const addComment = (idnew) => {
axiosApiInstance.post(`api/navigation/newscrossroad/`, {news: idnew, text: textcomment.value}).then(result => {
newsFull.value.comment= result.data.comment
})
textcomment.value=""
}
const deletComment = (id, news) => {
axiosApiInstance.post(`api/navigation/newscrossroad/`, {delid: id, news: news}).then(result => {
newsFull.value.comment= result.data.comment
})
}
const heartIcoAll = (image) => {
return image.likes.filter(e=>e.user==accountStore.user.login).length==1
}
// ------------------------------ Галерея
const galleryimges=ref([])
const dialogfoto = ref(false)
const indximg = ref('')
const openImg = (idimg) => {
dialogfoto.value = true
indximg.value = newsFull.value.gallery.findIndex(e=>e.id == idimg)
}
watch(()=>indximg ,(newValue,oldValue)=>{
if(newValue){
galleryimges.value = newsFull.value.gallery[newValue.value]
}
}, {deep:true})
// Лайки на фотографии
const toggleLike = (idimage) => {
axiosApiInstance.post(`api/navigation/gallery/`, {image: idimage}).then(result => {
galleryimges.value.likes= result.data
})
}
const toggleLikeAll = (idimage) => {
axiosApiInstance.post(`api/navigation/gallery/`, {image: idimage}).then(result => {
newsFull.value.gallery.filter(e=>e.id ==idimage)[0].likes = result.data
})
}
const heartIco = () => {
return galleryimges.value.likes.filter(e=>e.user==accountStore.user.login).length==1
}
return { return {
@@ -382,7 +531,19 @@ export default {
spravURL, spravURL,
splitname, splitname,
accountStore, accountStore,
formatText formatText,
dateformat,
textcomment,
addComment,
deletComment,
heartIcoAll,
heartIco,
toggleLikeAll,
toggleLike,
openImg,
dialogfoto,
galleryimges,
indximg
} }
} }
@@ -391,5 +552,9 @@ export default {
</script> </script>
<style> <style>
.comgal .v-switch__thumb {
color: white!important;
}
</style> </style>