fixed: memos 适配pjax刷新

This commit is contained in:
小赵同学 committed 2025-02-22 14:41:44 +08:00
1 parent 7c5a70dbe1
commit 218da80cb5
6 files changed
+1264 -286

No files matched your search

+2 -2
View File
@@ -26,8 +26,8 @@
<script src="/js/tiaozhuan.js"></script>
<script async src="/js/bsz.js"></script>
<!--memos 内容-->
<script src="/js/memos.js?v=1.4.4"></script>
<script src="https://koobai.com/js/coco-message.min.js"></script>
<script src="/js/memos.js?v=1.4.4" defer></script>
<script src="/js/coco-message.min.js"></script>
<!--memos 结束-->
</body>
+4 -193
View File
@@ -2246,7 +2246,8 @@ diaoyong {
.resimg {
display: grid;
gap: 6px;
row-gap: 10px;
column-gap: 6px;
width: 60%;
grid-template-columns: repeat(2,1fr);
margin-top: 5px;
@@ -2681,7 +2682,7 @@ blockquote p {
.memos-menu {
margin-left: 40px;
color: transparent
/*color: transparent*/
}
.memos-menu-d {
@@ -2749,12 +2750,6 @@ blockquote p {
}
}
@media(max-width: 900px) and (prefers-color-scheme:dark) {
.bb-list-li {
background:var(--background-dark-color)
}
}
@media(min-width: 900px) {
.memos_diaoyong .resimg {
width:100%!important;
@@ -2771,148 +2766,6 @@ blockquote p {
}
}
@media(prefers-color-scheme: dark) {
.bb-list-li {
background:var(--background-dark-color)
}
.memos-xiala {
background-color: #282527
}
.memos-xiala .switchUser-btn,.memos-xiala .private-btn,.memos-xiala .oneday-btn,.image-btn,.code-btn {
color: var(--sanji-color)
}
.memos-more-ico svg {
color: var(--erji-color)
}
.memos-editor-textarea::placeholder {
color: #726859
}
.memos-tag-all {
background: #332e2f
}
.memos-tag-sc-2 {
color: var(--erji-color)
}
.memos-editor-body {
border: .5px solid #67534c
}
.memos-tag-dg {
color: var(--erji-color)
}
.memos-tag-sc {
color: #999!important;
background: #332e2f!important
}
.bb-load button {
background: var(--background-dark-color)
}
.memos_diaoyong_from a {
color: var(--sanji-color)
}
.memos_diaoyong_time,.memos_diaoyong_laiz a,.memos_diaoyong_more a,.memos_diaoyong_from {
color: var(--erji-color)
}
.memos_diaoyong_info p,.memos_diaoyong_info a {
color: var(--text-content-dark-color)!important
}
.talks_comments svg {
color: var(--erji-color)
}
.talks_comments svg:hover {
color: var(--text-highlight-color)
}
.datacont pre,blockquote p {
background: #2c2829
}
.datacont pre code {
color: var(--sanji-color)
}
.datacont code {
background: var(--background-dark-body-color);
border: 1px solid var(--background-dark-body-color);
color: var(--text-highlight-color)
}
blockquote p {
border-left: 4px solid #5f5f5f;
color: #888!important
}
.memos_diaoyong_info blockquote p {
color: #888!important
}
.outline svg {
color: var(--erji-color)
}
.outline svg:hover {
color: var(--sanji-color)
}
.memos-path-input,.memos-token-input {
color: var(--text-content-dark-color)!important
}
.editor-selector select {
color: var(--erji-color)!important
}
.editor-selector::after {
border-color: var(--erji-color)transparent transparent transparent
}
.memos-editor-content .memos-editor-textarea {
color: var(--text-content-dark-color)
}
.memos-open-api-submit {
background: var(--background-dark-color)!important;
color: var(--text-highlight-color)!important
}
.edit-btn,.archive-btn,.delete-btn,.cancel-edit-btn,.memos-image-list {
color: var(--erji-color)
}
.memos-menu-d,.memos-img-edit {
background-color: #282527
}
.cancel-edit-btn {
border: .5px solid #201d1e
}
#memos-tag-menu {
background-color: #282527!important;
box-shadow: 2px 4px 1rem rgba(0,0,0,.3)!important;
color: #888!important
}
.tag-option.selected {
background-color: #3e3e3e!important;
color: #bdbdbd!important
}
}
.emoji-selector {
display: grid;
grid-template-columns: repeat(auto-fill,minmax(32px,1fr));
@@ -3019,16 +2872,6 @@ blockquote p {
margin-right: 4px
}
@media(prefers-color-scheme: dark) {
.sidebar-posts-title a {
color:var(--text-content-dark-color)
}
.sidebar-biaot,.index-laodao {
color: var(--erji-color)
}
}
.about-img {
position: relative
}
@@ -3259,20 +3102,6 @@ blockquote p {
transform: scale(1.05)
}
@media(prefers-color-scheme: dark) {
.archive-time,.archive-time-index {
color:var(--erji-color)
}
.posts_list_article,.archives_one,.posts_list_article-index {
background: var(--background-dark-color)
}
.posts-description {
color: #b7b7ab
}
}
.page-tiaozhuan .header,.page-tiaozhuan .footer-background {
display: none
}
@@ -3333,24 +3162,6 @@ blockquote p {
display: inline-block
}
@media(prefers-color-scheme: dark) {
.tiaozhuan-all {
background:var(--background-dark-color)url(https://img.koobai.com/tiaozhuandark.webp)no-repeat 50%/cover;
color: #acacac
}
.tiaozhuan-title {
color: #ddd
}
}
@font-face {
font-family: JetBrainsMono;
font-display: swap;
src: url(https://img.koobai.com/fonts/JetBrainsMono-Regular.woff2)format("woff2");
unicode-range: U+30-39,U+41-5A,U+61-7A
}
@media(min-width: 700px) {
body {
padding:0 30px
@@ -3372,7 +3183,7 @@ blockquote p {
@media(min-width: 900px) {
.img-hide,.retu-hide {
transform: translateY(35%);
/*transform: translateY(35%);*/
transition: opacity .4s ease,transform .8s ease
}
+1
View File
@@ -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
-61
View File
@@ -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();
+3 -15
View File
@@ -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,7 +471,7 @@ 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");
@@ -482,7 +482,6 @@ function getEditIcon() {
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');
}
});
File diff suppressed because it is too large. Load diff