add: 讨论

This commit is contained in:
yi-ge 2020-07-08 18:13:20 +08:00
parent f248fa1d11
commit 2403d74ce9
12 changed files with 266 additions and 52 deletions

View File

@ -5,13 +5,10 @@ module.exports = {
node: true
},
parserOptions: {
parser: 'babel-eslint'
parser: "babel-eslint"
},
extends: [
'@nuxtjs'
],
// add your custom rules here
extends: ["@nuxtjs"],
rules: {
'no-console': 'off'
"no-console": "off"
}
}
};

10
.vscode/settings.json vendored
View File

@ -3,8 +3,16 @@
"Weibo",
"Weixin",
"consola",
"eslintignore",
"fontawesome",
"fortawesome",
"nuxt"
"hljs",
"navication",
"nuxt",
"nuxtjs",
"styl",
"vditor",
"vmodal",
"wangeditor"
]
}

View File

@ -22,6 +22,7 @@
#rightContent
nuxt
Footer
v-dialog
</template>
<script>

View File

@ -8,6 +8,7 @@ section.container
nuxt-link(to='/', v-if='error.statusCode === 404')
.button
| 返回首页
v-dialog
</template>
<script>

View File

@ -6,4 +6,5 @@
footer
.footer
| Copyright © 2020 WangYi. All Rights Reserved.
v-dialog
</template>

View File

@ -81,7 +81,8 @@ module.exports = {
{
src: '~/plugins/browser.js',
ssr: false
}
},
{ src: '~/plugins/vue-js-modal', mode: 'client' }
],
/*

View File

@ -22,8 +22,10 @@
"cross-env": "^6.0.3",
"highlight.js": "^9.17.1",
"koa": "^2.11.0",
"moment": "^2.24.0",
"nuxt": "^2.12.2"
"moment": "^2.27.0",
"nuxt": "^2.12.2",
"vditor": "^3.3.3",
"vue-js-modal": "^2.0.0-rc.3"
},
"devDependencies": {
"@nuxtjs/eslint-config": "^2.0.0",
@ -31,6 +33,7 @@
"eslint": "^6.7.2",
"eslint-config-standard": ">=14.1.0",
"eslint-loader": "^3.0.3",
"eslint-plugin-html": "^6.0.2",
"eslint-plugin-import": ">=2.19.1",
"eslint-plugin-jest": "^23.1.1",
"eslint-plugin-node": ">=10.0.0",

View File

@ -2,43 +2,52 @@
div
article.articleDetails
.articleTitle
| {{ Articels.post_title }}
| {{ articels.post_title }}
.articalMeta
ul
li
Icon(:icon="['far', 'calendar-alt']")
| &nbsp; {{ Articels.post_date }}
| &nbsp; {{ articels.post_date }}
li
Icon(:icon="['far', 'bookmark']")
nuxt-link(v-for='(relationships, index) in Articels.term_relationships', :key='index', v-if='relationships.term_taxonomy', :to="'/' + relationships.term_taxonomy.term.slug")
nuxt-link(v-for='(relationships, index) in articels.term_relationships', :key='index', v-if='relationships.term_taxonomy', :to="'/' + relationships.term_taxonomy.term.slug")
span
| &nbsp; {{ relationships.term_taxonomy.term.name }}
li(v-if='Articels.postmetum.meta_value !== 0')
Icon(:icon="['fas', 'thermometer-' + Articels.hotValue]")
| &nbsp; {{ Articels.postmetum.meta_value }}
#articelToc.articelToc(v-if="Articels.post_toc_show")
li(v-if='articels.postmetum.meta_value !== 0')
Icon(:icon="['fas', 'thermometer-' + articels.hotValue]")
| &nbsp; {{ articels.postmetum.meta_value }}
#articelToc.articelToc(v-if="articels.post_toc_show")
.articelTitle 目录
.articelTocList(v-html="Articels.post_toc")
.articelContent(v-html='Articels.post_content')
ins.adsbygoogle(style="display:block; text-align:center; margin-top:20px;", data-ad-layout="in-article", data-ad-format="fluid", data-ad-client="ca-pub-2143583075951360", data-ad-slot="4741804954")
.articelRightToc(v-show="Articels.post_toc_show && showRightToc", @click="articelRightTocClick")
.articelTitle 目录
.articelTocList(v-html="Articels.post_toc")
p(style="margin: 15px 0;")
img(src="https://cdn.wyr.me/imgs/reward.jpg" style="max-width: 100%; width: 200px")
p(style="margin: 15px 0;") 评论功能已被暂时关闭请通过 a@wyr.me 联系我
nuxt-link(:to="Articels.last ? '/post/' + Articels.last.ID : ''")
.btnFooter.btnPrevt(:style="'color: ' + (Articels.last ? '#333' : '#ccc')")
Icon(:icon="['fas', 'chevron-left']")
| &nbsp; 上一篇 {{ Articels.last ? '(' + decodeTitle(Articels.last.post_name) + ')' : ''}}
nuxt-link(:to="Articels.next ? '/post/' + Articels.next.ID : ''")
.btnFooter.btnNext(:style="'color: ' + (Articels.next ? '#333' : '#ccc')")
| 下一篇 {{ Articels.next ? '(' + decodeTitle(Articels.next.post_name) + ')' : ''}} &nbsp;
Icon(:icon="['fas', 'chevron-right']")
.articelTocList(v-html="articels.post_toc")
.articelContent(v-html='articels.post_content')
.tools
.reward(@click="reward") 打赏
.comment
div(v-for="(item, index) in Comments" :key="index")
| {{ item.comment_content }}
p(style="color: #777; margin-bottom: 30px") 交流区
span(v-if="comments.length") ({{commentAmount}})
#editor
p 说点什么吧...
.comment-item(v-for="(item, index) in comments" :key="index")
.comment-avatar
img(:src="item.comment_author_avatar_url ? item.comment_author_avatar_url : 'https://picsum.photos/200/200/?blur=' + item.user_id")
.comment-area
.comment-author {{ item.comment_author }}
.comment-content {{ item.comment_content }}
.comment-info {{ item.comment_date }}
span.reply 回复
p(v-if="!comments.length", style="color: #cecece; text-align: center; margin-top: 40px") 暂无
ins.adsbygoogle(style="display:block; text-align:center; margin-top:20px;", data-ad-layout="in-article", data-ad-format="fluid", data-ad-client="ca-pub-2143583075951360", data-ad-slot="4741804954")
.articelRightToc(v-show="articels.post_toc_show && showRightToc", @click="articelRightTocClick")
.articelTitle 目录
.articelTocList(v-html="articels.post_toc")
nuxt-link(:to="articels.last ? '/post/' + articels.last.ID : ''")
.btnFooter.btnPrevt(:style="'color: ' + (articels.last ? '#333' : '#ccc')")
Icon(:icon="['fas', 'chevron-left']")
| &nbsp; 上一篇 {{ articels.last ? '(' + decodeTitle(articels.last.post_name) + ')' : ''}}
nuxt-link(:to="articels.next ? '/post/' + articels.next.ID : ''")
.btnFooter.btnNext(:style="'color: ' + (articels.next ? '#333' : '#ccc')")
| 下一篇 {{ articels.next ? '(' + decodeTitle(articels.next.post_name) + ')' : ''}} &nbsp;
Icon(:icon="['fas', 'chevron-right']")
</template>
<script>
@ -58,20 +67,40 @@ export default {
//
const tmp = await $axios.$get(`/public/comments/post?ID=${route.params.id}`)
const comments = tmp.result
console.log(comments)
const comments = tmp.result.list || []
const commentAmount = tmp.result.amount || 0
return {
Articels: result,
Comments: comments,
articels: result,
comments,
commentAmount,
showRightToc: false,
tocIds: result.post_toc_ids
}
},
mounted () {
//
if (process.client) {
if (!window.editorObj && window.WangEditor) {
window.editorObj = new window.Vditor('editor', {
toolbarConfig: {
pin: true
},
cache: {
enable: false
},
after: () => {
this.contentEditor.setValue('hello, Vditor + Vue!')
}
})
// window.editorObj.customConfig.uploadImgShowBase64 = true // 使 base64
// window.editorObj.create()
}
}
this.$finishLoad()
if (this.Articels.post_toc_show) {
if (this.articels.post_toc_show) {
const tocShow = () => {
if (window.addEvent) {
window.addEvent(window, 'scroll', () => {
@ -237,11 +266,17 @@ export default {
const leftBoundingOnScreen = elementLeftToWindowRight >= onScreenWidth
return bottomBoundingOnScreen && topBoundingOnScreen && rightBoundingOnScreen && leftBoundingOnScreen
},
reward () {
this.$modal.show('dialog', {
title: '感谢支持',
text: '<img src="https://cdn.wyr.me/imgs/reward.jpg" style="max-width: 100%; width: 400px"/>'
})
}
},
head () {
return {
title: `${this.Articels.post_title} - 轶哥`
title: `${this.articels.post_title} - 轶哥`
}
}
}
@ -312,6 +347,40 @@ export default {
.comment
width 100%
margin-top 45px
.comment-item
margin-top 20px
.comment-avatar
float left
margin-top 3px
img
border-radius 50%
width 40px
border-style none
cursor pointer
box-sizing border-box
margin 0
.comment-area
margin-left 50px
.comment-author, .comment-info
font-size 10px
.comment-author
color #a1887f
.comment-info
color #777
.reply
color #a1887f
cursor pointer
user-select none
margin-left 10px
.btnFooter
font-size 12px
@ -347,6 +416,7 @@ footer .footer
background-color #000
padding 10px
box-shadow 0 0 8px #000
z-index 999999
.articelToc
width 100%
@ -393,6 +463,22 @@ footer .footer
li
font-weight 300
.tools
margin-top 80px
margin-bottom 10px
text-align center
user-select none
.reward
margin 15px 0
border 1px solid #888
padding 5px 10px
display inline-block
color #888
font-weight 300
cursor pointer
margin auto
@media (max-width: 768px)
.articleDetails
padding 20px

View File

@ -1,4 +1,6 @@
import '~/layouts/common.styl'
import vditor from 'vditor'
import 'vditor/dist/index.css'
const $tags = document.getElementById('tags')
const floatTop = $tags.offsetTop + $tags.scrollHeight + 30
@ -17,7 +19,7 @@ window.addEvent = addEvent
window.onload = function () {
if (navigator.appName === 'Microsoft Internet Explorer' && parseInt(navigator.appVersion.split(';')[1].replace(/[ ]/g, '').replace('MSIE', '')) <= 9) {
alert('您的浏览器版本过低,继续访问将会出现问题,请升级浏览器版本!')
alert('您的浏览器版本过低,继续访问将会出现问题,请升级浏览器版本!') // eslint-disable-line
}
// 底部返回顶部按钮
@ -54,3 +56,5 @@ window.onload = function () {
const s = document.getElementsByTagName('script')[0]
s.parentNode.insertBefore(hm, s)
}
window.Vditor = vditor

4
plugins/vue-js-modal.js Normal file
View File

@ -0,0 +1,4 @@
import Vue from 'vue'
import VModal from 'vue-js-modal'
Vue.use(VModal, { dialog: true })

View File

@ -1,14 +1,62 @@
import Vue from 'vue'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faGithub, faQq, faWeixin, faWeibo, faTwitter, faFacebook, faGooglePlus, faTelegram } from '@fortawesome/free-brands-svg-icons'
import { faEnvelope, faSearch, faThermometerEmpty, faThermometerQuarter, faThermometerHalf, faThermometerThreeQuarters, faThermometerFull, faAngleDoubleUp, faChevronLeft, faChevronRight, faRss } from '@fortawesome/free-solid-svg-icons'
import { faClock, faCalendarAlt, faBookmark } from '@fortawesome/free-regular-svg-icons'
import {
faGithub,
faQq,
faWeixin,
faWeibo,
faTwitter,
faFacebook,
faGooglePlus,
faTelegram
} from '@fortawesome/free-brands-svg-icons'
import {
faEnvelope,
faSearch,
faThermometerEmpty,
faThermometerQuarter,
faThermometerHalf,
faThermometerThreeQuarters,
faThermometerFull,
faAngleDoubleUp,
faChevronLeft,
faChevronRight,
faRss
} from '@fortawesome/free-solid-svg-icons'
import {
faClock,
faCalendarAlt,
faBookmark
} from '@fortawesome/free-regular-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import hljs from 'highlight.js'
import Swiper from '../components/Swiper'
import Slide from '../components/Slide'
library.add(faGithub, faQq, faWeixin, faWeibo, faTwitter, faFacebook, faGooglePlus, faTelegram, faEnvelope, faRss, faSearch, faClock, faCalendarAlt, faBookmark, faThermometerEmpty, faThermometerQuarter, faThermometerHalf, faThermometerThreeQuarters, faThermometerFull, faAngleDoubleUp, faChevronLeft, faChevronRight)
library.add(
faGithub,
faQq,
faWeixin,
faWeibo,
faTwitter,
faFacebook,
faGooglePlus,
faTelegram,
faEnvelope,
faRss,
faSearch,
faClock,
faCalendarAlt,
faBookmark,
faThermometerEmpty,
faThermometerQuarter,
faThermometerHalf,
faThermometerThreeQuarters,
faThermometerFull,
faAngleDoubleUp,
faChevronLeft,
faChevronRight
)
Vue.component('Icon', FontAwesomeIcon)
Vue.component('Swiper', Vue.extend(Swiper))
@ -34,7 +82,10 @@ export default function (ctx, inject) {
})
inject('finishLoad', () => {
Array.prototype.forEach.call(document.querySelectorAll('pre code'), hljs.highlightBlock) // 代码高亮
Array.prototype.forEach.call(
document.querySelectorAll('pre code'),
hljs.highlightBlock
) // 代码高亮
document.getElementById('loading').style.display = 'none' // 隐藏Loading
})
}

View File

@ -3105,6 +3105,11 @@ detect-indent@^5.0.0:
resolved "https://mirrors.huaweicloud.com/repository/npm/detect-indent/-/detect-indent-5.0.0.tgz#3871cc0a6a002e8c3e5b3cf7f336264675f06b9d"
integrity sha1-OHHMCmoALow+Wzz38zYmRnXwa50=
diff-match-patch@^1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/diff-match-patch/-/diff-match-patch-1.0.5.tgz#abb584d5f10cd1196dfc55aa03701592ae3f7b37"
integrity sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw==
diffie-hellman@^5.0.0:
version "5.0.3"
resolved "https://mirrors.huaweicloud.com/repository/npm/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875"
@ -3148,7 +3153,7 @@ dom-converter@^0.2:
dependencies:
utila "~0.4"
dom-serializer@0:
dom-serializer@0, dom-serializer@^0.2.1:
version "0.2.2"
resolved "https://mirrors.huaweicloud.com/repository/npm/dom-serializer/-/dom-serializer-0.2.2.tgz#1afb81f533717175d478655debc5e332d9f9bb51"
integrity sha512-2/xPb3ORsQ42nHYiSunXkDjPLBaEj/xTwUO4B7XCZQTRk7EBtTOPaygh10YAAh2OI1Qrp6NWfpAhzswj0ydt9g==
@ -3178,6 +3183,13 @@ domhandler@^2.3.0:
dependencies:
domelementtype "1"
domhandler@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-3.0.0.tgz#51cd13efca31da95bbb0c5bee3a48300e333b3e9"
integrity sha512-eKLdI5v9m67kbXQbJSNn1zjh0SDzvzWVWtX+qEI3eMjZw8daH9k8rlj1FZY9memPwjiskQFbe7vHVVJIAqoEhw==
dependencies:
domelementtype "^2.0.1"
domutils@1.5.1:
version "1.5.1"
resolved "https://mirrors.huaweicloud.com/repository/npm/domutils/-/domutils-1.5.1.tgz#dcd8488a26f563d61079e48c9f7b7e32373682cf"
@ -3194,6 +3206,15 @@ domutils@^1.5.1, domutils@^1.7.0:
dom-serializer "0"
domelementtype "1"
domutils@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.1.0.tgz#7ade3201af43703fde154952e3a868eb4b635f16"
integrity sha512-CD9M0Dm1iaHfQ1R/TI+z3/JWp/pgub0j4jIQKH89ARR4ATAV2nbaOQS5XxU9maJP5jHaPdDDQSEHuE2UmpUTKg==
dependencies:
dom-serializer "^0.2.1"
domelementtype "^2.0.1"
domhandler "^3.0.0"
dot-prop@^5.2.0:
version "5.2.0"
resolved "https://mirrors.huaweicloud.com/repository/npm/dot-prop/-/dot-prop-5.2.0.tgz#c34ecc29556dc45f1f4c22697b6f4904e0cc4fcb"
@ -3420,6 +3441,13 @@ eslint-plugin-es@^3.0.0:
eslint-utils "^2.0.0"
regexpp "^3.0.0"
eslint-plugin-html@^6.0.2:
version "6.0.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-html/-/eslint-plugin-html-6.0.2.tgz#fcbd293e218d03dd72c147fc999d185c6f5989fe"
integrity sha512-Ik/z32UteKLo8GEfwNqVKcJ/WOz/be4h8N5mbMmxxnZ+9aL9XczOXQFz/bGu+nAGVoRg8CflldxJhONFpqlrxw==
dependencies:
htmlparser2 "^4.1.0"
eslint-plugin-import@2.19.1:
version "2.19.1"
resolved "https://mirrors.huaweicloud.com/repository/npm/eslint-plugin-import/-/eslint-plugin-import-2.19.1.tgz#5654e10b7839d064dd0d46cd1b88ec2133a11448"
@ -4393,6 +4421,16 @@ htmlparser2@^3.3.0:
inherits "^2.0.1"
readable-stream "^3.1.1"
htmlparser2@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-4.1.0.tgz#9a4ef161f2e4625ebf7dfbe6c0a2f52d18a59e78"
integrity sha512-4zDq1a1zhE4gQso/c5LP1OtrhYTncXNSpvJYtWJBtXAETPlMfi3IFNjGuQbYLuVY4ZR0QMqRVvo4Pdy9KLyP8Q==
dependencies:
domelementtype "^2.0.1"
domhandler "^3.0.0"
domutils "^2.0.0"
entities "^2.0.0"
http-assert@^1.3.0:
version "1.4.1"
resolved "https://mirrors.huaweicloud.com/repository/npm/http-assert/-/http-assert-1.4.1.tgz#c5f725d677aa7e873ef736199b89686cceb37878"
@ -5606,10 +5644,10 @@ mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.3, mkdirp@~0.5.1, mkdirp@~0.5.x:
dependencies:
minimist "^1.2.5"
moment@^2.24.0:
version "2.25.1"
resolved "https://mirrors.huaweicloud.com/repository/npm/moment/-/moment-2.25.1.tgz#1cb546dca1eccdd607c9324747842200b683465d"
integrity sha512-nRKMf9wDS4Fkyd0C9LXh2FFXinD+iwbJ5p/lh3CHitW9kZbRbJ8hCruiadiIXZVbeAqKZzqcTvHnK3mRhFjb6w==
moment@^2.27.0:
version "2.27.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.27.0.tgz#8bff4e3e26a236220dfe3e36de756b6ebaa0105d"
integrity sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==
move-concurrently@^1.0.1:
version "1.0.1"
@ -7502,6 +7540,11 @@ reserved-words@^0.1.2:
resolved "https://mirrors.huaweicloud.com/repository/npm/reserved-words/-/reserved-words-0.1.2.tgz#00a0940f98cd501aeaaac316411d9adc52b31ab1"
integrity sha1-AKCUD5jNUBrqqsMWQR2a3FKzGrE=
resize-observer-polyfill@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"
integrity sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==
resolve-from@^3.0.0:
version "3.0.0"
resolved "https://mirrors.huaweicloud.com/repository/npm/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748"
@ -8790,6 +8833,13 @@ vary@^1.1.2, vary@~1.1.2:
resolved "https://mirrors.huaweicloud.com/repository/npm/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=
vditor@^3.3.3:
version "3.3.3"
resolved "https://registry.yarnpkg.com/vditor/-/vditor-3.3.3.tgz#fbab16bf259e060a9502aa8a146943a70cd757f1"
integrity sha512-Z3rcpW9UWeI3VxQ4K3nNfEN2iC7aflwCVZMTlm2x+X+90EFaOKzgEQEizo+tma+hXcyhhb5UeTnmabVwoDKjNQ==
dependencies:
diff-match-patch "^1.0.4"
vendors@^1.0.0:
version "1.0.4"
resolved "https://mirrors.huaweicloud.com/repository/npm/vendors/-/vendors-1.0.4.tgz#e2b800a53e7a29b93506c3cf41100d16c4c4ad8e"
@ -8827,6 +8877,13 @@ vue-hot-reload-api@^2.3.0:
resolved "https://mirrors.huaweicloud.com/repository/npm/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz#532955cc1eb208a3d990b3a9f9a70574657e08f2"
integrity sha512-BXq3jwIagosjgNVae6tkHzzIk6a8MHFtzAdwhnV5VlvPTFxDCvIttgSiHWjdGoTJvXtmRu5HacExfdarRcFhog==
vue-js-modal@^2.0.0-rc.3:
version "2.0.0-rc.3"
resolved "https://registry.yarnpkg.com/vue-js-modal/-/vue-js-modal-2.0.0-rc.3.tgz#c34b33305af10b4ccecdbb381dd58efbb19e2862"
integrity sha512-Q9L9FsIUMuzCKSuB41D8LxV+Yc2q+zWHzzUdWaQ2KeHPS+78+X6AAnBztVoophbjt8UXHO7rQSRgER1MMw5qsw==
dependencies:
resize-observer-polyfill "^1.5.1"
vue-loader@^15.9.1:
version "15.9.2"
resolved "https://mirrors.huaweicloud.com/repository/npm/vue-loader/-/vue-loader-15.9.2.tgz#ae01f5f4c9c6a04bff4483912e72ef91a402c1ae"