添加评论
This commit is contained in:
parent
0cbd50eeda
commit
80192652ed
12
layouts/auth.vue
Normal file
12
layouts/auth.vue
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<template lang="pug">
|
||||||
|
.content
|
||||||
|
#loading.allSpinner
|
||||||
|
.spinner
|
||||||
|
.bounce1
|
||||||
|
.bounce2
|
||||||
|
.bounce3
|
||||||
|
.container
|
||||||
|
.page-container
|
||||||
|
nuxt
|
||||||
|
v-dialog
|
||||||
|
</template>
|
42
pages/auth.vue
Normal file
42
pages/auth.vue
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<template lang="pug">
|
||||||
|
.auth(v-html="notice")
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
layout: 'auth',
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
notice: 'Loading...'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async mounted () {
|
||||||
|
const code = this.$route.query.code
|
||||||
|
|
||||||
|
if (!code) { this.notice = '<p style="color: #999">非法访问,缺少授权参数"code"。<p><br><br> <a href="https://www.wyr.me" target="_blank">返回首页<a>' }
|
||||||
|
|
||||||
|
const { data } = await this.$axios.post('/visitor/user/auth', {
|
||||||
|
type: 'github',
|
||||||
|
code
|
||||||
|
})
|
||||||
|
|
||||||
|
if (data.status !== 1) {
|
||||||
|
this.notice = '<p style="color: #999">授权失败,请再试一次。<p><br><br> <a href="https://www.wyr.me" target="_blank">返回首页<a>'
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(data)
|
||||||
|
|
||||||
|
this.$finishLoad()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="stylus" scoped>
|
||||||
|
.auth
|
||||||
|
width 100%
|
||||||
|
height 100%
|
||||||
|
padding 50px
|
||||||
|
</style>
|
@ -45,12 +45,16 @@ div
|
|||||||
span.reply(@click="reply(item.comment_ID, i.comment_ID, true)" v-else) 取消回复
|
span.reply(@click="reply(item.comment_ID, i.comment_ID, true)" v-else) 取消回复
|
||||||
p(v-if="!comments.length", style="color: #cecece; text-align: center; margin-top: 40px") 暂无内容
|
p(v-if="!comments.length", style="color: #cecece; text-align: center; margin-top: 40px") 暂无内容
|
||||||
.comment-default-commit
|
.comment-default-commit
|
||||||
.comment-userinfo
|
.login(v-if="!visitorToken", @click="login")
|
||||||
|
img(src="https://cdn.wyr.me/imgs/GitHub-Login.png")
|
||||||
|
.comment-userinfo(v-else)
|
||||||
.comment-avatar
|
.comment-avatar
|
||||||
img(:src="'https://picsum.photos/100/100/?blur=1'")
|
img(:src="'https://picsum.photos/100/100/?blur=1'")
|
||||||
.comment-nickname 张三
|
.comment-nickname 张三
|
||||||
#editor
|
#editor
|
||||||
.comment-default-commit(id="editor-reply", v-show="replyID")
|
.comment-reply-commit(id="comment-reply-commit", v-show="replyID")
|
||||||
|
.login(v-show="!visitorToken", @click="login")
|
||||||
|
img(src="https://cdn.wyr.me/imgs/GitHub-Login.png")
|
||||||
#editor-reply
|
#editor-reply
|
||||||
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")
|
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")
|
.articelRightToc(v-show="articels.post_toc_show && showRightToc", @click="articelRightTocClick")
|
||||||
@ -94,20 +98,22 @@ export default {
|
|||||||
showRightToc: false,
|
showRightToc: false,
|
||||||
tocIds: result.post_toc_ids,
|
tocIds: result.post_toc_ids,
|
||||||
replyLastID: null,
|
replyLastID: null,
|
||||||
replyID: null
|
replyID: null,
|
||||||
|
visitorToken: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
// 创建编辑器
|
// 创建编辑器
|
||||||
if (process.client) {
|
if (process.client) {
|
||||||
if (!window.editorObj && window.Vditor) {
|
if (!window.editorObj && window.Vditor) {
|
||||||
|
this.visitorToken = window.localStorage.visitorToken
|
||||||
const upload = {
|
const upload = {
|
||||||
accept: 'image/*, video/*, audio/*, text/*, application/*, .rar, .zip, .php, .pptx, .ppt, .doc, .docx, .txt, .xls, .xlsx',
|
accept: 'image/*, video/*, audio/*, text/*, application/*, .rar, .zip, .php, .pptx, .ppt, .doc, .docx, .txt, .xls, .xlsx',
|
||||||
url: process.env.baseURL + '/public/file/upload',
|
url: process.env.baseURL + '/visitor/file/upload',
|
||||||
max: 10485760, // 10 MB
|
max: 10485760, // 10 MB
|
||||||
linkToImgUrl: process.env.baseURL + '/public/file/fetch',
|
linkToImgUrl: process.env.baseURL + '/visitor/file/fetch',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: 'Bearer ' + window.localStorage.token
|
Authorization: 'Bearer ' + window.localStorage.visitorToken
|
||||||
},
|
},
|
||||||
filename: name => encodeURIComponent(name.replace(/[^(a-zA-Z0-9\u4E00-\u9FA5\.)]/g, '') // eslint-disable-line
|
filename: name => encodeURIComponent(name.replace(/[^(a-zA-Z0-9\u4E00-\u9FA5\.)]/g, '') // eslint-disable-line
|
||||||
.replace(/[\?\\/:|<>\*\[\]\(\)\$%\{\}@~]/g, '') // eslint-disable-line
|
.replace(/[\?\\/:|<>\*\[\]\(\)\$%\{\}@~]/g, '') // eslint-disable-line
|
||||||
@ -408,7 +414,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
reply (id, replyLastID, cancel) {
|
reply (id, replyLastID, cancel) {
|
||||||
const editorReplyObject = document.getElementById('editor-reply')
|
const editorReplyObject = document.getElementById('comment-reply-commit')
|
||||||
if (cancel) {
|
if (cancel) {
|
||||||
this.replyID = null
|
this.replyID = null
|
||||||
this.replyLastID = null
|
this.replyLastID = null
|
||||||
@ -429,6 +435,9 @@ export default {
|
|||||||
window.location.hash = '#comment_ID_' + id
|
window.location.hash = '#comment_ID_' + id
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
login () {
|
||||||
|
window.open('https://github.com/login/oauth/authorize?client_id=ce1673a37333e47e482d&redirect_uri=https://www.wyr.me/auth', 'Github授权', 'scrollbars=yes,resizable=yes,status=no,location=yes,toolbar=no,menubar=no,width=800,height=600,left=0,top=0')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
head () {
|
head () {
|
||||||
@ -545,7 +554,6 @@ export default {
|
|||||||
margin-left 10px
|
margin-left 10px
|
||||||
|
|
||||||
.comment-userinfo
|
.comment-userinfo
|
||||||
margin-top 90px
|
|
||||||
margin-left 5px
|
margin-left 5px
|
||||||
padding 10px 5px
|
padding 10px 5px
|
||||||
|
|
||||||
@ -571,125 +579,164 @@ export default {
|
|||||||
margin-top 10px
|
margin-top 10px
|
||||||
margin-bottom 10px
|
margin-bottom 10px
|
||||||
|
|
||||||
#editor-reply
|
.comment-reply-commit
|
||||||
margin 10px 0 10px 50px
|
margin 10px 0 10px 50px
|
||||||
|
|
||||||
.btnFooter
|
.comment-default-commit
|
||||||
font-size 12px
|
margin-top 125px
|
||||||
margin-top 25px
|
|
||||||
|
|
||||||
i
|
.comment-default-commit, .comment-reply-commit
|
||||||
margin 10px
|
position relative
|
||||||
|
|
||||||
.btnPrevt
|
.login
|
||||||
float left
|
position absolute
|
||||||
|
left 0
|
||||||
|
top 0
|
||||||
|
width 100%
|
||||||
|
height 100%
|
||||||
|
text-align center
|
||||||
|
line-height 1
|
||||||
|
margin auto
|
||||||
|
z-index 99
|
||||||
|
cursor pointer
|
||||||
|
user-select none
|
||||||
|
|
||||||
.btnNext
|
img
|
||||||
float right
|
margin-top 70px
|
||||||
|
|
||||||
footer .footer
|
.login:hover
|
||||||
color #cccccc
|
background-color #fff
|
||||||
text-align left
|
|
||||||
line-height 1.5
|
|
||||||
margin 20px 0
|
|
||||||
|
|
||||||
.anchor-fix
|
.login:before
|
||||||
display block
|
content ''
|
||||||
height 70px /* same height as header */
|
position absolute
|
||||||
margin-top -70px /* same height as header */
|
background rgba(0, 0, 0, 0.1)
|
||||||
visibility hidden
|
top 0
|
||||||
|
left 0
|
||||||
|
width 100%
|
||||||
|
height 100%
|
||||||
|
filter blur(5px)
|
||||||
|
z-index 9
|
||||||
|
|
||||||
.articelRightToc
|
#editor-reply
|
||||||
position fixed
|
margin 0
|
||||||
width 15%
|
|
||||||
top 0
|
|
||||||
right 0
|
|
||||||
overflow-y auto
|
|
||||||
background-color #000
|
|
||||||
padding 10px
|
|
||||||
box-shadow 0 0 8px #000
|
|
||||||
z-index 999999
|
|
||||||
|
|
||||||
.articelToc
|
.btnFooter
|
||||||
width 100%
|
font-size 12px
|
||||||
|
margin-top 25px
|
||||||
|
|
||||||
.articelToc, .articelRightToc
|
i
|
||||||
color #bbb
|
margin 10px
|
||||||
user-select none
|
|
||||||
|
|
||||||
.articelTitle
|
.btnPrevt
|
||||||
font-weight 400
|
float left
|
||||||
margin-bottom 10px
|
|
||||||
|
|
||||||
.articelTocList
|
.btnNext
|
||||||
color #bbb
|
float right
|
||||||
|
|
||||||
a
|
footer .footer
|
||||||
|
color #cccccc
|
||||||
|
text-align left
|
||||||
|
line-height 1.5
|
||||||
|
margin 20px 0
|
||||||
|
|
||||||
|
.anchor-fix
|
||||||
|
display block
|
||||||
|
height 70px /* same height as header */
|
||||||
|
margin-top -70px /* same height as header */
|
||||||
|
visibility hidden
|
||||||
|
|
||||||
|
.articelRightToc
|
||||||
|
position fixed
|
||||||
|
width 15%
|
||||||
|
top 0
|
||||||
|
right 0
|
||||||
|
overflow-y auto
|
||||||
|
background-color #000
|
||||||
|
padding 10px
|
||||||
|
box-shadow 0 0 8px #000
|
||||||
|
z-index 999999
|
||||||
|
|
||||||
|
.articelToc
|
||||||
|
width 100%
|
||||||
|
|
||||||
|
.articelToc, .articelRightToc
|
||||||
color #bbb
|
color #bbb
|
||||||
|
user-select none
|
||||||
|
|
||||||
&:visited
|
.articelTitle
|
||||||
|
font-weight 400
|
||||||
|
margin-bottom 10px
|
||||||
|
|
||||||
|
.articelTocList
|
||||||
color #bbb
|
color #bbb
|
||||||
|
|
||||||
&:hover
|
a
|
||||||
color #d01c2e
|
color #bbb
|
||||||
|
|
||||||
ol.toc, ol.toc ol
|
&:visited
|
||||||
counter-reset toc
|
color #bbb
|
||||||
list-style none
|
|
||||||
|
|
||||||
ol li
|
&:hover
|
||||||
counter-increment toc
|
color #d01c2e
|
||||||
|
|
||||||
.toc li:before
|
ol.toc, ol.toc ol
|
||||||
content counters(toc, '.') ' '
|
counter-reset toc
|
||||||
|
list-style none
|
||||||
|
|
||||||
ol
|
ol li
|
||||||
margin-left 20px
|
counter-increment toc
|
||||||
|
|
||||||
li
|
.toc li:before
|
||||||
font-weight 400
|
content counters(toc, '.') ' '
|
||||||
|
|
||||||
ol
|
ol
|
||||||
margin-left 20px
|
margin-left 20px
|
||||||
|
|
||||||
li
|
li
|
||||||
font-weight 300
|
font-weight 400
|
||||||
|
|
||||||
.tools
|
ol
|
||||||
margin-top 80px
|
margin-left 20px
|
||||||
margin-bottom 10px
|
|
||||||
text-align center
|
|
||||||
user-select none
|
|
||||||
|
|
||||||
.reward
|
li
|
||||||
margin 15px 0
|
font-weight 300
|
||||||
border 1px solid #888
|
|
||||||
padding 5px 10px
|
|
||||||
display inline-block
|
|
||||||
color #888
|
|
||||||
font-weight 300
|
|
||||||
cursor pointer
|
|
||||||
margin auto
|
|
||||||
|
|
||||||
.vditor--fullscreen
|
.tools
|
||||||
z-index 9999999
|
margin-top 80px
|
||||||
|
margin-bottom 10px
|
||||||
|
text-align center
|
||||||
|
user-select none
|
||||||
|
|
||||||
@media (max-width: 768px)
|
.reward
|
||||||
.articleDetails
|
margin 15px 0
|
||||||
padding 20px
|
border 1px solid #888
|
||||||
margin-top 50px
|
padding 5px 10px
|
||||||
|
display inline-block
|
||||||
|
color #888
|
||||||
|
font-weight 300
|
||||||
|
cursor pointer
|
||||||
|
margin auto
|
||||||
|
|
||||||
.articelRightToc
|
.vditor--fullscreen
|
||||||
position fixed
|
z-index 9999999
|
||||||
width 80%
|
|
||||||
top 100px
|
|
||||||
bottom 95px
|
|
||||||
right 10px
|
|
||||||
background-color #000
|
|
||||||
padding 10px
|
|
||||||
overflow-y auto
|
|
||||||
box-shadow 0 0 8px #000
|
|
||||||
|
|
||||||
.mobileToc
|
@media (max-width: 768px)
|
||||||
bottom 48px
|
.articleDetails
|
||||||
|
padding 20px
|
||||||
|
margin-top 50px
|
||||||
|
|
||||||
|
.articelRightToc
|
||||||
|
position fixed
|
||||||
|
width 80%
|
||||||
|
top 100px
|
||||||
|
bottom 95px
|
||||||
|
right 10px
|
||||||
|
background-color #000
|
||||||
|
padding 10px
|
||||||
|
overflow-y auto
|
||||||
|
box-shadow 0 0 8px #000
|
||||||
|
|
||||||
|
.mobileToc
|
||||||
|
bottom 48px
|
||||||
</style>
|
</style>
|
||||||
|
@ -3,7 +3,10 @@ import vditor from 'vditor'
|
|||||||
import 'vditor/dist/index.css'
|
import 'vditor/dist/index.css'
|
||||||
|
|
||||||
const $tags = document.getElementById('tags')
|
const $tags = document.getElementById('tags')
|
||||||
const floatTop = $tags.offsetTop + $tags.scrollHeight + 30
|
let floatTop = null
|
||||||
|
if ($tags) {
|
||||||
|
floatTop = $tags.offsetTop + $tags.scrollHeight + 30
|
||||||
|
}
|
||||||
|
|
||||||
function addEvent (obj, type, fn) {
|
function addEvent (obj, type, fn) {
|
||||||
if (obj.attachEvent) {
|
if (obj.attachEvent) {
|
||||||
@ -24,30 +27,32 @@ window.onload = function () {
|
|||||||
|
|
||||||
// 底部返回顶部按钮
|
// 底部返回顶部按钮
|
||||||
const top = document.getElementById('gotop')
|
const top = document.getElementById('gotop')
|
||||||
// 滚动一屏幕时显示回到顶部
|
if (top) {
|
||||||
addEvent(window, 'scroll', function () {
|
// 滚动一屏幕时显示回到顶部
|
||||||
const currentPosition = document.documentElement.scrollTop || document.body.scrollTop
|
addEvent(window, 'scroll', function () {
|
||||||
currentPosition > window.screen.availHeight ? top.style.display = 'block' : top.style.display = 'none'
|
const currentPosition = document.documentElement.scrollTop || document.body.scrollTop
|
||||||
|
currentPosition > window.screen.availHeight ? top.style.display = 'block' : top.style.display = 'none'
|
||||||
|
|
||||||
// 左部导航自动浮动
|
// 左部导航自动浮动
|
||||||
if (currentPosition > floatTop) {
|
if (currentPosition > floatTop) {
|
||||||
document.getElementById('navication').style.position = 'fixed'
|
document.getElementById('navication').style.position = 'fixed'
|
||||||
} else {
|
|
||||||
document.getElementById('navication').style.position = 'static'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
top.onclick = function () {
|
|
||||||
var timer = setInterval(function () { // eslint-disable-line
|
|
||||||
let currentPosition = document.documentElement.scrollTop || document.body.scrollTop
|
|
||||||
currentPosition -= 100
|
|
||||||
if (currentPosition > 0) {
|
|
||||||
window.scrollTo(0, currentPosition)
|
|
||||||
} else {
|
} else {
|
||||||
window.scrollTo(0, 0)
|
document.getElementById('navication').style.position = 'static'
|
||||||
clearInterval(timer)
|
|
||||||
}
|
}
|
||||||
}, 10)
|
})
|
||||||
|
|
||||||
|
top.onclick = function () {
|
||||||
|
var timer = setInterval(function () { // eslint-disable-line
|
||||||
|
let currentPosition = document.documentElement.scrollTop || document.body.scrollTop
|
||||||
|
currentPosition -= 100
|
||||||
|
if (currentPosition > 0) {
|
||||||
|
window.scrollTo(0, currentPosition)
|
||||||
|
} else {
|
||||||
|
window.scrollTo(0, 0)
|
||||||
|
clearInterval(timer)
|
||||||
|
}
|
||||||
|
}, 10)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let _hmt = _hmt || [] // eslint-disable-line
|
let _hmt = _hmt || [] // eslint-disable-line
|
||||||
|
BIN
static/.DS_Store
vendored
Normal file
BIN
static/.DS_Store
vendored
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user