Refactor CommentTab.

pull/9/head
ruibaby 6 years ago
parent 8cda3bc740
commit c2070c808b

@ -118,8 +118,8 @@
<a-list-item-meta> <a-list-item-meta>
<a <a
slot="title" slot="title"
href="javascript:void(0);" :href="options.blog_url+'/archives/'+item.url"
@click="handleEditPostClick(item)" target="_blank"
>{{ item.title }}</a> >{{ item.title }}</a>
</a-list-item-meta> </a-list-item-meta>
<div>{{ item.createTime | timeAgo }}</div> <div>{{ item.createTime | timeAgo }}</div>
@ -297,6 +297,7 @@ import { PageView } from '@/layouts'
import AnalysisCard from './components/AnalysisCard' import AnalysisCard from './components/AnalysisCard'
import RecentCommentTab from './components/RecentCommentTab' import RecentCommentTab from './components/RecentCommentTab'
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import optionApi from '@/api/option'
import postApi from '@/api/post' import postApi from '@/api/post'
import logApi from '@/api/log' import logApi from '@/api/log'
@ -323,6 +324,8 @@ export default {
countsData: {}, countsData: {},
journal: {}, journal: {},
logs: [], logs: [],
options: [],
keys: ['blog_url'],
logPagination: { logPagination: {
page: 1, page: 1,
size: 50, size: 50,
@ -334,6 +337,7 @@ export default {
this.getCounts() this.getCounts()
this.listLatestPosts() this.listLatestPosts()
this.listLatestLogs() this.listLatestLogs()
this.loadOptions()
}, },
computed: { computed: {
formattedPostData() { formattedPostData() {
@ -357,6 +361,11 @@ export default {
} }
}, },
methods: { methods: {
loadOptions() {
optionApi.listAll(this.keys).then(response => {
this.options = response.data.data
})
},
listLatestPosts() { listLatestPosts() {
postApi.listLatest(5).then(response => { postApi.listLatest(5).then(response => {
this.postData = response.data.data this.postData = response.data.data

@ -10,21 +10,33 @@
:key="index" :key="index"
> >
<a-comment :avatar="'//gravatar.loli.net/avatar/'+item.gavatarMd5+'/?s=256&d=mp'"> <a-comment :avatar="'//gravatar.loli.net/avatar/'+item.gavatarMd5+'/?s=256&d=mp'">
<template slot="author" v-if="type==='posts'"> <template
{{ item.author }} 发表在 <a slot="author"
href="javascript:void(0);" v-if="type==='posts'"
>
<a
:href="item.authorUrl"
target="_blank"
>{{ item.author }}</a> 发表在 <a
:href="options.blog_url+'/archives/'+item.post.url"
target="_blank" target="_blank"
>{{ item.post.title }}</a> >{{ item.post.title }}</a>
</template> </template>
<template slot="author" v-else-if="type==='sheets'"> <template
{{ item.author }} 发表在 <a slot="author"
href="javascript:void(0);" v-else-if="type==='sheets'"
>
<a
:href="item.authorUrl"
target="_blank"
>{{ item.author }}</a> 发表在 <a
:href="options.blog_url+'/s/'+item.sheet.url"
target="_blank" target="_blank"
>{{ item.sheet.title }}</a> >{{ item.sheet.title }}</a>
</template> </template>
<template slot="actions"> <!-- <template slot="actions">
<span>回复</span> <span>回复</span>
</template> </template> -->
<p <p
class="comment-content-wrapper" class="comment-content-wrapper"
slot="content" slot="content"
@ -43,6 +55,8 @@
<script> <script>
import commentApi from '@/api/comment' import commentApi from '@/api/comment'
import optionApi from '@/api/option'
import marked from 'marked' import marked from 'marked'
export default { export default {
name: 'RecentCommentTab', name: 'RecentCommentTab',
@ -59,7 +73,9 @@ export default {
data() { data() {
return { return {
comments: [], comments: [],
loading: false loading: false,
options: [],
keys: ['blog_url']
} }
}, },
computed: { computed: {
@ -72,8 +88,14 @@ export default {
}, },
created() { created() {
this.loadComments() this.loadComments()
this.loadOptions()
}, },
methods: { methods: {
loadOptions() {
optionApi.listAll(this.keys).then(response => {
this.options = response.data.data
})
},
loadComments() { loadComments() {
this.loading = true this.loading = true
commentApi.latestComment(this.type, 5, 'PUBLISHED').then(response => { commentApi.latestComment(this.type, 5, 'PUBLISHED').then(response => {

@ -43,19 +43,19 @@
:to="{name:'LinkList'}" :to="{name:'LinkList'}"
v-if="record.id==1" v-if="record.id==1"
> >
<a href="javascript:void(0);">编辑</a> <a href="javascript:void(0);">管理</a>
</router-link> </router-link>
<router-link <router-link
:to="{name:'PhotoList'}" :to="{name:'PhotoList'}"
v-if="record.id==2" v-if="record.id==2"
> >
<a href="javascript:void(0);">编辑</a> <a href="javascript:void(0);">管理</a>
</router-link> </router-link>
<router-link <router-link
:to="{name:'JournalList'}" :to="{name:'JournalList'}"
v-if="record.id==3" v-if="record.id==3"
> >
<a href="javascript:void(0);">编辑</a> <a href="javascript:void(0);">管理</a>
</router-link> </router-link>
<a-divider type="vertical" /> <a-divider type="vertical" />
<a :href="options.blog_url+record.url" target="_blank">查看</a> <a :href="options.blog_url+record.url" target="_blank">查看</a>

Loading…
Cancel
Save