2020-06-19 17:37:45 +08:00
|
|
|
<template>
|
2020-06-23 17:40:43 +08:00
|
|
|
<el-row class="article__wrapper">
|
2020-08-02 23:55:08 +08:00
|
|
|
<el-col>
|
|
|
|
<el-card>
|
|
|
|
<div class="card-body d-flex flex-column article">
|
|
|
|
<div class="article__item">
|
2020-12-18 14:13:03 +08:00
|
|
|
<h1 class="list__title">
|
|
|
|
<span v-if="isPerfect" style="color: gold;" title="优选">
|
2021-07-29 11:22:52 +08:00
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"
|
|
|
|
style="fill: #FFB71B;"><path
|
|
|
|
d="M12 22c3.859 0 7-3.141 7-7s-3.141-7-7-7c-3.86 0-7 3.141-7 7s3.14 7 7 7zm0-12c2.757 0 5 2.243 5 5s-2.243 5-5 5-5-2.243-5-5 2.243-5 5-5zm-1-8H7v5.518a8.957 8.957 0 0 1 4-1.459V2zm6 0h-4v4.059a8.957 8.957 0 0 1 4 1.459V2z"></path><path
|
|
|
|
d="m10.019 15.811-.468 2.726L12 17.25l2.449 1.287-.468-2.726 1.982-1.932-2.738-.398L12 11l-1.225 2.481-2.738.398z"></path></svg>
|
2020-12-18 14:13:03 +08:00
|
|
|
</span>
|
|
|
|
{{ article.articleTitle }}
|
|
|
|
</h1>
|
2020-08-02 23:55:08 +08:00
|
|
|
<el-row class="pt-5">
|
|
|
|
<el-col :xs="3" :sm="1" :xl="1">
|
|
|
|
<el-avatar v-if="article.articleAuthorAvatarUrl" :src="article.articleAuthorAvatarUrl"></el-avatar>
|
|
|
|
<el-avatar v-else src="https://static.rymcu.com/article/1578475481946.png"></el-avatar>
|
|
|
|
</el-col>
|
|
|
|
<el-col :xs="9" :sm="11" :xl="11">
|
|
|
|
<div style="margin-left: 1rem;">
|
2021-07-29 11:22:52 +08:00
|
|
|
<el-link :href="'/user/' + article.articleAuthor.userAccount" class="text-default">
|
|
|
|
{{ article.articleAuthorName }}
|
2020-07-03 11:04:25 +08:00
|
|
|
</el-link>
|
2020-08-02 23:55:08 +08:00
|
|
|
<small class="d-block text-muted">{{ article.timeAgo }}</small>
|
|
|
|
</div>
|
|
|
|
</el-col>
|
|
|
|
<el-col :xs="12" :sm="12" :xl="12" v-if="user" class="text-right">
|
2020-10-24 23:37:27 +08:00
|
|
|
<el-link rel="nofollow" :underline="false" title="总浏览数"><i class="el-icon-s-data"></i><span
|
|
|
|
style="color: red;">{{ article.articleViewCount }}</span>
|
2020-08-02 23:55:08 +08:00
|
|
|
</el-link>
|
|
|
|
</el-col>
|
|
|
|
<el-col style="margin: 1rem 0;">
|
2020-09-27 22:34:26 +08:00
|
|
|
<el-col :span="12">
|
|
|
|
<el-tag
|
|
|
|
style="margin-right: 0.5rem;"
|
|
|
|
v-for="tag in article.tags"
|
|
|
|
:key="tag.idTag"
|
|
|
|
size="small"
|
|
|
|
effect="plain">
|
|
|
|
# {{ tag.tagTitle }}
|
|
|
|
</el-tag>
|
|
|
|
</el-col>
|
2020-09-27 23:15:51 +08:00
|
|
|
<el-col v-if="user" :span="12" style="text-align: right;">
|
|
|
|
<template v-if="user.idUser !== article.articleAuthorId">
|
2021-08-24 22:33:42 +08:00
|
|
|
<el-button size="mini" v-if="isFollower(article.articleAuthorId)" @click="cancelFollowUser(article.articleAuthorId)" plain>
|
2020-10-24 23:37:27 +08:00
|
|
|
取消关注
|
|
|
|
</el-button>
|
2020-09-28 00:37:14 +08:00
|
|
|
<el-button size="mini" v-else @click="followUser(article.articleAuthorId)" plain>关注</el-button>
|
2020-09-27 23:15:51 +08:00
|
|
|
</template>
|
2020-09-28 00:37:14 +08:00
|
|
|
<el-button size="mini" v-if="hasPermissions" @click="handleCommand('edit')" plain>编辑文章</el-button>
|
2020-12-18 14:13:03 +08:00
|
|
|
<template v-if="isAdmin">
|
|
|
|
<el-button size="mini" @click="handleCommand('editTag')" plain>编辑标签</el-button>
|
|
|
|
<el-button v-if="isPerfect" size="mini" @click="cancelPreference" plain>取消优选</el-button>
|
|
|
|
<el-button v-else size="mini" @click="setPreference" plain>设为优选</el-button>
|
|
|
|
</template>
|
2020-09-28 00:37:14 +08:00
|
|
|
<el-button size="mini" @click="handleCommand('share')" plain>分享</el-button>
|
2020-09-27 22:34:26 +08:00
|
|
|
</el-col>
|
2020-09-27 23:15:51 +08:00
|
|
|
<el-col v-else :span="12" style="text-align: right;">
|
2020-09-28 00:37:14 +08:00
|
|
|
<el-button size="mini" @click="gotoLogin" plain>关注</el-button>
|
|
|
|
<el-button size="mini" @click="handleCommand('share')" plain>分享</el-button>
|
2020-09-27 23:15:51 +08:00
|
|
|
</el-col>
|
2020-08-02 23:55:08 +08:00
|
|
|
</el-col>
|
|
|
|
<el-col v-if="isShare" style="margin-bottom: 1rem;">
|
|
|
|
<share-box :url="shareData.shareUrl"></share-box>
|
|
|
|
</el-col>
|
2020-10-24 23:37:27 +08:00
|
|
|
<el-col v-if="article.portfolios && article.portfolios.length > 0">
|
|
|
|
<portfolios-widget :portfolios="article.portfolios"></portfolios-widget>
|
|
|
|
</el-col>
|
2020-08-02 23:55:08 +08:00
|
|
|
</el-row>
|
|
|
|
<div class="pt-7 pipe-content__reset vditor-reset" id="articleContent" v-html="article.articleContent"
|
|
|
|
style="overflow: hidden;"></div>
|
2020-06-23 17:40:43 +08:00
|
|
|
</div>
|
2020-12-28 16:45:11 +08:00
|
|
|
<el-row>
|
|
|
|
<el-col v-if="article.portfolios && article.portfolios.length > 0">
|
|
|
|
<portfolios-widget :portfolios="article.portfolios"></portfolios-widget>
|
|
|
|
</el-col>
|
|
|
|
<el-col v-if="user">
|
2021-07-29 11:22:52 +08:00
|
|
|
<el-tooltip class="item" effect="dark" content="酷" placement="top-start">
|
2020-12-28 16:45:11 +08:00
|
|
|
<el-button type="text" style="font-size: 1.2rem;" @click="thumbsUp">
|
2021-07-29 11:22:52 +08:00
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
|
|
|
|
style="fill: rgba(0, 0, 0, 1);">
|
|
|
|
<path
|
|
|
|
d="M14.683 14.828a4.055 4.055 0 0 1-1.272.858 4.002 4.002 0 0 1-4.875-1.45l-1.658 1.119a6.063 6.063 0 0 0 1.621 1.62 5.963 5.963 0 0 0 2.148.903 6.035 6.035 0 0 0 3.542-.35 6.048 6.048 0 0 0 1.907-1.284c.272-.271.52-.571.734-.889l-1.658-1.119a4.147 4.147 0 0 1-.489.592z"></path>
|
|
|
|
<path
|
|
|
|
d="M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 2c2.953 0 5.531 1.613 6.918 4H5.082C6.469 5.613 9.047 4 12 4zm0 16c-4.411 0-8-3.589-8-8 0-.691.098-1.359.264-2H5v1a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2h2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-1h.736c.166.641.264 1.309.264 2 0 4.411-3.589 8-8 8z"></path>
|
|
|
|
</svg>
|
2020-12-28 16:45:11 +08:00
|
|
|
{{ article.articleThumbsUpCount }}
|
|
|
|
</el-button>
|
|
|
|
</el-tooltip>
|
|
|
|
<el-tooltip class="item" effect="dark" content="赞赏" placement="top-start">
|
2021-07-29 16:14:54 +08:00
|
|
|
<el-button v-if="user.idUser === article.articleAuthorId" type="text"
|
2021-07-29 11:22:52 +08:00
|
|
|
style="font-size: 1.2rem;">
|
|
|
|
<svg width="24" height="24">
|
|
|
|
<path :d="buymeacoffee.path"></path>
|
|
|
|
</svg>
|
2020-12-28 16:45:11 +08:00
|
|
|
{{ article.articleSponsorCount }}
|
|
|
|
</el-button>
|
|
|
|
<el-popconfirm
|
|
|
|
v-else
|
|
|
|
title="赞赏本文作者 20 巴旦木?"
|
|
|
|
@confirm="sponsor"
|
|
|
|
>
|
2021-07-29 16:14:54 +08:00
|
|
|
<el-button slot="reference" type="text" style="font-size: 1.2rem;">
|
|
|
|
<svg width="24" height="24">
|
|
|
|
<path :d="buymeacoffee.path"></path>
|
|
|
|
</svg>
|
2020-12-28 16:45:11 +08:00
|
|
|
{{ article.articleSponsorCount }}
|
|
|
|
</el-button>
|
|
|
|
</el-popconfirm>
|
|
|
|
</el-tooltip>
|
|
|
|
</el-col>
|
|
|
|
<el-col v-else>
|
2021-07-29 11:22:52 +08:00
|
|
|
<el-tooltip class="item" effect="dark" content="酷" placement="top-start">
|
2020-12-28 16:45:11 +08:00
|
|
|
<el-button type="text" style="font-size: 1.2rem;">
|
2021-07-29 11:22:52 +08:00
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
|
2021-07-29 16:14:54 +08:00
|
|
|
style="fill: rgba(0, 0, 0, 1);">
|
2021-07-29 11:22:52 +08:00
|
|
|
<path
|
|
|
|
d="M14.683 14.828a4.055 4.055 0 0 1-1.272.858 4.002 4.002 0 0 1-4.875-1.45l-1.658 1.119a6.063 6.063 0 0 0 1.621 1.62 5.963 5.963 0 0 0 2.148.903 6.035 6.035 0 0 0 3.542-.35 6.048 6.048 0 0 0 1.907-1.284c.272-.271.52-.571.734-.889l-1.658-1.119a4.147 4.147 0 0 1-.489.592z"></path>
|
|
|
|
<path
|
|
|
|
d="M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 2c2.953 0 5.531 1.613 6.918 4H5.082C6.469 5.613 9.047 4 12 4zm0 16c-4.411 0-8-3.589-8-8 0-.691.098-1.359.264-2H5v1a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2h2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-1h.736c.166.641.264 1.309.264 2 0 4.411-3.589 8-8 8z"></path>
|
|
|
|
</svg>
|
2020-12-28 16:45:11 +08:00
|
|
|
{{ article.articleThumbsUpCount }}
|
|
|
|
</el-button>
|
|
|
|
</el-tooltip>
|
|
|
|
<el-tooltip class="item" effect="dark" content="赞赏" placement="top-start">
|
2021-07-29 11:22:52 +08:00
|
|
|
<el-button type="text" style="font-size: 1.2rem;">
|
|
|
|
<svg width="24" height="24">
|
|
|
|
<path :d="buymeacoffee.path"></path>
|
|
|
|
</svg>
|
2020-12-28 16:45:11 +08:00
|
|
|
{{ article.articleSponsorCount }}
|
|
|
|
</el-button>
|
|
|
|
</el-tooltip>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
2020-08-02 23:55:08 +08:00
|
|
|
</div>
|
|
|
|
</el-card>
|
2020-06-23 17:40:43 +08:00
|
|
|
</el-col>
|
2020-08-02 23:55:08 +08:00
|
|
|
<el-col>
|
|
|
|
<comment-box :fetching="isFetching" :user="user" :avatar="avatar" :title="article.articleTitle"
|
2021-08-24 22:33:42 +08:00
|
|
|
:post-id="routeArticleId" :authorId="article.articleAuthorId" @gotoLogin="gotoLogin"></comment-box>
|
2020-06-23 17:40:43 +08:00
|
|
|
</el-col>
|
2020-09-23 22:39:36 +08:00
|
|
|
<el-col>
|
|
|
|
<el-dialog :visible.sync="dialogVisible">
|
|
|
|
<edit-tags
|
|
|
|
:idArticle="article.idArticle"
|
|
|
|
:tags="article.articleTags"
|
|
|
|
@closeDialog="closeTagsDialog">
|
|
|
|
</edit-tags>
|
|
|
|
</el-dialog>
|
|
|
|
</el-col>
|
2020-06-23 17:40:43 +08:00
|
|
|
</el-row>
|
2020-06-19 17:37:45 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-10-24 23:37:27 +08:00
|
|
|
import Vue from 'vue';
|
2020-12-28 16:45:11 +08:00
|
|
|
import {mapState} from 'vuex';
|
2020-10-24 23:37:27 +08:00
|
|
|
import ShareBox from '~/components/widget/share';
|
|
|
|
import PortfoliosWidget from '~/components/widget/portfolios';
|
|
|
|
import EditTags from '~/components/widget/tags';
|
2021-03-29 09:58:58 +08:00
|
|
|
import 'vditor/dist/css/content-theme/light.css';
|
2021-07-29 11:22:52 +08:00
|
|
|
import {buymeacoffee} from "simple-icons"
|
2020-06-30 17:50:32 +08:00
|
|
|
|
2020-10-24 23:37:27 +08:00
|
|
|
export default {
|
|
|
|
name: "ArticleDetail",
|
|
|
|
components: {
|
|
|
|
ShareBox,
|
|
|
|
PortfoliosWidget,
|
|
|
|
EditTags
|
|
|
|
},
|
|
|
|
validate({params, store}) {
|
|
|
|
return params.article_id && !isNaN(Number(params.article_id))
|
|
|
|
},
|
|
|
|
fetch({store, params, error}) {
|
|
|
|
return Promise.all([
|
|
|
|
store
|
|
|
|
.dispatch('article/fetchDetail', params)
|
|
|
|
.catch(err => error({statusCode: 404})),
|
|
|
|
store.dispatch('comment/fetchList', {post_id: params.article_id})
|
|
|
|
])
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState({
|
|
|
|
article: state => state.article.detail.data,
|
|
|
|
isFetching: state => state.article.detail.fetching,
|
|
|
|
isMobile: state => state.global.isMobile,
|
|
|
|
user: state => state.oauth,
|
|
|
|
avatar: state => state.userInfo?.avatarURL
|
|
|
|
}),
|
|
|
|
hasPermissions() {
|
|
|
|
let account = this.$store.state.userInfo?.nickname;
|
|
|
|
if (account) {
|
|
|
|
if (account === this.article.articleAuthor.userNickname) {
|
|
|
|
return true;
|
2020-07-03 11:04:25 +08:00
|
|
|
}
|
|
|
|
}
|
2022-01-03 19:11:23 +08:00
|
|
|
return false;
|
2020-06-23 17:40:43 +08:00
|
|
|
},
|
2020-10-24 23:37:27 +08:00
|
|
|
isAdmin() {
|
|
|
|
return this.$store.getters.hasPermissions('blog_admin');
|
2020-06-30 17:50:32 +08:00
|
|
|
},
|
2020-10-24 23:37:27 +08:00
|
|
|
routeArticleId() {
|
2020-12-18 14:13:03 +08:00
|
|
|
return Number(this.$route.params.article_id);
|
2020-10-24 23:37:27 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
head() {
|
|
|
|
return {
|
|
|
|
title: this.article.articleTitle || 'RYMCU - 嵌入式知识学习交流平台',
|
|
|
|
meta: [
|
|
|
|
{
|
|
|
|
name: 'keywords',
|
|
|
|
content: this.article.articleTags || 'RYMCU'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'description',
|
|
|
|
content: this.article.articlePreviewContent
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'site_name',
|
|
|
|
content: 'RYMCU'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'url',
|
|
|
|
content: this.article.articlePermalink
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'og:title',
|
|
|
|
content: this.article.articleTitle + ' - RYMCU'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'og:description',
|
|
|
|
content: this.article.articlePreviewContent
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'og:site_name',
|
|
|
|
content: 'RYMCU'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'og:url',
|
|
|
|
content: this.article.articlePermalink
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2021-07-29 11:22:52 +08:00
|
|
|
buymeacoffee,
|
2020-10-24 23:37:27 +08:00
|
|
|
loading: false,
|
|
|
|
isShare: false,
|
|
|
|
dialogVisible: false,
|
2020-12-18 14:13:03 +08:00
|
|
|
isPerfect: false,
|
2020-10-24 23:37:27 +08:00
|
|
|
shareData: {}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onRouter(name, data) {
|
|
|
|
this.$router.push(
|
|
|
|
{
|
|
|
|
path: `/${name}/${data}`
|
|
|
|
}
|
|
|
|
)
|
2020-06-29 21:30:58 +08:00
|
|
|
},
|
2020-10-24 23:37:27 +08:00
|
|
|
handleCommand(item) {
|
|
|
|
let _ts = this;
|
|
|
|
if (item === 'edit') {
|
|
|
|
_ts.$router.push({
|
|
|
|
path: `/article/post/${_ts.article.idArticle}`
|
|
|
|
})
|
|
|
|
} else if (item === 'editTag') {
|
|
|
|
_ts.$set(_ts, 'dialogVisible', true);
|
|
|
|
} else {
|
|
|
|
if (_ts.isShare) {
|
|
|
|
_ts.$set(_ts, 'isShare', false);
|
2020-06-29 21:30:58 +08:00
|
|
|
} else {
|
2020-10-24 23:37:27 +08:00
|
|
|
if (_ts.user) {
|
|
|
|
_ts.$axios.$get('/api/article/' + _ts.article.idArticle + '/share').then(function (res) {
|
|
|
|
if (res) {
|
|
|
|
_ts.$set(_ts, 'shareData', res);
|
|
|
|
_ts.$set(_ts, 'isShare', true);
|
|
|
|
}
|
|
|
|
});
|
2020-09-27 22:34:26 +08:00
|
|
|
} else {
|
2020-10-24 23:37:27 +08:00
|
|
|
_ts.$set(_ts, 'shareData', {shareUrl: _ts.article.articlePermalink});
|
|
|
|
_ts.$set(_ts, 'isShare', true);
|
2020-09-27 22:34:26 +08:00
|
|
|
}
|
2020-06-29 21:30:58 +08:00
|
|
|
}
|
2020-10-24 23:37:27 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
gotoLogin() {
|
|
|
|
this.$router.push({
|
2020-12-18 14:13:03 +08:00
|
|
|
name: 'login',
|
|
|
|
query: {
|
|
|
|
historyUrl: window.location.href
|
|
|
|
}
|
2020-10-24 23:37:27 +08:00
|
|
|
})
|
|
|
|
},
|
|
|
|
closeTagsDialog() {
|
|
|
|
this.$set(this, 'dialogVisible', false);
|
2020-12-28 16:45:11 +08:00
|
|
|
this.$store.dispatch('article/fetchDetail', this.$route.params);
|
2020-10-24 23:37:27 +08:00
|
|
|
},
|
|
|
|
followUser(idUser) {
|
|
|
|
let _ts = this;
|
|
|
|
if (_ts.user) {
|
|
|
|
_ts.$axios.$post('/api/follow', {
|
|
|
|
followingId: idUser,
|
|
|
|
followingType: 0
|
|
|
|
}).then(function (res) {
|
|
|
|
_ts.$set(_ts, 'isFollow', res);
|
2021-08-24 22:33:42 +08:00
|
|
|
_ts.$store.dispatch('follow/fetchUserFollowingList');
|
2020-06-29 21:30:58 +08:00
|
|
|
})
|
2020-10-24 23:37:27 +08:00
|
|
|
} else {
|
2020-12-28 16:45:11 +08:00
|
|
|
_ts.gotoLogin();
|
2020-06-29 21:30:58 +08:00
|
|
|
}
|
|
|
|
},
|
2020-10-24 23:37:27 +08:00
|
|
|
cancelFollowUser(idUser) {
|
2020-09-28 00:52:38 +08:00
|
|
|
let _ts = this;
|
|
|
|
if (_ts.user) {
|
2020-10-24 23:37:27 +08:00
|
|
|
_ts.$axios.$post('/api/follow/cancel-follow', {
|
|
|
|
followingId: idUser,
|
|
|
|
followingType: 0
|
2020-09-28 00:52:38 +08:00
|
|
|
}).then(function (res) {
|
|
|
|
_ts.$set(_ts, 'isFollow', res);
|
2021-08-24 22:33:42 +08:00
|
|
|
_ts.$store.dispatch('follow/fetchUserFollowingList');
|
2020-09-28 00:52:38 +08:00
|
|
|
})
|
2020-10-24 23:37:27 +08:00
|
|
|
} else {
|
2020-12-28 16:45:11 +08:00
|
|
|
_ts.gotoLogin();
|
2020-09-28 00:52:38 +08:00
|
|
|
}
|
2020-12-18 14:13:03 +08:00
|
|
|
},
|
|
|
|
setPreference() {
|
|
|
|
let _ts = this;
|
2022-01-03 19:11:23 +08:00
|
|
|
_ts.$axios.$patch("/api/admin/article/update-perfect", {
|
2020-12-18 14:13:03 +08:00
|
|
|
idArticle: _ts.article.idArticle,
|
|
|
|
articlePerfect: '1',
|
|
|
|
}).then(function (res) {
|
|
|
|
if (res) {
|
|
|
|
if (res.success) {
|
|
|
|
_ts.$set(_ts, 'isPerfect', false);
|
|
|
|
_ts.$message.success("设置成功!");
|
|
|
|
} else {
|
|
|
|
_ts.$message.error(_ts.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
cancelPreference() {
|
|
|
|
let _ts = this;
|
2022-01-03 19:11:23 +08:00
|
|
|
_ts.$axios.$patch("/api/admin/article/update-perfect", {
|
2020-12-18 14:13:03 +08:00
|
|
|
idArticle: _ts.article.idArticle,
|
|
|
|
articlePerfect: '0',
|
|
|
|
}).then(function (res) {
|
|
|
|
if (res) {
|
|
|
|
if (res.success) {
|
|
|
|
_ts.$set(_ts, 'isPerfect', true);
|
|
|
|
_ts.$message.success("取消成功!");
|
|
|
|
} else {
|
|
|
|
_ts.$message.error(_ts.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2020-12-28 16:45:11 +08:00
|
|
|
},
|
|
|
|
thumbsUp() {
|
|
|
|
let _ts = this;
|
|
|
|
_ts.$axios.$post('/api/article/thumbs-up', {
|
|
|
|
idArticle: _ts.article.idArticle
|
|
|
|
}).then(function (res) {
|
|
|
|
if (res) {
|
|
|
|
if (res.success) {
|
|
|
|
_ts.$message.success(res.message);
|
|
|
|
_ts.$store.dispatch('article/updateThumbsUpCount', {thumbsUpNumber: res.thumbsUpNumber})
|
|
|
|
} else {
|
|
|
|
_ts.$message.error(_ts.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
sponsor() {
|
|
|
|
let _ts = this;
|
|
|
|
_ts.$axios.$post('/api/article/sponsor', {
|
|
|
|
dataType: '0',
|
|
|
|
dataId: _ts.article.idArticle
|
|
|
|
}).then(function (res) {
|
|
|
|
if (res) {
|
|
|
|
if (res.success) {
|
|
|
|
_ts.$message.success(res.message);
|
|
|
|
_ts.$store.dispatch('article/updateSponsorCount', {sponsorNumber: 1})
|
|
|
|
} else {
|
|
|
|
_ts.$message.error(_ts.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2021-08-24 22:33:42 +08:00
|
|
|
},
|
|
|
|
isFollower(idUser) {
|
|
|
|
return this.$store.getters["follow/isFollower"](idUser)
|
2020-06-19 17:37:45 +08:00
|
|
|
}
|
2020-10-24 23:37:27 +08:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
let _ts = this;
|
|
|
|
_ts.$store.commit('setActiveMenu', 'articleDetail');
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
const previewElement = document.getElementById("articleContent");
|
|
|
|
// //const outLineElement = document.getElementById("articleToC");
|
|
|
|
// VditorPreview.setContentTheme('light');
|
|
|
|
Vue.VditorPreview.codeRender(previewElement, 'zh_CN');
|
|
|
|
Vue.VditorPreview.highlightRender({"enable": true, "lineNumber": true, "style": "github"}, previewElement);
|
|
|
|
Vue.VditorPreview.mathRender(previewElement, {
|
|
|
|
math: {"engine": "KaTeX", "inlineDigit": false, "macros": {}},
|
|
|
|
});
|
2020-11-30 20:42:51 +08:00
|
|
|
Vue.VditorPreview.mermaidRender(previewElement);
|
2020-10-24 23:37:27 +08:00
|
|
|
Vue.VditorPreview.graphvizRender(previewElement);
|
|
|
|
Vue.VditorPreview.chartRender(previewElement);
|
|
|
|
Vue.VditorPreview.mindmapRender(previewElement);
|
|
|
|
Vue.VditorPreview.abcRender(previewElement);
|
|
|
|
Vue.VditorPreview.mediaRender(previewElement);
|
|
|
|
Vue.VditorPreview.lazyLoadImageRender(previewElement);
|
|
|
|
//VditorPreview.outlineRender(previewElement, outLineElement);
|
2021-03-29 09:58:58 +08:00
|
|
|
previewElement.addEventListener("click", (event) => {
|
|
|
|
if (event.target.tagName === "IMG") {
|
|
|
|
Vue.VditorPreview.previewImage(event.target);
|
|
|
|
}
|
|
|
|
});
|
2020-12-18 14:13:03 +08:00
|
|
|
_ts.$set(_ts, 'isPerfect', _ts.article.articlePerfect === '1')
|
2020-10-24 23:37:27 +08:00
|
|
|
})
|
2020-06-23 17:40:43 +08:00
|
|
|
}
|
2020-10-24 23:37:27 +08:00
|
|
|
|
|
|
|
}
|
2020-06-23 17:40:43 +08:00
|
|
|
</script>
|
2020-06-19 17:37:45 +08:00
|
|
|
|
2020-06-23 17:40:43 +08:00
|
|
|
<style lang="scss">
|
2020-10-24 23:37:27 +08:00
|
|
|
@import "~vditor/src/assets/scss/index.scss";
|
2020-07-03 11:04:25 +08:00
|
|
|
|
2020-10-24 23:37:27 +08:00
|
|
|
.article__wrapper {
|
|
|
|
max-width: 980px;
|
2021-02-23 16:36:52 +08:00
|
|
|
margin: 20px auto;
|
2020-10-24 23:37:27 +08:00
|
|
|
display: block;
|
|
|
|
padding-left: 1rem;
|
|
|
|
padding-right: 1rem;
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
2020-06-19 17:37:45 +08:00
|
|
|
</style>
|