This commit is contained in:
haoouba 2021-02-18 20:38:17 +08:00
parent 4fba3b24a2
commit ac7017f6b9
7 changed files with 36 additions and 30 deletions

View File

@ -1,4 +1,21 @@
document.addEventListener('DOMContentLoaded', () => {
/* 公共修改地址栏URL函数 */
const changeURLArg = (url, arg, arg_val) => {
let pattern = arg + '=([^&]*)'
let replaceText = arg + '=' + arg_val
if (url.match(pattern)) {
let tmp = '/(' + arg + '=)([^&]*)/gi'
return url.replace(eval(tmp), replaceText)
} else {
if (url.match('[?]')) {
return url + '&' + replaceText
} else {
return url + '?' + replaceText
}
}
return url + '\n' + arg + '\n' + arg_val
}
/* 初始化昼夜模式 */
{
if (localStorage.getItem('data-night')) {
@ -327,7 +344,7 @@ document.addEventListener('DOMContentLoaded', () => {
Qmsg.warning(str.textContent.trim() || '')
isSubmit = false
} else {
window.location.href = Joe.changeURLArg(location.href, 'scroll', 'joe_comment')
window.location.href = changeURLArg(location.href, 'scroll', 'joe_comment')
}
}
})

View File

@ -1,4 +1,7 @@
document.addEventListener('DOMContentLoaded', () => {
const encryption = str => window.btoa(unescape(encodeURIComponent(str)))
const decrypt = str => decodeURIComponent(escape(window.atob(str)))
/* 当前页的CID */
const cid = $('.joe_detail').attr('data-cid')
@ -76,7 +79,7 @@ document.addEventListener('DOMContentLoaded', () => {
/* 激活浏览功能 */
{
let viewsArr = localStorage.getItem(Joe.encryption('views')) ? JSON.parse(Joe.decrypt(localStorage.getItem(Joe.encryption('views')))) : []
let viewsArr = localStorage.getItem(encryption('views')) ? JSON.parse(decrypt(localStorage.getItem(encryption('views')))) : []
const flag = viewsArr.includes(cid)
if (!flag) {
$.ajax({
@ -87,8 +90,8 @@ document.addEventListener('DOMContentLoaded', () => {
if (res.code !== 1) return
$('#Joe_Article_Views').html(`${res.data.views} 阅读`)
viewsArr.push(cid)
const name = Joe.encryption('views')
const val = Joe.encryption(JSON.stringify(viewsArr))
const name = encryption('views')
const val = encryption(JSON.stringify(viewsArr))
localStorage.setItem(name, val)
}
})
@ -97,14 +100,14 @@ document.addEventListener('DOMContentLoaded', () => {
/* 激活文章点赞功能 */
{
let agreeArr = localStorage.getItem(Joe.encryption('agree')) ? JSON.parse(Joe.decrypt(localStorage.getItem(Joe.encryption('agree')))) : []
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(Joe.encryption('agree')) ? JSON.parse(Joe.decrypt(localStorage.getItem(Joe.encryption('agree')))) : []
agreeArr = localStorage.getItem(encryption('agree')) ? JSON.parse(decrypt(localStorage.getItem(encryption('agree')))) : []
let flag = agreeArr.includes(cid)
$.ajax({
url: Joe.BASE_API,
@ -125,8 +128,8 @@ document.addEventListener('DOMContentLoaded', () => {
$('.joe_detail__agree .icon-1').addClass('active')
$('.joe_detail__agree .icon').addClass('active')
}
const name = Joe.encryption('agree')
const val = Joe.encryption(JSON.stringify(agreeArr))
const name = encryption('agree')
const val = encryption(JSON.stringify(agreeArr))
localStorage.setItem(name, val)
},
complete() {

View File

@ -3,7 +3,7 @@
/* 获取主题当前版本号 */
function _getVersion()
{
return "5.1.3";
return "5.1.4";
};
/* 判断是否是手机 */

View File

@ -18,7 +18,7 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-tomorrow.css">
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/prism/prism.js"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.post&page.js'); ?>"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.post&page.js?v=111'); ?>"></script>
</head>
<body>

View File

@ -8,7 +8,7 @@
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.post.css'); ?>">
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/prism/prism.js"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.post&page.js?v=545'); ?>"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.post&page.js?v=111'); ?>"></script>
</head>
<body>

View File

@ -8,7 +8,7 @@
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.post.css'); ?>">
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/prism/prism.js"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.post&page.js?v=545'); ?>"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.post&page.js?v=111'); ?>"></script>
</head>
<body>

View File

@ -1,6 +1,6 @@
<script>
/* 用于页面一进入直接判断是否是黑夜模式请勿将它移走或删除必须放这里解决闪烁问题下面的style也是请勿修改 */
if (localStorage.getItem('data-night')) document.querySelector("html").setAttribute("data-night", "night")
localStorage.getItem("data-night") && document.querySelector("html").setAttribute("data-night", "night");
window.Joe = {
LIVE2D: '<?php $this->options->JLive2d() ?>',
BASE_API: '<?php echo $this->options->rewrite == 0 ? '/index.php/joe/api' : '/joe/api' ?>',
@ -11,24 +11,10 @@
DOCUMENT_TITLE: '<?php $this->options->JDocumentTitle() ?>',
LAZY_LOAD: '<?php _getLazyload() ?>',
BIRTHDAY: '<?php $this->options->JBirthDay() ?>',
encryption: str => window.btoa(unescape(encodeURIComponent(str))),
decrypt: str => decodeURIComponent(escape(window.atob(str))),
changeURLArg: (url, arg, arg_val) => {
let pattern = arg + '=([^&]*)';
let replaceText = arg + '=' + arg_val;
if (url.match(pattern)) {
let tmp = '/(' + arg + '=)([^&]*)/gi';
return url.replace(eval(tmp), replaceText);
} else {
if (url.match('[?]')) {
return url + '&' + replaceText;
} else {
return url + '?' + replaceText;
}
}
return url + '\n' + arg + '\n' + arg_val;
}
}
/* 判断是否是ie浏览器 */
function detectIE(){var n=window.navigator.userAgent,e=n.indexOf("MSIE ");if(e>0)return parseInt(n.substring(e+5,n.indexOf(".",e)),10);if(n.indexOf("Trident/")>0){var r=n.indexOf("rv:");return parseInt(n.substring(r+3,n.indexOf(".",r)),10)}var i=n.indexOf("Edge/");return i>0&&parseInt(n.substring(i+5,n.indexOf(".",i)),10)}
detectIE() && (alert('当前站点不支持IE浏览器或您开启了兼容模式请使用其他浏览器访问或关闭兼容模式。'), (location.href = 'https://www.baidu.com'))
</script>
<style>
body::before {