From 6689e4d5c1e9912b436ffe1d1a0d59e2733cd007 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=BB=93=E5=8F=91=E5=8F=97=E9=95=BF=E7=94=9F?=
Date: Mon, 8 Jul 2019 09:45:27 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A2=98=E9=A1=B5=E9=9D=A2=E7=B2=BE?=
=?UTF-8?q?=E7=AE=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
themes/yilia/_config.yml | 32 +-------
themes/yilia/layout/_partial/after-footer.ejs | 24 +-----
themes/yilia/layout/_partial/article.ejs | 31 +-------
.../yilia/layout/_partial/baidu-analytics.ejs | 11 ---
.../layout/_partial/google-analytics.ejs | 14 ----
themes/yilia/layout/_partial/head.ejs | 6 +-
themes/yilia/layout/_partial/header.ejs | 2 +-
.../yilia/layout/_partial/post/changyan.ejs | 9 ---
themes/yilia/layout/_partial/post/duoshuo.ejs | 18 -----
themes/yilia/layout/_partial/post/share.ejs | 10 +--
themes/yilia/source-src/js/share.js | 74 ++++++++++---------
11 files changed, 59 insertions(+), 172 deletions(-)
delete mode 100644 themes/yilia/layout/_partial/baidu-analytics.ejs
delete mode 100644 themes/yilia/layout/_partial/google-analytics.ejs
delete mode 100644 themes/yilia/layout/_partial/post/changyan.ejs
delete mode 100644 themes/yilia/layout/_partial/post/duoshuo.ejs
diff --git a/themes/yilia/_config.yml b/themes/yilia/_config.yml
index f3f82d6..d3a48fc 100644
--- a/themes/yilia/_config.yml
+++ b/themes/yilia/_config.yml
@@ -65,40 +65,16 @@ toc_empty_wording: 目录,不存在的…
# 是否有快速回到顶部的按钮
top: true
-# Miscellaneous
-baidu_analytics: ''
-google_analytics: ''
+# 站点图标
favicon: /favicon.ico
-#你的头像url
+#头像url
avatar: https://cdn.colorfulsweet.site/resources/avatar.jpg
#是否开启分享
-share_jia: true
+share_enable: true
-#评论:1、畅言;2、Disqus;3、Gitment
-#不需要使用某项,直接设置值为false,或注释掉
-#具体请参考wiki:https://github.com/litten/hexo-theme-yilia/wiki/
-
-
-#1、畅言
-changyan_appid: false
-changyan_conf: false
-
-#2、Disqus 在hexo根目录的config里也有disqus_shortname字段,优先使用yilia的
-disqus: false
-
-#3、gitalk
-gitalk:
- enable: false
- ClientID: 90e8f648da2a669f7975
- ClientSecret: 7d2b602616387748ef0df10f7a8a626bdfd1034c
- repo: hexo_blog
- githubID: sookie2010
- adminUser: sookie2010
- distractionFreeMode: false
-
-#4、Valine
+#评论 Valine
valine:
enable: true
appId: 40jq6uO51rpVT4PEEcayYkda-gzGzoHsz
diff --git a/themes/yilia/layout/_partial/after-footer.ejs b/themes/yilia/layout/_partial/after-footer.ejs
index 8d5cef8..d17f345 100644
--- a/themes/yilia/layout/_partial/after-footer.ejs
+++ b/themes/yilia/layout/_partial/after-footer.ejs
@@ -7,25 +7,9 @@ window.themeConfig = {
isCategory: <%=is_category()%>, // 是否为分类页面
pageid: <%-page.pageid ? `"${page.pageid}"` : 'undefined'%>, // 页面标识, 用于个性化页面开发
toc_hide_index: <%=theme.toc_hide_index%>, // 目录序号
- root: "<%=config.root%>", // 资源根路径
- pictureCdn: "<%=config.picture_cdn%>" // 图片存储仓库地址
+ root: '<%=config.root%>', // 资源根路径
+ baseUrl: '<%=config.url%>',
+ pictureCdn: '<%=config.picture_cdn%>' // 图片存储仓库地址
}
-<%- partial('script') %>
-<% if(theme.gitalk.enable && is_post()) { %>
-
-
-
-<% } %>
\ No newline at end of file
+<%- partial('script') %>
\ No newline at end of file
diff --git a/themes/yilia/layout/_partial/article.ejs b/themes/yilia/layout/_partial/article.ejs
index 380f05d..5f08328 100644
--- a/themes/yilia/layout/_partial/article.ejs
+++ b/themes/yilia/layout/_partial/article.ejs
@@ -79,7 +79,7 @@
<%= __('show_full_text') %> >>
<% } %>
- <% if (!param.index && theme.share_jia){ %>
+ <% if (!param.index && theme.share_enable){ %>
<%- partial('post/share') %>
<% } %>
@@ -90,33 +90,6 @@
<%- partial('post/nav') %>
<% } %>
-<% if (!param.index && post.comments){ %>
- <% if (theme.changyan_appid && theme.changyan_conf){ %>
- <%- partial('post/changyan', {
- key: post.slug,
- title: post.title,
- url: config.url+url_for(post.path)
- }) %>
- <% } %>
-
- <% if (theme.disqus || config.disqus_shortname){ %>
-
- <% }
- if(theme.gitalk.enable || theme.valine.enable){ %>
+<% if (!param.index && post.comments && theme.valine.enable){ %>
- <% } %>
<% } %>
\ No newline at end of file
diff --git a/themes/yilia/layout/_partial/baidu-analytics.ejs b/themes/yilia/layout/_partial/baidu-analytics.ejs
deleted file mode 100644
index e9bd0b6..0000000
--- a/themes/yilia/layout/_partial/baidu-analytics.ejs
+++ /dev/null
@@ -1,11 +0,0 @@
-<% if (theme.baidu_analytics){ %>
-
-<% } %>
diff --git a/themes/yilia/layout/_partial/google-analytics.ejs b/themes/yilia/layout/_partial/google-analytics.ejs
deleted file mode 100644
index 84e75f0..0000000
--- a/themes/yilia/layout/_partial/google-analytics.ejs
+++ /dev/null
@@ -1,14 +0,0 @@
-<% if (theme.google_analytics){ %>
-
-
-
-<% } %>
diff --git a/themes/yilia/layout/_partial/head.ejs b/themes/yilia/layout/_partial/head.ejs
index b0b280b..3708c4b 100644
--- a/themes/yilia/layout/_partial/head.ejs
+++ b/themes/yilia/layout/_partial/head.ejs
@@ -22,12 +22,10 @@
<%- open_graph({twitter_id: theme.twitter, google_plus: theme.google_plus, fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %>
<% if (theme.rss){ %>
-
+
<% } %>
<% if (theme.favicon){ %>
-
+
<% } %>
<%- partial('css') %>
- <%- partial('google-analytics') %>
- <%- partial('baidu-analytics') %>
diff --git a/themes/yilia/layout/_partial/header.ejs b/themes/yilia/layout/_partial/header.ejs
index 8eba01d..e78cf20 100644
--- a/themes/yilia/layout/_partial/header.ejs
+++ b/themes/yilia/layout/_partial/header.ejs
@@ -20,7 +20,7 @@
diff --git a/themes/yilia/layout/_partial/post/changyan.ejs b/themes/yilia/layout/_partial/post/changyan.ejs
deleted file mode 100644
index 8598894..0000000
--- a/themes/yilia/layout/_partial/post/changyan.ejs
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/themes/yilia/layout/_partial/post/duoshuo.ejs b/themes/yilia/layout/_partial/post/duoshuo.ejs
deleted file mode 100644
index bd9eff5..0000000
--- a/themes/yilia/layout/_partial/post/duoshuo.ejs
+++ /dev/null
@@ -1,18 +0,0 @@
-
diff --git a/themes/yilia/layout/_partial/post/share.ejs b/themes/yilia/layout/_partial/post/share.ejs
index 5d790b0..d884615 100644
--- a/themes/yilia/layout/_partial/post/share.ejs
+++ b/themes/yilia/layout/_partial/post/share.ejs
@@ -37,11 +37,11 @@
-
-
扫一扫,分享到微信
-
-
-
+
+
扫一扫,分享到微信
+
+
+
\ No newline at end of file
diff --git a/themes/yilia/source-src/js/share.js b/themes/yilia/source-src/js/share.js
index 037fc62..476ee66 100644
--- a/themes/yilia/source-src/js/share.js
+++ b/themes/yilia/source-src/js/share.js
@@ -1,16 +1,7 @@
import QRious from 'qrious'
-function generate(url, opts) {
- var url = url.replace(/<%-sUrl%>/g, encodeURIComponent(opts.sUrl))
- .replace(/<%-sTitle%>/g, opts.sTitle)
- .replace(/<%-sDesc%>/g, opts.sDesc)
- .replace(/<%-sPic%>/g, encodeURIComponent(opts.sPic))
-
- window.open(url)
-}
-
var qrcodeInit = false
-function showWX() {
+function showWXModal() {
let wx = document.querySelector('.js-wx-box')
let mask = document.querySelector('.mask')
if(!qrcodeInit) {
@@ -24,30 +15,45 @@ function showWX() {
mask.classList.add('in')
}
-function hideWX() {
- let wx = document.querySelector('.js-wx-box')
+function hideModal() {
+ let modals = document.querySelectorAll('.page-modal')
let mask = document.querySelector('.mask')
- wx.classList.remove('in', 'ready')
+ Array.prototype.forEach.call(modals, modal => {
+ modal.classList.remove('in', 'ready')
+ })
mask.classList.remove('in')
}
function handleClick(type, opts) {
- if (type === 'weibo') {
- generate('http://service.weibo.com/share/share.php?url=<%-sUrl%>&title=<%-sTitle%>&pic=<%-sPic%>', opts)
- } else if (type === 'qq') {
- generate('http://connect.qq.com/widget/shareqq/index.html?url=<%-sUrl%>&title=<%-sTitle%>&source=<%-sDesc%>', opts)
- } else if (type === 'douban') {
- generate('https://www.douban.com/share/service?image=<%-sPic%>&href=<%-sUrl%>&name=<%-sTitle%>&text=<%-sDesc%>', opts)
- } else if (type === 'qzone') {
- generate('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=<%-sUrl%>&title=<%-sTitle%>&pics=<%-sPic%>&summary=<%-sDesc%>', opts)
- } else if (type === 'facebook') {
- generate('https://www.facebook.com/sharer/sharer.php?u=<%-sUrl%>', opts)
- } else if (type === 'twitter') {
- generate('https://twitter.com/intent/tweet?text=<%-sTitle%>&url=<%-sUrl%>&via=<%-config.url%>', opts)
- } else if (type === 'google') {
- generate('https://plus.google.com/share?url=<%-sUrl%>', opts)
- } else if (type === 'weixin') {
- showWX()
+ let url = null
+ switch(type) {
+ case 'weibo' :
+ url = `http://service.weibo.com/share/share.php?url=${opts.sUrl}&title=${opts.sTitle}&pic=${opts.sPic}`
+ break
+ case 'qq' :
+ url = `http://connect.qq.com/widget/shareqq/index.html?url=${opts.sUrl}&title=${opts.sTitle}&source=${opts.sDesc}`
+ break
+ case 'douban' :
+ url = `https://www.douban.com/share/service?image=${opts.sPic}&href=${opts.sUrl}&name=${opts.sTitle}&text=${opts.sDesc}`
+ break
+ case 'qzone' :
+ url = `http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=${opts.sUrl}&title=${opts.sTitle}&pics=${opts.sPic}&summary=${opts.sDesc}`
+ break
+ case 'facebook' :
+ url = `https://www.facebook.com/sharer/sharer.php?u=${opts.sUrl}`
+ break
+ case 'twitter' :
+ url = `https://twitter.com/intent/tweet?text=${opts.sTitle}&url=${opts.sUrl}&via=${themeConfig.baseUrl}`
+ break
+ case 'google' :
+ url = `https://plus.google.com/share?url=${opts.sUrl}`
+ break
+ case 'weixin' :
+ showWXModal()
+ break
+ }
+ if(url) {
+ window.open(url)
}
}
@@ -66,15 +72,17 @@ let init = function() {
$em.onclick = (e) => {
let type = $em.getAttribute('data-type')
handleClick(type, {
- sUrl: sUrl,
- sPic: sPic,
+ sUrl: encodeURIComponent(sUrl),
+ sPic: encodeURIComponent(sPic),
sTitle: sTitle,
sDesc: sTitle
})
}
})
- document.querySelector('.mask').addEventListener('click', hideWX)
- document.querySelector('.js-modal-close').addEventListener('click', hideWX)
+ document.querySelector('.mask').addEventListener('click', hideModal)
+ Array.prototype.forEach.call(document.querySelectorAll('.js-modal-close'), modalClose => {
+ modalClose.addEventListener('click', hideModal)
+ })
}
export default { init }
\ No newline at end of file