diff --git a/assets/js/joe.global.js b/assets/js/joe.global.js index 75d2d1a..f8fba12 100644 --- a/assets/js/joe.global.js +++ b/assets/js/joe.global.js @@ -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') } } }) diff --git a/assets/js/joe.post&page.js b/assets/js/joe.post&page.js index 02bba19..1aabd25 100644 --- a/assets/js/joe.post&page.js +++ b/assets/js/joe.post&page.js @@ -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() { diff --git a/core/function.php b/core/function.php index b7bfc1e..f113201 100644 --- a/core/function.php +++ b/core/function.php @@ -3,7 +3,7 @@ /* 获取主题当前版本号 */ function _getVersion() { - return "5.1.3"; + return "5.1.4"; }; /* 判断是否是手机 */ diff --git a/friends.php b/friends.php index ab7c93a..ac7b7dd 100644 --- a/friends.php +++ b/friends.php @@ -18,7 +18,7 @@ - + diff --git a/page.php b/page.php index a5a78c7..859f017 100644 --- a/page.php +++ b/page.php @@ -8,7 +8,7 @@ - + diff --git a/post.php b/post.php index e4b5c80..6dfe5bd 100644 --- a/post.php +++ b/post.php @@ -8,7 +8,7 @@ - + diff --git a/public/include.php b/public/include.php index c18284b..966ec31 100644 --- a/public/include.php +++ b/public/include.php @@ -1,6 +1,6 @@