From f38d55b36cc4f590732a6f0c12ac9c69397a5038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E6=81=92?= <2323333339@qq.com> Date: Fri, 30 Apr 2021 17:50:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/js/joe.leaving.js | 256 ++++++++++---------- assets/js/joe.leaving.min.js | 2 +- assets/js/joe.post_page.js | 410 ++++++++++++++++----------------- assets/js/joe.post_page.min.js | 2 +- core/function.php | 2 +- core/route.php | 11 +- friends.php | 2 +- leaving.php | 2 +- package.json | 2 +- page.php | 2 +- post.php | 2 +- 11 files changed, 349 insertions(+), 344 deletions(-) diff --git a/assets/js/joe.leaving.js b/assets/js/joe.leaving.js index 85b4912..a66bed7 100644 --- a/assets/js/joe.leaving.js +++ b/assets/js/joe.leaving.js @@ -1,139 +1,139 @@ document.addEventListener('DOMContentLoaded', () => { - const encryption = str => window.btoa(unescape(encodeURIComponent(str))); - const decrypt = str => decodeURIComponent(escape(window.atob(str))); + const encryption = str => window.btoa(unescape(encodeURIComponent(str))); + const decrypt = str => decodeURIComponent(escape(window.atob(str))); - /* 当前页的CID */ - const cid = $('.joe_detail').attr('data-cid'); + /* 当前页的CID */ + const cid = $('.joe_detail').attr('data-cid'); - /* 获取本篇文章百度收录情况 */ - { - $.ajax({ - url: Joe.BASE_API, - type: 'POST', - dataType: 'json', - data: { routeType: 'baidu_record', site: window.location.href }, - success(res) { - if (res.data && res.data === '已收录') { - $('#Joe_Baidu_Record').css('color', '#67C23A'); - $('#Joe_Baidu_Record').html('已收录'); - } else { - /* 如果填写了Token,则自动推送给百度 */ - if (Joe.BAIDU_PUSH) { - $('#Joe_Baidu_Record').html('未收录,推送中...'); - const _timer = setTimeout(function () { - $.ajax({ - url: Joe.BASE_API, - type: 'POST', - dataType: 'json', - data: { - routeType: 'baidu_push', - domain: encodeURI(window.location.hostname), - url: encodeURI(window.location.href) - }, - success(res) { - if (res.error) { - $('#Joe_Baidu_Record').html('推送失败,请检查!'); - } else { - $('#Joe_Baidu_Record').html('推送成功!'); - } - } - }); - clearTimeout(_timer); - }, 1000); - } else { - const url = `https://ziyuan.baidu.com/linksubmit/url?sitename=${encodeURI(window.location.href)}`; - $('#Joe_Baidu_Record').html(`未收录,提交收录`); - } - } - } - }); - } + /* 获取本篇文章百度收录情况 */ + { + $.ajax({ + url: Joe.BASE_API, + type: 'POST', + dataType: 'json', + data: { routeType: 'baidu_record', site: window.location.href }, + success(res) { + if (res.data && res.data === '已收录') { + $('#Joe_Baidu_Record').css('color', '#67C23A'); + $('#Joe_Baidu_Record').html('已收录'); + } else { + /* 如果填写了Token,则自动推送给百度 */ + if (Joe.BAIDU_PUSH) { + $('#Joe_Baidu_Record').html('未收录,推送中...'); + const _timer = setTimeout(function () { + $.ajax({ + url: Joe.BASE_API, + type: 'POST', + dataType: 'json', + data: { + routeType: 'baidu_push', + domain: window.location.protocol + '//' + window.location.hostname, + url: encodeURI(window.location.protocol + '//' + window.location.hostname + window.location.pathname) + }, + success(res) { + if (res.data.error) { + $('#Joe_Baidu_Record').html('推送失败,请检查!'); + } else { + $('#Joe_Baidu_Record').html('推送成功!'); + } + } + }); + clearTimeout(_timer); + }, 1000); + } else { + const url = `https://ziyuan.baidu.com/linksubmit/url?sitename=${encodeURI(window.location.href)}`; + $('#Joe_Baidu_Record').html(`未收录,提交收录`); + } + } + } + }); + } - /* 激活浏览功能 */ - { - let viewsArr = localStorage.getItem(encryption('views')) ? JSON.parse(decrypt(localStorage.getItem(encryption('views')))) : []; - const flag = viewsArr.includes(cid); - if (!flag) { - $.ajax({ - url: Joe.BASE_API, - type: 'POST', - dataType: 'json', - data: { routeType: 'handle_views', cid }, - success(res) { - if (res.code !== 1) return; - $('#Joe_Article_Views').html(`${res.data.views} 阅读`); - viewsArr.push(cid); - const name = encryption('views'); - const val = encryption(JSON.stringify(viewsArr)); - localStorage.setItem(name, val); - } - }); - } - } + /* 激活浏览功能 */ + { + let viewsArr = localStorage.getItem(encryption('views')) ? JSON.parse(decrypt(localStorage.getItem(encryption('views')))) : []; + const flag = viewsArr.includes(cid); + if (!flag) { + $.ajax({ + url: Joe.BASE_API, + type: 'POST', + dataType: 'json', + data: { routeType: 'handle_views', cid }, + success(res) { + if (res.code !== 1) return; + $('#Joe_Article_Views').html(`${res.data.views} 阅读`); + viewsArr.push(cid); + const name = encryption('views'); + const val = encryption(JSON.stringify(viewsArr)); + localStorage.setItem(name, val); + } + }); + } + } - /* 激活随机样式 */ - { - let _index = 100; - const colors = ['#F8D800', '#0396FF', '#EA5455', '#7367F0', '#32CCBC', '#F6416C', '#28C76F', '#9F44D3', '#F55555', '#736EFE', '#E96D71', '#DE4313', '#D939CD', '#4C83FF', '#F072B6', '#C346C2', '#5961F9', '#FD6585', '#465EFB', '#FFC600', '#FA742B', '#5151E5', '#BB4E75', '#FF52E5', '#49C628', '#00EAFF', '#F067B4', '#F067B4', '#ff9a9e', '#00f2fe', '#4facfe', '#f093fb', '#6fa3ef', '#bc99c4', '#46c47c', '#f9bb3c', '#e8583d', '#f68e5f']; - const random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; - const maxWidth = $('.joe_detail__leaving-list').width(); - const maxHeight = $('.joe_detail__leaving-list').height(); - const radius1 = ['20px 300px', '20px 400px', '20px 500px', '30px 300px', '30px 400px', '30px 500px', '40px 300px', '40px 400px', '40px 500px']; - const radius2 = ['300px 20px', '400px 20px', '500px 20px', '300px 30px', '400px 30px', '500px 30px', '300px 40px', '400px 40px', '500px 40px']; - $('.joe_detail__leaving-list .item').each((index, item) => { - const zIndex = random(1, 99); - const background = colors[random(0, colors.length - 1)]; - const width = Math.ceil($(item).width()); - const height = Math.ceil($(item).height()); - const top = random(0, maxHeight - height); - const left = random(0, maxWidth - width); - $(item).css({ - display: 'block', - zIndex, - background, - top, - left, - borderTopLeftRadius: radius2[random(0, radius2.length - 1)], - borderTopRightRadius: radius1[random(0, radius1.length - 1)], - borderBottomLeftRadius: radius1[random(0, radius1.length - 1)], - borderBottomRightRadius: radius1[random(0, radius1.length - 1)] - }); - $(item).draggabilly({ containment: true }); - $(item).on('dragStart', e => { - _index++; - $(item).css({ zIndex: _index }); - }); - }); - } + /* 激活随机样式 */ + { + let _index = 100; + const colors = ['#F8D800', '#0396FF', '#EA5455', '#7367F0', '#32CCBC', '#F6416C', '#28C76F', '#9F44D3', '#F55555', '#736EFE', '#E96D71', '#DE4313', '#D939CD', '#4C83FF', '#F072B6', '#C346C2', '#5961F9', '#FD6585', '#465EFB', '#FFC600', '#FA742B', '#5151E5', '#BB4E75', '#FF52E5', '#49C628', '#00EAFF', '#F067B4', '#F067B4', '#ff9a9e', '#00f2fe', '#4facfe', '#f093fb', '#6fa3ef', '#bc99c4', '#46c47c', '#f9bb3c', '#e8583d', '#f68e5f']; + const random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; + const maxWidth = $('.joe_detail__leaving-list').width(); + const maxHeight = $('.joe_detail__leaving-list').height(); + const radius1 = ['20px 300px', '20px 400px', '20px 500px', '30px 300px', '30px 400px', '30px 500px', '40px 300px', '40px 400px', '40px 500px']; + const radius2 = ['300px 20px', '400px 20px', '500px 20px', '300px 30px', '400px 30px', '500px 30px', '300px 40px', '400px 40px', '500px 40px']; + $('.joe_detail__leaving-list .item').each((index, item) => { + const zIndex = random(1, 99); + const background = colors[random(0, colors.length - 1)]; + const width = Math.ceil($(item).width()); + const height = Math.ceil($(item).height()); + const top = random(0, maxHeight - height); + const left = random(0, maxWidth - width); + $(item).css({ + display: 'block', + zIndex, + background, + top, + left, + borderTopLeftRadius: radius2[random(0, radius2.length - 1)], + borderTopRightRadius: radius1[random(0, radius1.length - 1)], + borderBottomLeftRadius: radius1[random(0, radius1.length - 1)], + borderBottomRightRadius: radius1[random(0, radius1.length - 1)] + }); + $(item).draggabilly({ containment: true }); + $(item).on('dragStart', e => { + _index++; + $(item).css({ zIndex: _index }); + }); + }); + } - /* 格式化分页的hash值 */ - { - $('.joe_comment .joe_pagination a').each((index, item) => { - const href = $(item).attr('href'); - if (href && href.includes('#')) { - $(item).attr('href', href.replace('#comments', '?scroll=joe_comment')); - } - }); - } + /* 格式化分页的hash值 */ + { + $('.joe_comment .joe_pagination a').each((index, item) => { + const href = $(item).attr('href'); + if (href && href.includes('#')) { + $(item).attr('href', href.replace('#comments', '?scroll=joe_comment')); + } + }); + } }); /* 写在load事件里,为了解决图片未加载完成,滚动距离获取会不准确的问题 */ window.addEventListener('load', function () { - /* 判断地址栏是否有锚点链接,有则跳转到对应位置 */ - { - const scroll = new URLSearchParams(location.search).get('scroll'); - if (scroll) { - const height = $('.joe_header').height(); - let elementEL = null; - if ($('#' + scroll).length > 0) { - elementEL = $('#' + scroll); - } else { - elementEL = $('.' + scroll); - } - if (elementEL && elementEL.length > 0) { - const top = elementEL.offset().top - height - 15; - window.scrollTo({ top, behavior: 'smooth' }); - } - } - } + /* 判断地址栏是否有锚点链接,有则跳转到对应位置 */ + { + const scroll = new URLSearchParams(location.search).get('scroll'); + if (scroll) { + const height = $('.joe_header').height(); + let elementEL = null; + if ($('#' + scroll).length > 0) { + elementEL = $('#' + scroll); + } else { + elementEL = $('.' + scroll); + } + if (elementEL && elementEL.length > 0) { + const top = elementEL.offset().top - height - 15; + window.scrollTo({ top, behavior: 'smooth' }); + } + } + } }); diff --git a/assets/js/joe.leaving.min.js b/assets/js/joe.leaving.min.js index 56612f0..db12910 100644 --- a/assets/js/joe.leaving.min.js +++ b/assets/js/joe.leaving.min.js @@ -1 +1 @@ -document.addEventListener("DOMContentLoaded",()=>{const e=e=>window.btoa(unescape(encodeURIComponent(e))),o=e=>decodeURIComponent(escape(window.atob(e))),t=$(".joe_detail").attr("data-cid");$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"baidu_record",site:window.location.href},success(e){if(e.data&&"已收录"===e.data)$("#Joe_Baidu_Record").css("color","#67C23A"),$("#Joe_Baidu_Record").html("已收录");else if(Joe.BAIDU_PUSH){$("#Joe_Baidu_Record").html('未收录,推送中...');const e=setTimeout(function(){$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"baidu_push",domain:encodeURI(window.location.hostname),url:encodeURI(window.location.href)},success(e){e.error?$("#Joe_Baidu_Record").html('推送失败,请检查!'):$("#Joe_Baidu_Record").html('推送成功!')}}),clearTimeout(e)},1e3)}else{const e=`https://ziyuan.baidu.com/linksubmit/url?sitename=${encodeURI(window.location.href)}`;$("#Joe_Baidu_Record").html(`未收录,提交收录`)}}});{let a=localStorage.getItem(e("views"))?JSON.parse(o(localStorage.getItem(e("views")))):[];const n=a.includes(t);n||$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"handle_views",cid:t},success(o){if(1!==o.code)return;$("#Joe_Article_Views").html(`${o.data.views} 阅读`),a.push(t);const n=e("views"),i=e(JSON.stringify(a));localStorage.setItem(n,i)}})}{let e=100;const o=["#F8D800","#0396FF","#EA5455","#7367F0","#32CCBC","#F6416C","#28C76F","#9F44D3","#F55555","#736EFE","#E96D71","#DE4313","#D939CD","#4C83FF","#F072B6","#C346C2","#5961F9","#FD6585","#465EFB","#FFC600","#FA742B","#5151E5","#BB4E75","#FF52E5","#49C628","#00EAFF","#F067B4","#F067B4","#ff9a9e","#00f2fe","#4facfe","#f093fb","#6fa3ef","#bc99c4","#46c47c","#f9bb3c","#e8583d","#f68e5f"],t=(e,o)=>Math.floor(Math.random()*(o-e+1))+e,a=$(".joe_detail__leaving-list").width(),n=$(".joe_detail__leaving-list").height(),i=["20px 300px","20px 400px","20px 500px","30px 300px","30px 400px","30px 500px","40px 300px","40px 400px","40px 500px"],l=["300px 20px","400px 20px","500px 20px","300px 30px","400px 30px","500px 30px","300px 40px","400px 40px","500px 40px"];$(".joe_detail__leaving-list .item").each((c,s)=>{const d=t(1,99),r=o[t(0,o.length-1)],p=Math.ceil($(s).width()),h=Math.ceil($(s).height()),x=t(0,n-h),u=t(0,a-p);$(s).css({display:"block",zIndex:d,background:r,top:x,left:u,borderTopLeftRadius:l[t(0,l.length-1)],borderTopRightRadius:i[t(0,i.length-1)],borderBottomLeftRadius:i[t(0,i.length-1)],borderBottomRightRadius:i[t(0,i.length-1)]}),$(s).draggabilly({containment:!0}),$(s).on("dragStart",o=>{e++,$(s).css({zIndex:e})})})}$(".joe_comment .joe_pagination a").each((e,o)=>{const t=$(o).attr("href");t&&t.includes("#")&&$(o).attr("href",t.replace("#comments","?scroll=joe_comment"))})}),window.addEventListener("load",function(){{const e=new URLSearchParams(location.search).get("scroll");if(e){const o=$(".joe_header").height();let t=null;if(t=$("#"+e).length>0?$("#"+e):$("."+e),t&&t.length>0){const e=t.offset().top-o-15;window.scrollTo({top:e,behavior:"smooth"})}}}}); \ No newline at end of file +document.addEventListener("DOMContentLoaded",()=>{const e=e=>window.btoa(unescape(encodeURIComponent(e))),o=e=>decodeURIComponent(escape(window.atob(e))),t=$(".joe_detail").attr("data-cid");$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"baidu_record",site:window.location.href},success(e){if(e.data&&"已收录"===e.data)$("#Joe_Baidu_Record").css("color","#67C23A"),$("#Joe_Baidu_Record").html("已收录");else if(Joe.BAIDU_PUSH){$("#Joe_Baidu_Record").html('未收录,推送中...');const e=setTimeout(function(){$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"baidu_push",domain:window.location.protocol+"//"+window.location.hostname,url:encodeURI(window.location.protocol+"//"+window.location.hostname+window.location.pathname)},success(e){e.data.error?$("#Joe_Baidu_Record").html('推送失败,请检查!'):$("#Joe_Baidu_Record").html('推送成功!')}}),clearTimeout(e)},1e3)}else{const e=`https://ziyuan.baidu.com/linksubmit/url?sitename=${encodeURI(window.location.href)}`;$("#Joe_Baidu_Record").html(`未收录,提交收录`)}}});{let a=localStorage.getItem(e("views"))?JSON.parse(o(localStorage.getItem(e("views")))):[];const n=a.includes(t);n||$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"handle_views",cid:t},success(o){if(1!==o.code)return;$("#Joe_Article_Views").html(`${o.data.views} 阅读`),a.push(t);const n=e("views"),i=e(JSON.stringify(a));localStorage.setItem(n,i)}})}{let e=100;const o=["#F8D800","#0396FF","#EA5455","#7367F0","#32CCBC","#F6416C","#28C76F","#9F44D3","#F55555","#736EFE","#E96D71","#DE4313","#D939CD","#4C83FF","#F072B6","#C346C2","#5961F9","#FD6585","#465EFB","#FFC600","#FA742B","#5151E5","#BB4E75","#FF52E5","#49C628","#00EAFF","#F067B4","#F067B4","#ff9a9e","#00f2fe","#4facfe","#f093fb","#6fa3ef","#bc99c4","#46c47c","#f9bb3c","#e8583d","#f68e5f"],t=(e,o)=>Math.floor(Math.random()*(o-e+1))+e,a=$(".joe_detail__leaving-list").width(),n=$(".joe_detail__leaving-list").height(),i=["20px 300px","20px 400px","20px 500px","30px 300px","30px 400px","30px 500px","40px 300px","40px 400px","40px 500px"],l=["300px 20px","400px 20px","500px 20px","300px 30px","400px 30px","500px 30px","300px 40px","400px 40px","500px 40px"];$(".joe_detail__leaving-list .item").each((c,d)=>{const s=t(1,99),r=o[t(0,o.length-1)],p=Math.ceil($(d).width()),h=Math.ceil($(d).height()),x=t(0,n-h),u=t(0,a-p);$(d).css({display:"block",zIndex:s,background:r,top:x,left:u,borderTopLeftRadius:l[t(0,l.length-1)],borderTopRightRadius:i[t(0,i.length-1)],borderBottomLeftRadius:i[t(0,i.length-1)],borderBottomRightRadius:i[t(0,i.length-1)]}),$(d).draggabilly({containment:!0}),$(d).on("dragStart",o=>{e++,$(d).css({zIndex:e})})})}$(".joe_comment .joe_pagination a").each((e,o)=>{const t=$(o).attr("href");t&&t.includes("#")&&$(o).attr("href",t.replace("#comments","?scroll=joe_comment"))})}),window.addEventListener("load",function(){{const e=new URLSearchParams(location.search).get("scroll");if(e){const o=$(".joe_header").height();let t=null;if(t=$("#"+e).length>0?$("#"+e):$("."+e),t&&t.length>0){const e=t.offset().top-o-15;window.scrollTo({top:e,behavior:"smooth"})}}}}); \ No newline at end of file diff --git a/assets/js/joe.post_page.js b/assets/js/joe.post_page.js index 6557f60..fe99d71 100644 --- a/assets/js/joe.post_page.js +++ b/assets/js/joe.post_page.js @@ -1,221 +1,221 @@ document.addEventListener('DOMContentLoaded', () => { - const encryption = str => window.btoa(unescape(encodeURIComponent(str))); - const decrypt = str => decodeURIComponent(escape(window.atob(str))); + const encryption = str => window.btoa(unescape(encodeURIComponent(str))); + const decrypt = str => decodeURIComponent(escape(window.atob(str))); - /* 当前页的CID */ - const cid = $('.joe_detail').attr('data-cid'); + /* 当前页的CID */ + const cid = $('.joe_detail').attr('data-cid'); - /* 获取本篇文章百度收录情况 */ - { - $.ajax({ - url: Joe.BASE_API, - type: 'POST', - dataType: 'json', - data: { routeType: 'baidu_record', site: window.location.href }, - success(res) { - if (res.data && res.data === '已收录') { - $('#Joe_Baidu_Record').css('color', '#67C23A'); - $('#Joe_Baidu_Record').html('已收录'); - } else { - /* 如果填写了Token,则自动推送给百度 */ - if (Joe.BAIDU_PUSH) { - $('#Joe_Baidu_Record').html('未收录,推送中...'); - const _timer = setTimeout(function () { - $.ajax({ - url: Joe.BASE_API, - type: 'POST', - dataType: 'json', - data: { - routeType: 'baidu_push', - domain: encodeURI(window.location.hostname), - url: encodeURI(window.location.href) - }, - success(res) { - if (res.error) { - $('#Joe_Baidu_Record').html('推送失败,请检查!'); - } else { - $('#Joe_Baidu_Record').html('推送成功!'); - } - } - }); - clearTimeout(_timer); - }, 1000); - } else { - const url = `https://ziyuan.baidu.com/linksubmit/url?sitename=${encodeURI(window.location.href)}`; - $('#Joe_Baidu_Record').html(`未收录,提交收录`); - } - } - } - }); - } + /* 获取本篇文章百度收录情况 */ + { + $.ajax({ + url: Joe.BASE_API, + type: 'POST', + dataType: 'json', + data: { routeType: 'baidu_record', site: window.location.href }, + success(res) { + if (res.data && res.data === '已收录') { + $('#Joe_Baidu_Record').css('color', '#67C23A'); + $('#Joe_Baidu_Record').html('已收录'); + } else { + /* 如果填写了Token,则自动推送给百度 */ + if (Joe.BAIDU_PUSH) { + $('#Joe_Baidu_Record').html('未收录,推送中...'); + const _timer = setTimeout(function () { + $.ajax({ + url: Joe.BASE_API, + type: 'POST', + dataType: 'json', + data: { + routeType: 'baidu_push', + domain: window.location.protocol + '//' + window.location.hostname, + url: encodeURI(window.location.protocol + '//' + window.location.hostname + window.location.pathname) + }, + success(res) { + if (res.data.error) { + $('#Joe_Baidu_Record').html('推送失败,请检查!'); + } else { + $('#Joe_Baidu_Record').html('推送成功!'); + } + } + }); + clearTimeout(_timer); + }, 1000); + } else { + const url = `https://ziyuan.baidu.com/linksubmit/url?sitename=${encodeURI(window.location.href)}`; + $('#Joe_Baidu_Record').html(`未收录,提交收录`); + } + } + } + }); + } - /* 激活代码高亮 */ - { - Prism.highlightAll(); - $("pre[class*='language-']").each(function (index, item) { - let text = $(item).find("code[class*='language-']").text(); - let span = $(``); - new ClipboardJS(span[0], { text: () => text }).on('success', () => Qmsg.success('复制成功!')); - $(item).append(span); - }); - } + /* 激活代码高亮 */ + { + Prism.highlightAll(); + $("pre[class*='language-']").each(function (index, item) { + let text = $(item).find("code[class*='language-']").text(); + let span = $(``); + new ClipboardJS(span[0], { text: () => text }).on('success', () => Qmsg.success('复制成功!')); + $(item).append(span); + }); + } - /* 激活图片预览功能 */ - { - $('.joe_detail__article img:not(img.owo_image)').each(function () { - $(this).wrap($(``)); - }); - } + /* 激活图片预览功能 */ + { + $('.joe_detail__article img:not(img.owo_image)').each(function () { + $(this).wrap($(``)); + }); + } - /* 设置文章内的链接为新窗口打开 */ - { - $('.joe_detail__article a:not(.joe_detail__article-anote)').each(function () { - $(this).attr({ target: '_blank', rel: 'noopener noreferrer nofollow' }); - }); - } + /* 设置文章内的链接为新窗口打开 */ + { + $('.joe_detail__article a:not(.joe_detail__article-anote)').each(function () { + $(this).attr({ target: '_blank', rel: 'noopener noreferrer nofollow' }); + }); + } - /* 激活浏览功能 */ - { - let viewsArr = localStorage.getItem(encryption('views')) ? JSON.parse(decrypt(localStorage.getItem(encryption('views')))) : []; - const flag = viewsArr.includes(cid); - if (!flag) { - $.ajax({ - url: Joe.BASE_API, - type: 'POST', - dataType: 'json', - data: { routeType: 'handle_views', cid }, - success(res) { - if (res.code !== 1) return; - $('#Joe_Article_Views').html(`${res.data.views} 阅读`); - viewsArr.push(cid); - const name = encryption('views'); - const val = encryption(JSON.stringify(viewsArr)); - localStorage.setItem(name, val); - } - }); - } - } + /* 激活浏览功能 */ + { + let viewsArr = localStorage.getItem(encryption('views')) ? JSON.parse(decrypt(localStorage.getItem(encryption('views')))) : []; + const flag = viewsArr.includes(cid); + if (!flag) { + $.ajax({ + url: Joe.BASE_API, + type: 'POST', + dataType: 'json', + data: { routeType: 'handle_views', cid }, + success(res) { + if (res.code !== 1) return; + $('#Joe_Article_Views').html(`${res.data.views} 阅读`); + viewsArr.push(cid); + const name = encryption('views'); + const val = encryption(JSON.stringify(viewsArr)); + localStorage.setItem(name, val); + } + }); + } + } - /* 激活文章点赞功能 */ - { - let agreeArr = localStorage.getItem(encryption('agree')) ? JSON.parse(decrypt(localStorage.getItem(encryption('agree')))) : []; - if (agreeArr.includes(cid)) $('.joe_detail__agree .icon-1').addClass('active'); - else $('.joe_detail__agree .icon-2').addClass('active'); - let _loading = false; - $('.joe_detail__agree .icon').on('click', function () { - if (_loading) return; - _loading = true; - agreeArr = localStorage.getItem(encryption('agree')) ? JSON.parse(decrypt(localStorage.getItem(encryption('agree')))) : []; - let flag = agreeArr.includes(cid); - $.ajax({ - url: Joe.BASE_API, - type: 'POST', - dataType: 'json', - data: { routeType: 'handle_agree', cid, type: flag ? 'disagree' : 'agree' }, - success(res) { - if (res.code !== 1) return; - $('.joe_detail__agree .text').html(res.data.agree); - if (flag) { - const index = agreeArr.findIndex(_ => _ === cid); - agreeArr.splice(index, 1); - $('.joe_detail__agree .icon-1').removeClass('active'); - $('.joe_detail__agree .icon-2').addClass('active'); - $('.joe_detail__agree .icon').removeClass('active'); - } else { - agreeArr.push(cid); - $('.joe_detail__agree .icon-2').removeClass('active'); - $('.joe_detail__agree .icon-1').addClass('active'); - $('.joe_detail__agree .icon').addClass('active'); - } - const name = encryption('agree'); - const val = encryption(JSON.stringify(agreeArr)); - localStorage.setItem(name, val); - }, - complete() { - _loading = false; - } - }); - }); - } + /* 激活文章点赞功能 */ + { + let agreeArr = localStorage.getItem(encryption('agree')) ? JSON.parse(decrypt(localStorage.getItem(encryption('agree')))) : []; + if (agreeArr.includes(cid)) $('.joe_detail__agree .icon-1').addClass('active'); + else $('.joe_detail__agree .icon-2').addClass('active'); + let _loading = false; + $('.joe_detail__agree .icon').on('click', function () { + if (_loading) return; + _loading = true; + agreeArr = localStorage.getItem(encryption('agree')) ? JSON.parse(decrypt(localStorage.getItem(encryption('agree')))) : []; + let flag = agreeArr.includes(cid); + $.ajax({ + url: Joe.BASE_API, + type: 'POST', + dataType: 'json', + data: { routeType: 'handle_agree', cid, type: flag ? 'disagree' : 'agree' }, + success(res) { + if (res.code !== 1) return; + $('.joe_detail__agree .text').html(res.data.agree); + if (flag) { + const index = agreeArr.findIndex(_ => _ === cid); + agreeArr.splice(index, 1); + $('.joe_detail__agree .icon-1').removeClass('active'); + $('.joe_detail__agree .icon-2').addClass('active'); + $('.joe_detail__agree .icon').removeClass('active'); + } else { + agreeArr.push(cid); + $('.joe_detail__agree .icon-2').removeClass('active'); + $('.joe_detail__agree .icon-1').addClass('active'); + $('.joe_detail__agree .icon').addClass('active'); + } + const name = encryption('agree'); + const val = encryption(JSON.stringify(agreeArr)); + localStorage.setItem(name, val); + }, + complete() { + _loading = false; + } + }); + }); + } - /* 格式化分页的hash值 */ - { - $('.joe_comment .joe_pagination a').each((index, item) => { - const href = $(item).attr('href'); - if (href && href.includes('#')) { - $(item).attr('href', href.replace('#comments', '?scroll=joe_comment')); - } - }); - } + /* 格式化分页的hash值 */ + { + $('.joe_comment .joe_pagination a').each((index, item) => { + const href = $(item).attr('href'); + if (href && href.includes('#')) { + $(item).attr('href', href.replace('#comments', '?scroll=joe_comment')); + } + }); + } - /* 密码保护文章,输入密码访问 */ - { - let isSubmit = false; - $('.joe_detail__article-protected').on('submit', function (e) { - e.preventDefault(); - const url = $(this).attr('action') + '&time=' + +new Date(); - const protectPassword = $(this).find('input[type="password"]').val(); - if (protectPassword.trim() === '') return Qmsg.info('请输入访问密码!'); - if (isSubmit) return; - isSubmit = true; - $.ajax({ - url, - type: 'POST', - data: { - cid, - protectPassword - }, - dataType: 'text', - success(res) { - let arr = [], - str = ''; - arr = $(res).contents(); - Array.from(arr).forEach(_ => { - if (_.parentNode.className === 'container') str = _; - }); - if (!/Joe/.test(res)) { - Qmsg.warning(str.textContent.trim() || ''); - isSubmit = false; - $('.joe_comment__respond-form .foot .submit button').html('发表评论'); - } else { - location.reload(); - } - } - }); - }); - } + /* 密码保护文章,输入密码访问 */ + { + let isSubmit = false; + $('.joe_detail__article-protected').on('submit', function (e) { + e.preventDefault(); + const url = $(this).attr('action') + '&time=' + +new Date(); + const protectPassword = $(this).find('input[type="password"]').val(); + if (protectPassword.trim() === '') return Qmsg.info('请输入访问密码!'); + if (isSubmit) return; + isSubmit = true; + $.ajax({ + url, + type: 'POST', + data: { + cid, + protectPassword + }, + dataType: 'text', + success(res) { + let arr = [], + str = ''; + arr = $(res).contents(); + Array.from(arr).forEach(_ => { + if (_.parentNode.className === 'container') str = _; + }); + if (!/Joe/.test(res)) { + Qmsg.warning(str.textContent.trim() || ''); + isSubmit = false; + $('.joe_comment__respond-form .foot .submit button').html('发表评论'); + } else { + location.reload(); + } + } + }); + }); + } - /* 激活文章视频模块 */ - { - if ($('.joe_detail__article-video').length > 0) { - const player = $('.joe_detail__article-video .play iframe').attr('data-player'); - $('.joe_detail__article-video .episodes .item').on('click', function () { - $(this).addClass('active').siblings().removeClass('active'); - const url = $(this).attr('data-src'); - $('.joe_detail__article-video .play iframe').attr({ src: player + url }); - }); - $('.joe_detail__article-video .episodes .item').first().click(); - } - } + /* 激活文章视频模块 */ + { + if ($('.joe_detail__article-video').length > 0) { + const player = $('.joe_detail__article-video .play iframe').attr('data-player'); + $('.joe_detail__article-video .episodes .item').on('click', function () { + $(this).addClass('active').siblings().removeClass('active'); + const url = $(this).attr('data-src'); + $('.joe_detail__article-video .play iframe').attr({ src: player + url }); + }); + $('.joe_detail__article-video .episodes .item').first().click(); + } + } }); /* 写在load事件里,为了解决图片未加载完成,滚动距离获取会不准确的问题 */ window.addEventListener('load', function () { - /* 判断地址栏是否有锚点链接,有则跳转到对应位置 */ - { - const scroll = new URLSearchParams(location.search).get('scroll'); - if (scroll) { - const height = $('.joe_header').height(); - let elementEL = null; - if ($('#' + scroll).length > 0) { - elementEL = $('#' + scroll); - } else { - elementEL = $('.' + scroll); - } - if (elementEL && elementEL.length > 0) { - const top = elementEL.offset().top - height - 15; - window.scrollTo({ top, behavior: 'smooth' }); - } - } - } + /* 判断地址栏是否有锚点链接,有则跳转到对应位置 */ + { + const scroll = new URLSearchParams(location.search).get('scroll'); + if (scroll) { + const height = $('.joe_header').height(); + let elementEL = null; + if ($('#' + scroll).length > 0) { + elementEL = $('#' + scroll); + } else { + elementEL = $('.' + scroll); + } + if (elementEL && elementEL.length > 0) { + const top = elementEL.offset().top - height - 15; + window.scrollTo({ top, behavior: 'smooth' }); + } + } + } }); diff --git a/assets/js/joe.post_page.min.js b/assets/js/joe.post_page.min.js index 100f8fe..a74dc05 100644 --- a/assets/js/joe.post_page.min.js +++ b/assets/js/joe.post_page.min.js @@ -1 +1 @@ -document.addEventListener("DOMContentLoaded",()=>{const e=e=>window.btoa(unescape(encodeURIComponent(e))),t=e=>decodeURIComponent(escape(window.atob(e))),a=$(".joe_detail").attr("data-cid");$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"baidu_record",site:window.location.href},success(e){if(e.data&&"已收录"===e.data)$("#Joe_Baidu_Record").css("color","#67C23A"),$("#Joe_Baidu_Record").html("已收录");else if(Joe.BAIDU_PUSH){$("#Joe_Baidu_Record").html('未收录,推送中...');const e=setTimeout(function(){$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"baidu_push",domain:encodeURI(window.location.hostname),url:encodeURI(window.location.href)},success(e){e.error?$("#Joe_Baidu_Record").html('推送失败,请检查!'):$("#Joe_Baidu_Record").html('推送成功!')}}),clearTimeout(e)},1e3)}else{const e=`https://ziyuan.baidu.com/linksubmit/url?sitename=${encodeURI(window.location.href)}`;$("#Joe_Baidu_Record").html(`未收录,提交收录`)}}}),Prism.highlightAll(),$("pre[class*='language-']").each(function(e,t){let a=$(t).find("code[class*='language-']").text(),o=$('');new ClipboardJS(o[0],{text:()=>a}).on("success",()=>Qmsg.success("复制成功!")),$(t).append(o)}),$(".joe_detail__article img:not(img.owo_image)").each(function(){$(this).wrap($(``))}),$(".joe_detail__article a:not(.joe_detail__article-anote)").each(function(){$(this).attr({target:"_blank",rel:"noopener noreferrer nofollow"})});{let o=localStorage.getItem(e("views"))?JSON.parse(t(localStorage.getItem(e("views")))):[];const i=o.includes(a);i||$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"handle_views",cid:a},success(t){if(1!==t.code)return;$("#Joe_Article_Views").html(`${t.data.views} 阅读`),o.push(a);const i=e("views"),s=e(JSON.stringify(o));localStorage.setItem(i,s)}})}{let o=localStorage.getItem(e("agree"))?JSON.parse(t(localStorage.getItem(e("agree")))):[];o.includes(a)?$(".joe_detail__agree .icon-1").addClass("active"):$(".joe_detail__agree .icon-2").addClass("active");let i=!1;$(".joe_detail__agree .icon").on("click",function(){if(i)return;i=!0,o=localStorage.getItem(e("agree"))?JSON.parse(t(localStorage.getItem(e("agree")))):[];let s=o.includes(a);$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"handle_agree",cid:a,type:s?"disagree":"agree"},success(t){if(1!==t.code)return;if($(".joe_detail__agree .text").html(t.data.agree),s){const e=o.findIndex(e=>e===a);o.splice(e,1),$(".joe_detail__agree .icon-1").removeClass("active"),$(".joe_detail__agree .icon-2").addClass("active"),$(".joe_detail__agree .icon").removeClass("active")}else o.push(a),$(".joe_detail__agree .icon-2").removeClass("active"),$(".joe_detail__agree .icon-1").addClass("active"),$(".joe_detail__agree .icon").addClass("active");const i=e("agree"),n=e(JSON.stringify(o));localStorage.setItem(i,n)},complete(){i=!1}})})}$(".joe_comment .joe_pagination a").each((e,t)=>{const a=$(t).attr("href");a&&a.includes("#")&&$(t).attr("href",a.replace("#comments","?scroll=joe_comment"))});{let e=!1;$(".joe_detail__article-protected").on("submit",function(t){t.preventDefault();const o=$(this).attr("action")+"&time="+ +new Date,i=$(this).find('input[type="password"]').val();if(""===i.trim())return Qmsg.info("请输入访问密码!");e||(e=!0,$.ajax({url:o,type:"POST",data:{cid:a,protectPassword:i},dataType:"text",success(t){let a=[],o="";a=$(t).contents(),Array.from(a).forEach(e=>{"container"===e.parentNode.className&&(o=e)}),/Joe/.test(t)?location.reload():(Qmsg.warning(o.textContent.trim()||""),e=!1,$(".joe_comment__respond-form .foot .submit button").html("发表评论"))}}))})}if($(".joe_detail__article-video").length>0){const e=$(".joe_detail__article-video .play iframe").attr("data-player");$(".joe_detail__article-video .episodes .item").on("click",function(){$(this).addClass("active").siblings().removeClass("active");const t=$(this).attr("data-src");$(".joe_detail__article-video .play iframe").attr({src:e+t})}),$(".joe_detail__article-video .episodes .item").first().click()}}),window.addEventListener("load",function(){{const e=new URLSearchParams(location.search).get("scroll");if(e){const t=$(".joe_header").height();let a=null;if(a=$("#"+e).length>0?$("#"+e):$("."+e),a&&a.length>0){const e=a.offset().top-t-15;window.scrollTo({top:e,behavior:"smooth"})}}}}); \ No newline at end of file +document.addEventListener("DOMContentLoaded",()=>{const e=e=>window.btoa(unescape(encodeURIComponent(e))),t=e=>decodeURIComponent(escape(window.atob(e))),a=$(".joe_detail").attr("data-cid");$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"baidu_record",site:window.location.href},success(e){if(e.data&&"已收录"===e.data)$("#Joe_Baidu_Record").css("color","#67C23A"),$("#Joe_Baidu_Record").html("已收录");else if(Joe.BAIDU_PUSH){$("#Joe_Baidu_Record").html('未收录,推送中...');const e=setTimeout(function(){$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"baidu_push",domain:window.location.protocol+"//"+window.location.hostname,url:encodeURI(window.location.protocol+"//"+window.location.hostname+window.location.pathname)},success(e){e.data.error?$("#Joe_Baidu_Record").html('推送失败,请检查!'):$("#Joe_Baidu_Record").html('推送成功!')}}),clearTimeout(e)},1e3)}else{const e=`https://ziyuan.baidu.com/linksubmit/url?sitename=${encodeURI(window.location.href)}`;$("#Joe_Baidu_Record").html(`未收录,提交收录`)}}}),Prism.highlightAll(),$("pre[class*='language-']").each(function(e,t){let a=$(t).find("code[class*='language-']").text(),o=$('');new ClipboardJS(o[0],{text:()=>a}).on("success",()=>Qmsg.success("复制成功!")),$(t).append(o)}),$(".joe_detail__article img:not(img.owo_image)").each(function(){$(this).wrap($(``))}),$(".joe_detail__article a:not(.joe_detail__article-anote)").each(function(){$(this).attr({target:"_blank",rel:"noopener noreferrer nofollow"})});{let o=localStorage.getItem(e("views"))?JSON.parse(t(localStorage.getItem(e("views")))):[];const i=o.includes(a);i||$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"handle_views",cid:a},success(t){if(1!==t.code)return;$("#Joe_Article_Views").html(`${t.data.views} 阅读`),o.push(a);const i=e("views"),n=e(JSON.stringify(o));localStorage.setItem(i,n)}})}{let o=localStorage.getItem(e("agree"))?JSON.parse(t(localStorage.getItem(e("agree")))):[];o.includes(a)?$(".joe_detail__agree .icon-1").addClass("active"):$(".joe_detail__agree .icon-2").addClass("active");let i=!1;$(".joe_detail__agree .icon").on("click",function(){if(i)return;i=!0,o=localStorage.getItem(e("agree"))?JSON.parse(t(localStorage.getItem(e("agree")))):[];let n=o.includes(a);$.ajax({url:Joe.BASE_API,type:"POST",dataType:"json",data:{routeType:"handle_agree",cid:a,type:n?"disagree":"agree"},success(t){if(1!==t.code)return;if($(".joe_detail__agree .text").html(t.data.agree),n){const e=o.findIndex(e=>e===a);o.splice(e,1),$(".joe_detail__agree .icon-1").removeClass("active"),$(".joe_detail__agree .icon-2").addClass("active"),$(".joe_detail__agree .icon").removeClass("active")}else o.push(a),$(".joe_detail__agree .icon-2").removeClass("active"),$(".joe_detail__agree .icon-1").addClass("active"),$(".joe_detail__agree .icon").addClass("active");const i=e("agree"),s=e(JSON.stringify(o));localStorage.setItem(i,s)},complete(){i=!1}})})}$(".joe_comment .joe_pagination a").each((e,t)=>{const a=$(t).attr("href");a&&a.includes("#")&&$(t).attr("href",a.replace("#comments","?scroll=joe_comment"))});{let e=!1;$(".joe_detail__article-protected").on("submit",function(t){t.preventDefault();const o=$(this).attr("action")+"&time="+ +new Date,i=$(this).find('input[type="password"]').val();if(""===i.trim())return Qmsg.info("请输入访问密码!");e||(e=!0,$.ajax({url:o,type:"POST",data:{cid:a,protectPassword:i},dataType:"text",success(t){let a=[],o="";a=$(t).contents(),Array.from(a).forEach(e=>{"container"===e.parentNode.className&&(o=e)}),/Joe/.test(t)?location.reload():(Qmsg.warning(o.textContent.trim()||""),e=!1,$(".joe_comment__respond-form .foot .submit button").html("发表评论"))}}))})}if($(".joe_detail__article-video").length>0){const e=$(".joe_detail__article-video .play iframe").attr("data-player");$(".joe_detail__article-video .episodes .item").on("click",function(){$(this).addClass("active").siblings().removeClass("active");const t=$(this).attr("data-src");$(".joe_detail__article-video .play iframe").attr({src:e+t})}),$(".joe_detail__article-video .episodes .item").first().click()}}),window.addEventListener("load",function(){{const e=new URLSearchParams(location.search).get("scroll");if(e){const t=$(".joe_header").height();let a=null;if(a=$("#"+e).length>0?$("#"+e):$("."+e),a&&a.length>0){const e=a.offset().top-t-15;window.scrollTo({top:e,behavior:"smooth"})}}}}); \ No newline at end of file diff --git a/core/function.php b/core/function.php index 0dd24d3..fe92b40 100644 --- a/core/function.php +++ b/core/function.php @@ -2,7 +2,7 @@ /* 获取主题当前版本号 */ function _getVersion() { - return "6.7.9"; + return "6.8.0"; }; /* 判断是否是手机 */ diff --git a/core/route.php b/core/route.php index 5b4b8ad..73052b3 100644 --- a/core/route.php +++ b/core/route.php @@ -192,11 +192,11 @@ function _pushRecord($self) header("HTTP/1.1 200 OK"); header('Access-Control-Allow-Origin:*'); header("Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept"); + $token = Helper::options()->JBaiduToken; $domain = $self->request->domain; $url = $self->request->url; - $token = Helper::options()->JBaiduToken; $urls = explode(",", $url); - $api = 'http://data.zz.baidu.com/urls?site=' . $domain . '&token=' . $token; + $api = "http://data.zz.baidu.com/urls?site={$domain}&token={$token}"; $ch = curl_init(); $options = array( CURLOPT_URL => $api, @@ -207,7 +207,12 @@ function _pushRecord($self) ); curl_setopt_array($ch, $options); $result = curl_exec($ch); - $self->response->throwJson(json_decode($result)); + curl_close($ch); + $self->response->throwJson(array( + 'domain' => $domain, + 'url' => $url, + 'data' => json_decode($result, TRUE) + )); } /* 获取壁纸分类 已测试 √ */ diff --git a/friends.php b/friends.php index 7d0184e..8074c55 100644 --- a/friends.php +++ b/friends.php @@ -18,7 +18,7 @@ - + diff --git a/leaving.php b/leaving.php index d02f175..d03f986 100644 --- a/leaving.php +++ b/leaving.php @@ -15,7 +15,7 @@ need('public/include.php'); ?> - + diff --git a/package.json b/package.json index fa6800d..3d99e87 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typecho-joe-next", - "version": "6.7.9", + "version": "6.8.0", "description": "A Theme Of Typecho", "main": "index.php", "keywords": [ diff --git a/page.php b/page.php index 0348178..9d8c565 100644 --- a/page.php +++ b/page.php @@ -7,7 +7,7 @@ - + diff --git a/post.php b/post.php index 22842c9..1874650 100644 --- a/post.php +++ b/post.php @@ -7,7 +7,7 @@ - +