评论配置接口获取

This commit is contained in:
结发受长生 2019-08-25 21:27:14 +08:00
parent eb5625c3ae
commit d42e02e75d
6 changed files with 12 additions and 33 deletions

View File

@ -61,6 +61,8 @@ toc: 2
toc_hide_index: true
# 是否显示文章列表页的动画效果
animate: true
# 文章全文页面是否开启评论
comment: true
# 目录为空时的提示
toc_empty_wording: 目录,不存在的…

View File

@ -7,6 +7,7 @@ window.themeConfig = {
isCategory: <%=is_category()%>, // 是否为分类页面
pageid: <%-page.pageid ? `"${page.pageid}"` : 'undefined'%>, // 页面标识, 用于个性化页面开发
toc_hide_index: <%=theme.toc_hide_index%>, // 目录序号
comment: <%=theme.comment%>, // 文章全文页面是否开启评论
animate: <%=theme.animate%>, // 是否显示文章列表页动画效果
root: '<%=config.root%>', // 资源根路径
baseUrl: '<%=config.url%>',

View File

@ -1,4 +1,3 @@
<% var defaultBg = '#4d4d4d'; %>
<div class="intrude-less">
<header id="header" class="inner">
<a href="<%=config.root%>" @mouseover="linkMouseover('home')" class="profilepic">

View File

@ -1,25 +0,0 @@
{
"gitalk": {
"enable": false,
"config": {
"ClientID": "90e8f648da2a669f7975",
"ClientSecret": "7d2b602616387748ef0df10f7a8a626bdfd1034c",
"repo": "hexo_blog",
"githubID": "sookie2010",
"adminUser": "sookie2010",
"distractionFreeMode": false
}
},
"valine": {
"enable": true,
"config": {
"el": "#comments",
"notify": false,
"verify": false,
"appId": "40jq6uO51rpVT4PEEcayYkda-gzGzoHsz",
"appKey": "nBOoOEDP4EBUfgpSJAF6idKi",
"placeholder": "ヾノ≧∀≦)o来啊快活啊!",
"avatar": "mm"
}
}
}

View File

@ -1,3 +1,4 @@
const axios = require('axios')
// const AV = require('leancloud-storage')
window.AV = require('leancloud-storage')
// const Valine = require('../lib/Valine.min')
@ -6,11 +7,13 @@ window.AV = require('leancloud-storage')
* 可以支持对于AV对象的传参输入, 而不需要暴露全局变量
* 但是缺少一些新功能
*/
// 评论配置
const commentConfig = require('../config/comment.json')
import(/* webpackChunkName: "valine" */ '../lib/Valine.min').then(({default: Valine }) => {
commentConfig.valine.config.path = window.location.pathname
// commentConfig.valine.config.av = AV
new Valine(commentConfig.valine.config)
// 从接口获取评论配置
axios.get(`${window.themeConfig.root}api/common/valineConfig`).then(res => {
let config = res.data
config.path = window.location.pathname
// config.av = AV
new Valine(config)
})
})

View File

@ -43,8 +43,7 @@ Util.addLoadEvent(function() {
}
})
const commentConfig = require('../config/comment.json')
if(window.themeConfig.isPost && commentConfig.valine.enable) {
if(window.themeConfig.isPost && window.themeConfig.comment) {
// 文章详情页面, 并且启用了评论, 则加载评论相关代码
import(/* webpackChunkName: "comment" */ './comment')
}