Новости
This commit is contained in:
1 parent
182f643b5c
commit
89d45d8469
5 files changed
+90
-161
No files matched your search
BIN
Binary file not shown.
@@ -8,7 +8,7 @@
|
||||
:ref="i"
|
||||
class="mx-auto"
|
||||
:class="i>0?'mt-1':''"
|
||||
v-for="(x, i) in newss" :key= i
|
||||
v-for="(x, i) in newss.result" :key= i
|
||||
>
|
||||
|
||||
<v-list-item class="w-100 pl-4 py-2 pt-3">
|
||||
@@ -63,23 +63,22 @@
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
|
||||
<!-- :to="'/news'" -->
|
||||
|
||||
|
||||
</v-card>
|
||||
<!-- <div ref="#g">hello</div> -->
|
||||
|
||||
|
||||
<!-- ------------------------------ @click="scrollMeTo('porto')"---------------------------------------------------- -->
|
||||
|
||||
|
||||
|
||||
|
||||
<div >
|
||||
|
||||
<v-card v-show="pages=='news'"
|
||||
class="mx-auto rounded-0 gggggggggggggggggggggggggg"
|
||||
class="mx-auto rounded-0"
|
||||
|
||||
:ref="el => { if (el) divs[i] = el }"
|
||||
v-for="(x, i) in newss" :key=i
|
||||
|
||||
v-for="(x, i) in newss.result" :key=i
|
||||
>
|
||||
<v-list-item class="w-100 pl-4 py-2 pt-3">
|
||||
<template v-slot:prepend>
|
||||
@@ -89,7 +88,7 @@
|
||||
:image=accountStore.user.photo></v-avatar>
|
||||
</template>
|
||||
|
||||
<v-list-item-title>{{x.author.fio}} {{ i }}</v-list-item-title>
|
||||
<v-list-item-title>{{x.author.fio}}</v-list-item-title>
|
||||
|
||||
<v-list-item-subtitle>Участник</v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
@@ -109,13 +108,10 @@
|
||||
|
||||
<template v-slot:append>
|
||||
<div class="justify-self-end">
|
||||
<!-- <v-btn v-scroll-to="{element:'#nh'}">
|
||||
2
|
||||
</v-btn> -->
|
||||
<v-icon class="me-1" :icon="x.scores.filter(e=> e.user==accountStore.user.id && e.score == true).length>0?'mdi-thumb-up':'mdi-thumb-up-outline'" @click="toggleIncrementLike(x.id, true)"></v-icon>
|
||||
<span class="subheading me-2">{{x.scores.filter(e=> e.score==true).length}}</span>
|
||||
<span class="me-1">·</span>
|
||||
<v-icon class="me-1" icon="mdi-thumb-down-outline" @click="toggleIncrementLike(x.id, false)"/>
|
||||
<v-icon class="me-1" :icon="x.scores.filter(e=> e.user==accountStore.user.id && 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 class="me-1" icon="mdi-message-text-outline" @click="openComent(x.id)"/>
|
||||
@@ -166,13 +162,7 @@
|
||||
|
||||
|
||||
</v-row>
|
||||
<!-- <div style="text-align: center;">
|
||||
<div style="display: inline-block; text-align: left;">
|
||||
Centered
|
||||
Content
|
||||
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="text-subtitle-2">
|
||||
|
||||
|
||||
@@ -220,8 +210,27 @@
|
||||
|
||||
|
||||
</v-card>
|
||||
<!-- <div id="nh">ss</div> -->
|
||||
|
||||
|
||||
<v-pagination
|
||||
v-model="page"
|
||||
:length="newss.allnews"
|
||||
prev-icon="mdi-menu-left"
|
||||
next-icon="mdi-menu-right"
|
||||
@click="pagelistNews"
|
||||
></v-pagination>
|
||||
|
||||
<v-select
|
||||
v-model="selecnews"
|
||||
variant="outlined"
|
||||
:items="['1', '2', '3', '4', '5', '6']"
|
||||
></v-select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<v-row justify="center">
|
||||
<v-dialog
|
||||
v-model="dialogCommentShow"
|
||||
@@ -299,40 +308,59 @@ export default {
|
||||
const burl = baseURL.slice(0,-1)
|
||||
const textcomment = ref('')
|
||||
const idnews = ref(0)
|
||||
const page = ref(1)
|
||||
const selecnews = ref(2)
|
||||
|
||||
const toggleIncrementLike = (news, scores) => {
|
||||
axiosApiInstance.post(`api/navigation/news/`, {news: news, scores: scores}).then(result => {
|
||||
newss.value[newss.value.findIndex(e=> e.id==news)].scores= result.data
|
||||
// console.log(result.data, 'result.data-----------------')
|
||||
newss.value.result[newss.value.result.findIndex(e=> e.id==news)].scores= result.data
|
||||
})
|
||||
}
|
||||
|
||||
const dateformat = (datas) => {
|
||||
return format(new Date(datas), 'dd.MM.yyyy HH:mm')
|
||||
}
|
||||
|
||||
const newses =() => {
|
||||
|
||||
}
|
||||
|
||||
const openComent = (news) => {
|
||||
dialogCommentShow.value=!dialogCommentShow.value
|
||||
idnews.value = news
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
const addComment = () => {
|
||||
axiosApiInstance.post(`api/navigation/news/`, {news: idnews.value, text: textcomment.value}).then(result => {
|
||||
dialogCommentShow.value=!dialogCommentShow.value
|
||||
newss.value[newss.value.findIndex(e=> e.id==result.data['news'])].comment = result.data.comment
|
||||
|
||||
newss.value.result[newss.value.result.findIndex(e=> e.id==result.data['news'])].comment = result.data.comment
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
const deletComment = (id, news) => {
|
||||
axiosApiInstance.post(`api/navigation/news/`, {delid: id, news: news}).then(result => {
|
||||
newss.value.result[newss.value.result.findIndex(e=> e.id==result.data['news'])].comment = result.data.comment
|
||||
})
|
||||
}
|
||||
|
||||
getfromserver(`api/navigation/news/?name=${props.pages}&page=${page.value-1}&selected=${selecnews.value}`, newss)
|
||||
|
||||
const pagelistNews =() => {
|
||||
getfromserver(`api/navigation/news/?name=${props.pages}&page=${page.value-1}&selected=${selecnews.value}`, newss)
|
||||
}
|
||||
|
||||
watch(()=>accountStore.cod2user ,(newValue,oldValue)=>{
|
||||
if(newValue){
|
||||
getfromserver(`api/navigation/news/?name=${props.pages}&page=${page.value-1}&selected=${selecnews.value}`,newss)
|
||||
}
|
||||
}, {deep:true})
|
||||
|
||||
watch(()=>selecnews ,(newValue,oldValue)=>{
|
||||
if(newValue){
|
||||
getfromserver(`api/navigation/news/?name=${props.pages}&page=${page.value-1}&selected=${newValue.value}`, newss)
|
||||
}
|
||||
}, {deep:true})
|
||||
|
||||
|
||||
|
||||
const dateformat = (datas) => {
|
||||
return format(new Date(datas), 'dd.MM.yyyy HH:mm')
|
||||
}
|
||||
|
||||
|
||||
const openComent = (news) => {
|
||||
dialogCommentShow.value=!dialogCommentShow.value
|
||||
idnews.value = news
|
||||
}
|
||||
|
||||
|
||||
const limitText=(text)=> {
|
||||
const t = text.split(' ').slice(0, 25)
|
||||
return `${text.split(' ').slice(0, 25).join(' ')} ${t.length<25?'':'...'}`
|
||||
@@ -342,24 +370,9 @@ export default {
|
||||
return name.familyname + ' ' + name.name[0] + '.' + name.parentname[0]+ '.'
|
||||
}
|
||||
|
||||
getfromserver(`api/navigation/news/?name=${props.pages}`, newss)
|
||||
|
||||
|
||||
|
||||
watch(()=>accountStore.cod2user ,(newValue,oldValue)=>{
|
||||
if(newValue){
|
||||
getfromserver(`api/navigation/news/`,newss)
|
||||
}
|
||||
}, {deep:true})
|
||||
|
||||
const deletComment = (id, news) => {
|
||||
axiosApiInstance.post(`api/navigation/news/`, {delid: id, news: news}).then(result => {
|
||||
|
||||
newss.value[newss.value.findIndex(e=> e.id==result.data['news'])].comment = result.data.comment
|
||||
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
@@ -376,8 +389,10 @@ export default {
|
||||
addComment,
|
||||
idnews,
|
||||
deletComment,
|
||||
newses,
|
||||
divs
|
||||
pagelistNews,
|
||||
divs,
|
||||
page,
|
||||
selecnews
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,105 +187,9 @@
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
<!-- <v-col class="pointer align-self-center flex-grow-0"
|
||||
|
||||
@click="rail = !rail">
|
||||
<v-icon
|
||||
|
||||
size="20"
|
||||
:icon="rail?'mdi-chevron-right':'mdi-chevron-left'"
|
||||
|
||||
|
||||
/>
|
||||
</v-col> -->
|
||||
</v-row>
|
||||
<!-- <div class="d-flex flex-column h-100">
|
||||
<v-row>
|
||||
<v-col>
|
||||
<v-divider/>
|
||||
<v-list
|
||||
nav
|
||||
density="compact">
|
||||
|
||||
<template v-for="(x, key) in navigations">
|
||||
<v-list-item
|
||||
v-if="!('submenu' in x)"
|
||||
:key="x.key"
|
||||
:title="x.name"
|
||||
:value="x.name"
|
||||
:href="x.link"
|
||||
:to="x.path"
|
||||
color="navigation"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<v-icon
|
||||
|
||||
:icon="x.ico"
|
||||
/>
|
||||
</template>
|
||||
</v-list-item>
|
||||
<v-list-group
|
||||
v-else
|
||||
:key="key"
|
||||
:value="x.name"
|
||||
>
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-list-item
|
||||
v-bind="props"
|
||||
:title="x.name"
|
||||
:prepend-icon="x.ico"
|
||||
/>
|
||||
</template>
|
||||
<v-list-item
|
||||
v-for="(child, k) in x.submenu"
|
||||
|
||||
:href="child.link"
|
||||
:key="k"
|
||||
:value="child.name"
|
||||
:title="child.name"
|
||||
:to="child.path"
|
||||
/>
|
||||
</v-list-group>
|
||||
</template>
|
||||
</v-list>
|
||||
<v-list
|
||||
nav
|
||||
density="compact"
|
||||
>
|
||||
<v-list-item v-for="x of mainmenuStore.portallinks"
|
||||
:key="x.name"
|
||||
:title="x.name"
|
||||
:value="x.name"
|
||||
:href="x.link"
|
||||
color="teal-darken-4"
|
||||
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<v-icon
|
||||
|
||||
:icon="x.imagecode"
|
||||
/>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-row class="flex-grow-0 mb-1 text-caption font-weight-bold text-truncate">
|
||||
<v-col>
|
||||
|
||||
<v-list>
|
||||
|
||||
<v-list-item >
|
||||
<p class="pb-2">Посещений всего: {{ appStore.countvisitor.totalvisit }}</p>
|
||||
<p class="pb-2">Посещений сегодня: {{ appStore.countvisitor.visittoday }}</p>
|
||||
<p class="pb-2">Уникальных посещений: {{ appStore.countvisitor.uniqtoday }}</p>
|
||||
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div> -->
|
||||
|
||||
</v-navigation-drawer>
|
||||
<!-- <v-navigation-drawer
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
class="text-h6 text-grey text-center align-self-center text--lighten-1 font-weight-light"
|
||||
>
|
||||
Безопасность
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
+14
-5
@@ -26,12 +26,20 @@ class NewsAPIView(ListAPIView):
|
||||
permission_classes = (AllowAny,)
|
||||
|
||||
def get(self, request):
|
||||
|
||||
|
||||
# allnews = News.objects.all().count()
|
||||
# print(round(allnews/int(request.GET.get("selected"))), '------------------------------------------------------------------')
|
||||
newsqueryset = News.objects.all().order_by('cdate')
|
||||
allnews =newsqueryset.count()
|
||||
# print(round(allnews/int(request.GET.get("selected"))), '------------------------------------------------------------------')
|
||||
if request.GET.get("name") == "home":
|
||||
newsqueryset = News.objects.all().order_by('cdate')[:10]
|
||||
newsqueryset = newsqueryset[:10]
|
||||
else:
|
||||
newsqueryset = News.objects.all().order_by('cdate')
|
||||
newsqueryset = News.objects.all().order_by('cdate')[int(request.GET.get("page"))*int(request.GET.get("selected")):int(request.GET.get("page"))*int(request.GET.get("selected"))+int(request.GET.get("selected"))]
|
||||
result = []
|
||||
for x in newsqueryset:
|
||||
|
||||
for x in newsqueryset:
|
||||
a=model_to_dict(x)
|
||||
a['link']= str(x.link.url)
|
||||
a['show'] = False
|
||||
@@ -46,8 +54,9 @@ class NewsAPIView(ListAPIView):
|
||||
]
|
||||
|
||||
result.append(a)
|
||||
|
||||
return Response(result)
|
||||
#
|
||||
return Response({"result": result, "allnews": round(allnews/int(request.GET.get("selected")))})
|
||||
|
||||
def post(self, request):
|
||||
|
||||
if 'scores' in request.data:
|
||||
|
||||
Reference in new issue
Block a user