😚BUG修补:解决在原生butterfly下,pjax适配问题

This commit is contained in:
柳神 2024-08-15 01:51:11 +08:00
parent 68034a2268
commit 69e7e41082
5 changed files with 41 additions and 22 deletions

View File

@ -26,7 +26,7 @@
--shadow-color: var(--shadow-color-light); --shadow-color: var(--shadow-color-light);
--border-color: var(--border-color-light); --border-color: var(--border-color-light);
--modal-bg-color: rgba(255, 255, 255, 0.5); --modal-bg-color: rgba(255, 255, 255, 0.5);
--modal-content-bg-color: rgba(239, 250, 255, 0.7); --modal-content-bg-color: rgba(239, 250, 255, 0.5);
--load-more-btn-bg-color: var(--container-bg-color); --load-more-btn-bg-color: var(--container-bg-color);
} }
@ -155,10 +155,10 @@ body {
#modal-author-avatar { #modal-author-avatar {
display: block; display: block;
margin: 0 auto 10px; margin: 0 auto;
border-radius: 50%; border-radius: 50%;
width: 80px; width: 100px;
height: 80px; height: 100px;
object-fit: cover; object-fit: cover;
} }
@ -166,7 +166,7 @@ body {
display: block; display: block;
text-align: center; text-align: center;
font-size: 15px; font-size: 15px;
margin: 25px 0; margin: 15px 0;
color: var(--hover-color); color: var(--hover-color);
text-decoration: none; text-decoration: none;
} }
@ -242,6 +242,11 @@ body {
flex-direction: column; flex-direction: column;
justify-content: space-between; justify-content: space-between;
height: 150px; height: 150px;
transition: border 0.3s;
}
.card:hover {
border: 1px solid var(--hover-color);
} }
.card-title { .card-title {
@ -319,6 +324,13 @@ body {
width: 140px; width: 140px;
height: 140px; height: 140px;
opacity: 0.4; opacity: 0.4;
transition: transform 0.6s ease, bottom 0.3s ease, right 0.3s ease; /* 0.3秒的平滑过渡效果 */
}
#friend-circle-lite-root .card:hover .card-bg {
transform: scale(1.1);
bottom: -10px;
right: -8px;
} }
#load-more-btn { #load-more-btn {
@ -327,7 +339,7 @@ body {
background-color: var(--container-bg-color); background-color: var(--container-bg-color);
cursor: pointer; cursor: pointer;
width: 200px; width: 200px;
border-radius: 20px; border-radius: 10px;
border: 1px solid var(--border-color); border: 1px solid var(--border-color);
padding: 3px; padding: 3px;
transition: all 0.3s; transition: all 0.3s;

View File

@ -17,7 +17,7 @@ function initialize_fc_lite() {
const loadMoreBtn = document.createElement('button'); const loadMoreBtn = document.createElement('button');
loadMoreBtn.id = 'load-more-btn'; loadMoreBtn.id = 'load-more-btn';
loadMoreBtn.innerText = '显示更多'; loadMoreBtn.innerText = '再来亿点';
root.appendChild(loadMoreBtn); root.appendChild(loadMoreBtn);
// 创建统计信息容器 // 创建统计信息容器
@ -42,7 +42,7 @@ function initialize_fc_lite() {
} }
} }
fetch(`${UserConfig.private_api_url}all.json`) fetch(`${UserConfig.private_api_url}all`)
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
localStorage.setItem(cacheKey, JSON.stringify(data)); localStorage.setItem(cacheKey, JSON.stringify(data));
@ -50,7 +50,7 @@ function initialize_fc_lite() {
processArticles(data); processArticles(data);
}) })
.finally(() => { .finally(() => {
loadMoreBtn.innerText = '显示更多'; // 恢复按钮文本 loadMoreBtn.innerText = '再来亿点'; // 恢复按钮文本
}); });
} }
@ -152,7 +152,7 @@ function initialize_fc_lite() {
const authorArticles = allArticles.filter(article => article.author === author); const authorArticles = allArticles.filter(article => article.author === author);
// 仅仅取前五个,防止文章过多导致模态框过长,如果不够五个则全部取出 // 仅仅取前五个,防止文章过多导致模态框过长,如果不够五个则全部取出
authorArticles.slice(0, 5).forEach(article => { authorArticles.slice(0, 4).forEach(article => {
const articleDiv = document.createElement('div'); const articleDiv = document.createElement('div');
articleDiv.className = 'modal-article'; articleDiv.className = 'modal-article';
@ -203,12 +203,19 @@ function initialize_fc_lite() {
}; };
}; };
document.addEventListener("DOMContentLoaded", function() { //document.addEventListener("DOMContentLoaded", function() {
setTimeout(initialize_fc_lite, 0); // setTimeout(initialize_fc_lite, 0);
}); //});
document.addEventListener('pjax:complete', function() { //document.addEventListener('pjax:complete', function() {
setTimeout(initialize_fc_lite, 0); // setTimeout(initialize_fc_lite, 0);
}); //});
setTimeout(initialize_fc_lite, 0); //setTimeout(initialize_fc_lite, 0);
function whenDOMReady() {
initialize_fc_lite();
}
whenDOMReady()
document.addEventListener("pjax:complete", whenDOMReady)

2
main/fclite.min.css vendored

File diff suppressed because one or more lines are too long

2
main/fclite.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -30,7 +30,7 @@ async def root():
@app.get('/all') @app.get('/all')
async def get_all_articles(): async def get_all_articles():
try: try:
with open('all.json', 'r', encoding='utf-8') as f: with open('./all.json', 'r', encoding='utf-8') as f:
articles_data = json.load(f) articles_data = json.load(f)
return JSONResponse(content=articles_data) return JSONResponse(content=articles_data)
except FileNotFoundError: except FileNotFoundError:
@ -41,7 +41,7 @@ async def get_all_articles():
@app.get('/errors') @app.get('/errors')
async def get_error_friends(): async def get_error_friends():
try: try:
with open('errors.json', 'r', encoding='utf-8') as f: with open('./errors.json', 'r', encoding='utf-8') as f:
errors_data = json.load(f) errors_data = json.load(f)
return JSONResponse(content=errors_data) return JSONResponse(content=errors_data)
except FileNotFoundError: except FileNotFoundError:
@ -52,7 +52,7 @@ async def get_error_friends():
@app.get('/random') @app.get('/random')
async def get_random_article(): async def get_random_article():
try: try:
with open('all.json', 'r', encoding='utf-8') as f: with open('./all.json', 'r', encoding='utf-8') as f:
articles_data = json.load(f) articles_data = json.load(f)
if articles_data.get("article_data"): if articles_data.get("article_data"):
random_article = random.choice(articles_data["article_data"]) random_article = random.choice(articles_data["article_data"])