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