Подробнее
This commit is contained in:
1 parent
4431232ffa
commit
2a475f3c65
9 files changed
+88
-122
No files matched your search
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<v-card
|
||||
class="rounded-0 h-100 flex-column d-flex"
|
||||
min-height="412"
|
||||
max-height="412"
|
||||
min-height="416"
|
||||
max-height="416"
|
||||
>
|
||||
<v-card-title class="pb-1">
|
||||
{{news.title}}
|
||||
@@ -62,7 +62,7 @@
|
||||
</span>
|
||||
<v-icon
|
||||
size="x-small"
|
||||
class="me-1"
|
||||
class="me-1 mb-1"
|
||||
icon="mdi-image"
|
||||
/>
|
||||
<span class="subheading">
|
||||
@@ -74,24 +74,24 @@
|
||||
<v-divider/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="ma-0">
|
||||
<v-col class="py-0 "
|
||||
<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>
|
||||
<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/>
|
||||
<v-row class="flex-grow-0 ma-0">
|
||||
<v-row class="flex-grow-0 ma-0">
|
||||
<v-col>
|
||||
<v-btn
|
||||
color="more_details_btn"
|
||||
variant="text"
|
||||
:to='`/news?id=${news.id}`'
|
||||
:to='`/newsfull?id=${news.id}`'
|
||||
size="small"
|
||||
append-icon="mdi-step-forward-2"
|
||||
>
|
||||
@@ -99,94 +99,13 @@
|
||||
</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'
|
||||
import { axiosApiInstance } from '@/utils/axios-api'
|
||||
|
||||
const accountStore = useAccountStore()
|
||||
|
||||
@@ -199,26 +118,34 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
setup(){
|
||||
setup(props){
|
||||
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 t = doc.split(' ').slice(0, 50)
|
||||
return `${doc.split(' ').slice(0, 50).join(' ')} ${t.length<50?'':'...'}`
|
||||
}
|
||||
|
||||
const splitname = (name) => {
|
||||
return name.familyname + ' ' + name.name[0] + '.' + name.parentname[0]+ '.'
|
||||
}
|
||||
|
||||
const toggleIncrementLike = (newss, scores) => {
|
||||
axiosApiInstance.post(`api/navigation/newscrossroad/`, {news: newss, scores: scores}).then(result => {
|
||||
props.news.scores = result.data
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
accountStore,
|
||||
burl,
|
||||
limitText,
|
||||
splitname,
|
||||
toggleIncrementLike
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,8 @@ export default {
|
||||
},
|
||||
|
||||
|
||||
setup(props, context) {
|
||||
setup(p
|
||||
, context) {
|
||||
|
||||
const accountStore = useAccountStore()
|
||||
const userlinks = ref([])
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<v-col class="d-flex flex-column">
|
||||
<v-row class=" flex-grow-1 pa-1 d-flex h-0 overflow-auto">
|
||||
<v-col
|
||||
v-for="(x, key) in newsAll.result"
|
||||
v-for="(x, key) in newsAll"
|
||||
:key="key"
|
||||
xl=3
|
||||
lg=4
|
||||
@@ -11,7 +11,7 @@
|
||||
sm=12
|
||||
xs=12
|
||||
cols=12
|
||||
class="d-flex pb-0 px-1 flex-column "
|
||||
class="d-flex pa-1 flex-column "
|
||||
>
|
||||
<news-card :news="x"/>
|
||||
</v-col>
|
||||
@@ -20,7 +20,7 @@
|
||||
<v-col class="pa-0" >
|
||||
<v-pagination
|
||||
v-model="page"
|
||||
:length=newsAll.countpage+1
|
||||
:length=countetnews+1
|
||||
:total-visible="7"
|
||||
@update:modelValue="loadNewsAll"
|
||||
/>
|
||||
@@ -49,13 +49,11 @@
|
||||
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
|
||||
@@ -64,35 +62,31 @@ export default {
|
||||
setup(){
|
||||
|
||||
const newsAll=ref([])
|
||||
const countetnews = ref(0)
|
||||
const page = ref(1)
|
||||
const countpage = ref(8)
|
||||
const route = useRoute()
|
||||
|
||||
const loadNewsAll = () => {
|
||||
axiosApiInstance.get( `api/navigation/newscrossroad/?name=${route.path}&page=${page.value-1}&countpage=${countpage.value}`).then(result => {
|
||||
newsAll.value= result.data
|
||||
}
|
||||
newsAll.value= result.data.result
|
||||
countetnews.value = result.data.countpage
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
loadNewsAll()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return {
|
||||
|
||||
newsAll,
|
||||
countetnews,
|
||||
page,
|
||||
countpage,
|
||||
|
||||
loadNewsAll,
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
<template>
|
||||
<div class="flex-column h-100 ">
|
||||
|
||||
|
||||
<v-card
|
||||
<div class="flex-column h-100">
|
||||
<div
|
||||
v-for="(x, key) in newss.result"
|
||||
:key="key"
|
||||
>
|
||||
<news-card :news="x"/>
|
||||
</div>
|
||||
<!-- <v-card
|
||||
:ref="i"
|
||||
style="width:421px"
|
||||
class="mx-auto px-3 pt-3 elevation-0"
|
||||
@@ -61,7 +65,7 @@
|
||||
<v-divider/>
|
||||
|
||||
<v-divider class="mt-1"/>
|
||||
</v-card>
|
||||
</v-card> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -75,11 +79,13 @@ import myHelper from './UI/my-helper.vue'
|
||||
import { axiosApiInstance } from '@/utils/axios-api'
|
||||
import { format } from 'date-fns'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
import newsCard from './UI/news-card.vue'
|
||||
const accountStore = useAccountStore()
|
||||
|
||||
export default {
|
||||
components: { myHelper },
|
||||
components: { myHelper,
|
||||
newsCard
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -97,6 +97,15 @@ const routes = [
|
||||
ico: "mdi-newspaper"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/newsfull',
|
||||
name: 'FullNewsPage',
|
||||
component: () => import('@/components/news-list-news.vue'),
|
||||
meta:{
|
||||
title:"Одна новость",
|
||||
ico: "mdi-newspaper"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/userinfo',
|
||||
name: 'UsersInfoPage',
|
||||
|
||||
@@ -15,7 +15,7 @@ export const useAccountStore = defineStore('AccountStore', () => {
|
||||
const setUser = (value)=> {
|
||||
value.photo = checkremote(`${spravURL}${value.login}.jpg`)
|
||||
user.value=value
|
||||
console.log(value.photo, 'value.photo-------------------')
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ export function getfromserver(path, reactive){
|
||||
|
||||
export function bgimage(filecheck){
|
||||
const h = new URL(`@assets/bg-for-number-carousel.png`, import.meta.url).href
|
||||
console.log(h, 'ffffffffffffffffffffffffffffff');
|
||||
|
||||
return h
|
||||
}
|
||||
// bg-for-number-carousel.png
|
||||
@@ -65,7 +65,7 @@ export function pagecounter(){
|
||||
const router = useRouter()
|
||||
const accountStore = useAccountStore()
|
||||
const appStore = useAppStore()
|
||||
console.log(router.currentRoute.value.meta, '-------------ttt------------------');
|
||||
console.log(router.currentRoute.value.meta, '----роутер страницы--');
|
||||
let postdata = {user__id: "user" in accountStore &&"id" in accountStore.user? accountStore.user.id: null,
|
||||
page: router.currentRoute.value.meta.title,
|
||||
fullPath: router.currentRoute.value.fullPath,
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
<v-row class="d-flex h-0 overflow-auto">
|
||||
<v-col>
|
||||
|
||||
<News-list-home />
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
+29
-1
@@ -106,7 +106,6 @@ class NewsCrossroadAPIView(ListAPIView):
|
||||
print('Получены все новости по ид')
|
||||
newsqueryset = News.objects.all().order_by('-cdate')
|
||||
countpage = newsqueryset.count()
|
||||
print(countpage,'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
|
||||
if request.GET.get("name") == "/":
|
||||
print('Запрос на новости для главной страницы')
|
||||
newsqueryset = newsqueryset[:10]
|
||||
@@ -123,6 +122,35 @@ class NewsCrossroadAPIView(ListAPIView):
|
||||
|
||||
|
||||
return Response({"result":result, "countpage": round(countpage/int(request.GET.get("countpage")))})
|
||||
|
||||
def post(self, request):
|
||||
|
||||
if 'scores' in request.data:
|
||||
upd, created = ScoreNews.objects.get_or_create(news_id=request.data['news'], author=self.request.user)
|
||||
|
||||
if created or (upd.score != request.data['scores']):
|
||||
upd.score = request.data['scores']
|
||||
else:
|
||||
upd.score = None
|
||||
|
||||
upd.cdate=datetime.now()
|
||||
upd.save()
|
||||
|
||||
back = [{"score":y.score, "user":y.author.username} for y in ScoreNews.objects.filter(news_id=request.data['news'])]
|
||||
|
||||
if 'text' in request.data:
|
||||
CommentNews.objects.create(news_id=request.data['news'], author=self.request.user, text=request.data['text'])
|
||||
back = {'news': request.data['news'], 'comment': ({"text":y.text, "cdate":y.cdate, "id": y.pk,
|
||||
"author":model_to_dict(y.author.user)
|
||||
} for y in CommentNews.objects.filter(news_id=request.data['news']))}
|
||||
if 'delid' in request.data:
|
||||
CommentNews.objects.filter(pk=request.data['delid']).delete()
|
||||
|
||||
back = {'news': request.data['news'], 'comment': ({"text":y.text, "cdate":y.cdate, "id": y.pk,
|
||||
"author":model_to_dict(y.author.user)
|
||||
} for y in CommentNews.objects.filter(news_id=request.data['news']))}
|
||||
|
||||
return Response(back)
|
||||
|
||||
class CarouselsAPIView(ListAPIView):
|
||||
permission_classes = (AllowAny,)
|
||||
|
||||
Reference in new issue
Block a user