fixed: memos 适配pjax刷新
This commit is contained in:
1 parent
7c5a70dbe1
commit
218da80cb5
6 files changed
+1269
-291
No files matched your search
+1
@@ -0,0 +1 @@
|
||||
"use strict";function _typeof(o){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}!function(o,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(o=o||self,o.cocoMessage=t())}(void 0,function(){function o(o,t){var e=document.createElement("div");for(var n in o){var s=o[n];"className"==n?(n="class",e.setAttribute(n,s)):"_"==n[0]&&e.addEventListener(n.slice(1),s)}if("string"==typeof t)e.innerHTML=t;else if("object"==_typeof(t)&&t.tagName)e.appendChild(t);else if(t)for(var i=0;i<t.length;i++){var r=t[i];e.appendChild(r)}return e}function t(o,t){for(var e in t)o.style[e]=t[e];""===o.getAttribute("style")&&o.removeAttribute("style")}function e(o,t){var e=o.className||"";if(!n(e,t)){var s=e.split(/\s+/);s.push(t),o.className=s.join(" ")}}function n(o,t){return o.indexOf(t)>-1}function s(o,t){var e=o.className||"";if(n(e,t)){var s=e.split(/\s+/),i=s.indexOf(t);s.splice(i,1),o.className=s.join(" ")}""===o.className&&o.removeAttribute("class")}function i(){return r(arguments,"info")}function r(o,t){var e={};for(var n in h)e[n]=h[n];for(var s=0;s<o.length;s++){var i=o[s];void 0!==i&&("string"==typeof i||"object"==_typeof(i)?e.msg=i:"boolean"==typeof i?e.showClose=i:"function"==typeof i?e.onClose=i:"number"==typeof i&&(e.duration=i))}return e.type=t,a(e)}function a(e){var n=e.type,i=e.duration,r=e.msg,a=e.showClose,d=e.onClose,g=0===i,p=l();"loading"==n&&(r=""===r?"正在加载":r,g=a,i=0);var h=o({className:"coco-msg-wrapper"},[o({className:"coco-msg coco-msg-fade-in ".concat(n)},[o({className:"coco-msg-icon"},p[n]),o({className:"coco-msg-content"},r),o({className:"coco-msg-wait ".concat(g?"coco-msg-pointer":"coco-msg-wait-hidden"),_click:function(){f(h,d)}},c(g)||"")])]);return 0!==i&&setTimeout(function(){f(h,d)},i),m.children.length||document.body.appendChild(m),m.appendChild(h),t(h,{height:h.offsetHeight+"px"}),setTimeout(function(){s(h.children[0],"coco-msg-fade-in")},300),function(){f(h,d)}}function c(o){return o?'<svg class="coco-msg-close" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5514"><path d="M810 274l-238 238 238 238-60 60-238-238-238 238-60-60 238-238-238-238 60-60 238 238 238-238z" p-id="5515"></path></svg>':""}function f(o,n){o&&(t(o,{padding:0,height:0}),e(o.children[0],"coco-msg-fade-out"),n&&n(),setTimeout(function(){if(o){for(var t=!1,e=0;e<m.children.length;e++)m.children[e]===o&&(t=!0);t&&d(o),o=null,m.children.length||t&&d(m)}},300))}function l(){return{info:'\n <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3250"><path d="M469.333333 341.333333h85.333334v469.333334H469.333333z" fill="#ffffff" p-id="3251"></path><path d="M469.333333 213.333333h85.333334v85.333334H469.333333z" fill="#ffffff" p-id="3252"></path><path d="M384 341.333333h170.666667v85.333334H384z" fill="#ffffff" p-id="3253"></path><path d="M384 725.333333h256v85.333334H384z" fill="#ffffff" p-id="3254"></path></svg>\n ',success:'\n <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1807"><path d="M455.42 731.04c-8.85 0-17.75-3.05-24.99-9.27L235.14 553.91c-16.06-13.81-17.89-38.03-4.09-54.09 13.81-16.06 38.03-17.89 54.09-4.09l195.29 167.86c16.06 13.81 17.89 38.03 4.09 54.09-7.58 8.83-18.31 13.36-29.1 13.36z" p-id="1808" fill="#ffffff"></path><path d="M469.89 731.04c-8.51 0-17.07-2.82-24.18-8.6-16.43-13.37-18.92-37.53-5.55-53.96L734.1 307.11c13.37-16.44 37.53-18.92 53.96-5.55 16.43 13.37 18.92 37.53 5.55 53.96L499.67 716.89c-7.58 9.31-18.64 14.15-29.78 14.15z" p-id="1809" fill="#ffffff"></path></svg>\n ',warning:'\n <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="18912"><path d="M468.114286 621.714286c7.314286 21.942857 21.942857 36.571429 43.885714 36.571428s36.571429-14.628571 43.885714-36.571428L585.142857 219.428571c0-43.885714-36.571429-73.142857-73.142857-73.142857-43.885714 0-73.142857 36.571429-73.142857 80.457143l29.257143 394.971429zM512 731.428571c-43.885714 0-73.142857 29.257143-73.142857 73.142858s29.257143 73.142857 73.142857 73.142857 73.142857-29.257143 73.142857-73.142857-29.257143-73.142857-73.142857-73.142858z" p-id="18913" fill="#ffffff"></path></svg>\n ',error:'\n <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5514"><path d="M810 274l-238 238 238 238-60 60-238-238-238 238-60-60 238-238-238-238 60-60 238 238 238-238z" p-id="5515" fill="#ffffff"></path></svg>\n ',loading:'\n <div class="coco-msg_loading">\n <svg class="coco-msg-circular" viewBox="25 25 50 50">\n <circle class="coco-msg-path" cx="50" cy="50" r="20" fill="none" stroke-width="4" stroke-miterlimit="10"/>\n </svg>\n </div>\n '}}function d(o){oLine truncated
|
||||
@@ -150,64 +150,3 @@ if (document.querySelector("#Comments") && !isMobile()) {
|
||||
// 灯箱调用(首页顶部/Memos页面)
|
||||
window.ViewImage && ViewImage.init('.content_zhengwen img, .top-img,.gallery-thumbnail img,.posts_photo a,.photo-moment a');
|
||||
|
||||
// 页面上滑加载动画
|
||||
function animateSummaries() {
|
||||
const articles = document.querySelectorAll('.img-hide,.retu-hide'); // 包含新的类
|
||||
const shuffledArticles = Array.from(articles).sort(() => Math.random() - 0.5);
|
||||
|
||||
function animate(article, delay) {
|
||||
setTimeout(() => {
|
||||
article.classList.add('visible');
|
||||
}, delay);
|
||||
}
|
||||
|
||||
const options = {
|
||||
rootMargin: '0px 0px -70px 0px',
|
||||
};
|
||||
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach((entry, index) => {
|
||||
if (entry.isIntersecting) {
|
||||
// 类名 retu-hide 延迟 100 默认 img-hide 延迟 8,实现错落效果
|
||||
const delay = entry.target.classList.contains('retu-hide') ? index * 100 : index * 8;
|
||||
animate(entry.target, delay);
|
||||
observer.unobserve(entry.target);
|
||||
}
|
||||
});
|
||||
}, options);
|
||||
|
||||
shuffledArticles.forEach((article) => {
|
||||
observer.observe(article);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function initEditor() {
|
||||
const loadEditorBtn = document.getElementById("loadEditorBtn");
|
||||
const memosEditor = document.querySelector(".memos-editor");
|
||||
const editorBody = document.querySelector('.index-laodao');
|
||||
|
||||
if (loadEditorBtn) {
|
||||
loadEditorBtn.addEventListener("click", function () {
|
||||
// 切换编辑器显示状态
|
||||
getEditor != "show" ? hasMemosOpenId() : '';
|
||||
memosEditor.classList.toggle("d-none");
|
||||
|
||||
// 保存编辑器显示状态到 localStorage
|
||||
if (window.localStorage) {
|
||||
const isHidden = memosEditor.classList.contains("d-none");
|
||||
window.localStorage.setItem("memos-editor-display", isHidden ? "hide" : "show");
|
||||
getEditor = window.localStorage.getItem("memos-editor-display");
|
||||
}
|
||||
|
||||
// 平滑滚动到 .index-laodao
|
||||
if (editorBody && !memosEditor.classList.contains("d-none")) {
|
||||
editorBody.scrollIntoView({ behavior: 'smooth' });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化编辑器逻辑
|
||||
initEditor();
|
||||
|
||||
@@ -254,7 +254,7 @@ function updateHTMl(data,mode){
|
||||
// 在动画执行之前调整 z-index
|
||||
document.querySelector('.memos-more-ico').style.zIndex = '1';
|
||||
// 在DOM加载完毕后执行滑动加载动画
|
||||
animateSummaries();
|
||||
// animateSummaries();
|
||||
|
||||
if(document.querySelector('button.button-load')) document.querySelector('button.button-load').textContent = '再来几篇';
|
||||
}
|
||||
@@ -316,7 +316,7 @@ function loadArtalk(memo_id) {
|
||||
pageTitle: '',
|
||||
server: 'https://artalk.5b2.cn/',
|
||||
site: '优世界',
|
||||
darkMode: 'auto'
|
||||
darkMode: false
|
||||
});
|
||||
} else {
|
||||
commentDiv.classList.add('hidden');
|
||||
@@ -471,18 +471,17 @@ function getEditIcon() {
|
||||
getEditor == "show" ? hasMemosOpenId() : '';
|
||||
};
|
||||
|
||||
loadEditorBtn.addEventListener("click", function () {
|
||||
$('.load-memos-editor').on('click', function() {
|
||||
getEditor != "show" ? hasMemosOpenId() : '';
|
||||
document.querySelector(".memos-editor").classList.toggle("d-none");
|
||||
window.localStorage && window.localStorage.setItem("memos-editor-display", document.querySelector(".memos-editor").classList.contains("d-none") ? "hide" : "show");
|
||||
getEditor = window.localStorage && window.localStorage.getItem("memos-editor-display");
|
||||
|
||||
// 点击唠叨一下,平滑滚动到.index-laodao
|
||||
let editorBody = document.querySelector('.index-laodao');
|
||||
if (editorBody && !document.querySelector(".memos-editor").classList.contains("d-none")) {
|
||||
editorBody.scrollIntoView({ behavior: 'smooth' });
|
||||
}
|
||||
|
||||
// 点击唠叨一下,平滑滚动到.index-laodao
|
||||
let editorBody = document.querySelector('.index-laodao');
|
||||
if (editorBody && !document.querySelector(".memos-editor").classList.contains("d-none")) {
|
||||
editorBody.scrollIntoView({ behavior: 'smooth' });
|
||||
}
|
||||
});
|
||||
|
||||
//标签数据
|
||||
@@ -1249,14 +1248,3 @@ function handleTextareaInput() {
|
||||
handleTextareaInput();
|
||||
document.querySelector('.memos-editor-textarea').addEventListener('input', handleTextareaInput);
|
||||
|
||||
|
||||
//memos、评论链接跳转中间页
|
||||
document.body.addEventListener('click', function(e) {
|
||||
let target = e.target.closest('.atk-comment-wrap a, .datacont a');
|
||||
if (target && !target.href.includes('usj.cc')) {
|
||||
e.preventDefault();
|
||||
let encodedUrl = btoa(target.href);
|
||||
let url = '/tiaozhuan?target=' + encodedUrl;
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
});
|
||||
+1254
-15
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user