优化结果
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>每日笑话</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="card">
|
||||
<p id="joke">加载中...</p>
|
||||
<button id="next">换一个</button>
|
||||
</div>
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
107
InfoGenie-frontend/public/60sapi/娱乐消遣/随机冷笑话/css/background.css
Normal file
107
InfoGenie-frontend/public/60sapi/娱乐消遣/随机冷笑话/css/background.css
Normal file
@@ -0,0 +1,107 @@
|
||||
/* background.css - 动态渐变背景 */
|
||||
body {
|
||||
background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
|
||||
background-size: 400% 400%;
|
||||
animation: gradient 15s ease infinite;
|
||||
}
|
||||
|
||||
@keyframes gradient {
|
||||
0% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
50% {
|
||||
background-position: 100% 50%;
|
||||
}
|
||||
100% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
}
|
||||
:root {
|
||||
--bg-yellow: #FFFDE7; /* 浅黄 */
|
||||
--bg-blue: #E3F2FD; /* 淡蓝 */
|
||||
}
|
||||
|
||||
body {
|
||||
background: linear-gradient(180deg, var(--bg-yellow) 0%, var(--bg-blue) 100%);
|
||||
background-attachment: fixed; /* 固定背景,滚动时不移动 */
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
overflow: hidden;
|
||||
transition: background-color 0.5s ease;
|
||||
}
|
||||
|
||||
/* Light Theme (Default) */
|
||||
[data-theme="light"] {
|
||||
background: linear-gradient(to bottom, #87CEEB, #B0E0E6);
|
||||
}
|
||||
|
||||
/* Dark Theme */
|
||||
[data-theme="dark"] {
|
||||
background: linear-gradient(to bottom, #232526, #414345);
|
||||
}
|
||||
[data-theme="dark"] .snowflake {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* Winter Theme */
|
||||
[data-theme="winter"] {
|
||||
background: linear-gradient(to bottom, #a1c4fd, #c2e9fb);
|
||||
}
|
||||
[data-theme="winter"] .background-bottom {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
background: linear-gradient(to top, white, rgba(255, 255, 255, 0));
|
||||
z-index: -1;
|
||||
border-radius: 50% 50% 0 0 / 20px;
|
||||
box-shadow: 0 -10px 20px rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
|
||||
|
||||
#snowflake-container {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.snowflake {
|
||||
position: absolute;
|
||||
top: -10%;
|
||||
color: white;
|
||||
font-size: 20px;
|
||||
user-select: none;
|
||||
animation: fall linear infinite;
|
||||
}
|
||||
|
||||
@keyframes fall {
|
||||
to {
|
||||
transform: translateY(105vh) rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
#frost-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: url('https://www.transparenttextures.com/patterns/ice-age.png') repeat;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.5s ease-in-out;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
#frost-overlay.is-frosted {
|
||||
opacity: 0.3;
|
||||
}
|
||||
217
InfoGenie-frontend/public/60sapi/娱乐消遣/随机冷笑话/css/style.css
Normal file
217
InfoGenie-frontend/public/60sapi/娱乐消遣/随机冷笑话/css/style.css
Normal file
@@ -0,0 +1,217 @@
|
||||
:root {
|
||||
--primary-color-light: #4A90E2;
|
||||
--text-color-light: #333;
|
||||
--card-bg-light: rgba(255, 255, 255, 0.85);
|
||||
|
||||
--primary-color-dark: #5271C4;
|
||||
--text-color-dark: #E0E0E0;
|
||||
--card-bg-dark: rgba(40, 40, 40, 0.85);
|
||||
|
||||
--primary-color-winter: #6A82FB;
|
||||
--text-color-winter: #2c3e50;
|
||||
--card-bg-winter: rgba(255, 255, 255, 0.7);
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 100vh;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.top-nav {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
padding: 5px;
|
||||
border-radius: 50px;
|
||||
backdrop-filter: blur(5px);
|
||||
}
|
||||
|
||||
.theme-switcher {
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.theme-btn {
|
||||
background: transparent;
|
||||
border: 2px solid transparent;
|
||||
border-radius: 50%;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
font-size: 1.5em;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s, border-color 0.2s;
|
||||
}
|
||||
.theme-btn:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
.theme-btn.active {
|
||||
border-color: white;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-family: 'ZCOOL KuaiLe', cursive;
|
||||
font-size: 3em;
|
||||
margin-bottom: 20px;
|
||||
transition: color 0.5s ease;
|
||||
}
|
||||
|
||||
.joke-stream {
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 25px;
|
||||
}
|
||||
|
||||
.joke-card {
|
||||
border-radius: 20px;
|
||||
padding: 30px 40px;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
min-height: 150px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
backdrop-filter: blur(8px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
transition: background-color 0.5s ease, border-color 0.5s ease;
|
||||
}
|
||||
|
||||
#joke-text {
|
||||
font-size: 1.5em;
|
||||
line-height: 1.6;
|
||||
transition: opacity 0.3s, color 0.5s ease;
|
||||
}
|
||||
|
||||
/* --- Theming --- */
|
||||
|
||||
/* Light Theme */
|
||||
[data-theme="light"] .title { color: white; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2); }
|
||||
[data-theme="light"] .joke-card { background-color: var(--card-bg-light); }
|
||||
[data-theme="light"] #joke-text { color: var(--text-color-light); }
|
||||
[data-theme="light"] #new-joke-btn { background-color: var(--primary-color-light); box-shadow: 0 4px 15px rgba(74, 144, 226, 0.4); }
|
||||
[data-theme="light"] footer { color: rgba(255, 255, 255, 0.8); }
|
||||
|
||||
/* Dark Theme */
|
||||
[data-theme="dark"] .title { color: #EAEAEA; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); }
|
||||
[data-theme="dark"] .joke-card { background-color: var(--card-bg-dark); border-color: rgba(255, 255, 255, 0.1); }
|
||||
[data-theme="dark"] #joke-text { color: var(--text-color-dark); }
|
||||
[data-theme="dark"] #new-joke-btn { background-color: var(--primary-color-dark); box-shadow: 0 4px 15px rgba(82, 113, 196, 0.4); }
|
||||
[data-theme="dark"] footer { color: rgba(200, 200, 200, 0.7); }
|
||||
|
||||
/* Winter Theme */
|
||||
[data-theme="winter"] .title { color: #1e3a5f; text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.7); }
|
||||
[data-theme="winter"] .joke-card {
|
||||
background-color: var(--card-bg-winter);
|
||||
border-color: rgba(255, 255, 255, 0.8);
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1), inset 0 0 15px rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
[data-theme="winter"] #joke-text { color: var(--text-color-winter); }
|
||||
[data-theme="winter"] #new-joke-btn { background-color: var(--primary-color-winter); box-shadow: 0 4px 15px rgba(106, 130, 251, 0.4); }
|
||||
[data-theme="winter"] footer { color: #1e3a5f; }
|
||||
|
||||
|
||||
.controls {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
#new-joke-btn {
|
||||
color: white;
|
||||
font-size: 1.2em;
|
||||
font-weight: bold;
|
||||
padding: 15px 35px;
|
||||
border: none;
|
||||
border-radius: 50px;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.5s ease;
|
||||
}
|
||||
|
||||
#new-joke-btn:hover {
|
||||
transform: translateY(-3px);
|
||||
}
|
||||
|
||||
#new-joke-btn:active {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
.interactions {
|
||||
margin-top: 25px;
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.interaction-btn {
|
||||
background: rgba(255, 255, 255, 0.7);
|
||||
border: 1px solid rgba(255, 255, 255, 0.9);
|
||||
border-radius: 50%;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
font-size: 1.5em;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s, background-color 0.2s;
|
||||
}
|
||||
|
||||
.interaction-btn:hover {
|
||||
transform: scale(1.1);
|
||||
background: white;
|
||||
}
|
||||
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
font-size: 0.9em;
|
||||
transition: color 0.5s ease;
|
||||
}
|
||||
|
||||
/* Loader */
|
||||
#loader {
|
||||
position: absolute;
|
||||
transition: color 0.5s ease;
|
||||
}
|
||||
[data-theme="light"] #loader { color: var(--primary-color-light); }
|
||||
[data-theme="dark"] #loader { color: var(--primary-color-dark); }
|
||||
[data-theme="winter"] #loader { color: var(--primary-color-winter); }
|
||||
|
||||
.snowflake-loader {
|
||||
font-size: 40px;
|
||||
display: inline-block;
|
||||
animation: spin 1.5s linear infinite;
|
||||
}
|
||||
.snowflake-loader::before {
|
||||
content: '❄';
|
||||
}
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 600px) {
|
||||
.title {
|
||||
font-size: 2.5em;
|
||||
}
|
||||
.joke-card {
|
||||
padding: 25px;
|
||||
}
|
||||
#joke-text {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
.top-nav {
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
}
|
||||
}
|
||||
58
InfoGenie-frontend/public/60sapi/娱乐消遣/随机冷笑话/index.html
Normal file
58
InfoGenie-frontend/public/60sapi/娱乐消遣/随机冷笑话/index.html
Normal file
@@ -0,0 +1,58 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>随机冷笑话</title>
|
||||
<link href="https://fonts.googleapis.com/css2?family=ZCOOL+KuaiLe&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/background.css">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
</head>
|
||||
<body data-theme="light">
|
||||
<div id="snowflake-container"></div>
|
||||
<div id="frost-overlay"></div>
|
||||
<div class="background-bottom"></div>
|
||||
|
||||
<nav class="top-nav">
|
||||
<div class="theme-switcher">
|
||||
<button class="theme-btn" data-theme-target="light" title="清新风">☀️</button>
|
||||
<button class="theme-btn" data-theme-target="dark" title="暗黑风">🌙</button>
|
||||
<button class="theme-btn" data-theme-target="winter" title="冰雪风">❄️</button>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<header>
|
||||
<h1 class="title">冷笑话生成器</h1>
|
||||
</header>
|
||||
|
||||
<main class="joke-card">
|
||||
<div id="loader" class="hidden">
|
||||
<div class="snowflake-loader"></div>
|
||||
<p>思考中...</p>
|
||||
</div>
|
||||
<p id="joke-text">点击下面的按钮,来点冷笑话吧!</p>
|
||||
</main>
|
||||
|
||||
<div class="controls">
|
||||
<button id="new-joke-btn">再来一个</button>
|
||||
</div>
|
||||
|
||||
<div class="interactions">
|
||||
<button class="interaction-btn" id="like-btn" title="好笑">👍</button>
|
||||
<button class="interaction-btn" id="dislike-btn" title="不好笑">👎</button>
|
||||
<button class="interaction-btn" id="collect-btn" title="收藏">⭐️</button>
|
||||
<button class="interaction-btn" id="share-btn" title="分享">🔗</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<p>© 2024 冷笑话工坊</p>
|
||||
</footer>
|
||||
|
||||
<audio id="wind-sound" src="https://www.soundjay.com/nature/sounds/wind-howl-01.mp3" preload="auto"></audio>
|
||||
<audio id="snow-sound" src="https://www.soundjay.com/nature/sounds/walking-in-snow-01.mp3" preload="auto"></audio>
|
||||
|
||||
<script src="js/script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
117
InfoGenie-frontend/public/60sapi/娱乐消遣/随机冷笑话/js/script.js
Normal file
117
InfoGenie-frontend/public/60sapi/娱乐消遣/随机冷笑话/js/script.js
Normal file
@@ -0,0 +1,117 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const jokeTextElem = document.getElementById('joke-text');
|
||||
const newJokeBtn = document.getElementById('new-joke-btn');
|
||||
const snowflakeContainer = document.getElementById('snowflake-container');
|
||||
const frostOverlay = document.getElementById('frost-overlay');
|
||||
const windSound = document.getElementById('wind-sound');
|
||||
const snowSound = document.getElementById('snow-sound');
|
||||
const loader = document.getElementById('loader');
|
||||
const themeBtns = document.querySelectorAll('.theme-btn');
|
||||
|
||||
const apiEndpoints = [
|
||||
'https://60s.api.shumengya.top/v2/dad-joke',
|
||||
];
|
||||
let currentApiIndex = 0;
|
||||
|
||||
async function fetchJoke() {
|
||||
jokeTextElem.classList.add('hidden');
|
||||
loader.classList.remove('hidden');
|
||||
|
||||
try {
|
||||
const response = await fetch(apiEndpoints[currentApiIndex]);
|
||||
if (!response.ok) throw new Error('Network response was not ok');
|
||||
|
||||
const data = await response.json();
|
||||
if (data.code === 200 && data.data.content) {
|
||||
updateJokeText(data.data.content);
|
||||
if (document.body.dataset.theme === 'winter' && Math.random() < 0.3) {
|
||||
triggerFrostEffect();
|
||||
}
|
||||
} else {
|
||||
throw new Error('API returned invalid data');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Fetch error:', error);
|
||||
currentApiIndex = (currentApiIndex + 1) % apiEndpoints.length;
|
||||
if (currentApiIndex !== 0) {
|
||||
fetchJoke();
|
||||
} else {
|
||||
jokeTextElem.textContent = '冰箱坏了,暂时没有冷笑话...';
|
||||
}
|
||||
} finally {
|
||||
loader.classList.add('hidden');
|
||||
jokeTextElem.classList.remove('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
function updateJokeText(text) {
|
||||
jokeTextElem.textContent = '';
|
||||
let i = 0;
|
||||
const typing = setInterval(() => {
|
||||
if (i < text.length) {
|
||||
jokeTextElem.textContent += text.charAt(i);
|
||||
i++;
|
||||
} else {
|
||||
clearInterval(typing);
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
|
||||
function createSnowflakes() {
|
||||
const snowflakeCount = document.body.dataset.theme === 'dark' ? 50 : 30;
|
||||
snowflakeContainer.innerHTML = '';
|
||||
for (let i = 0; i < snowflakeCount; i++) {
|
||||
const snowflake = document.createElement('div');
|
||||
snowflake.className = 'snowflake';
|
||||
snowflake.textContent = '❄️';
|
||||
|
||||
snowflake.style.left = `${Math.random() * 100}vw`;
|
||||
snowflake.style.fontSize = `${Math.random() * 15 + 10}px`;
|
||||
snowflake.style.opacity = Math.random() * 0.5 + 0.3;
|
||||
|
||||
const duration = Math.random() * 10 + 8;
|
||||
const delay = Math.random() * 10;
|
||||
|
||||
snowflake.style.animation = `fall ${duration}s linear ${delay}s infinite`;
|
||||
|
||||
snowflakeContainer.appendChild(snowflake);
|
||||
}
|
||||
}
|
||||
|
||||
function triggerFrostEffect() {
|
||||
frostOverlay.classList.add('is-frosted');
|
||||
windSound.play().catch(e => console.error("Audio play failed:", e));
|
||||
setTimeout(() => {
|
||||
frostOverlay.classList.remove('is-frosted');
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
function setTheme(theme) {
|
||||
document.body.dataset.theme = theme;
|
||||
localStorage.setItem('joke-theme', theme);
|
||||
|
||||
themeBtns.forEach(btn => {
|
||||
btn.classList.toggle('active', btn.dataset.themeTarget === theme);
|
||||
});
|
||||
|
||||
if (theme === 'winter') {
|
||||
snowSound.play().catch(e => console.error("Audio play failed:", e));
|
||||
}
|
||||
|
||||
// Recreate snowflakes for theme-specific density
|
||||
createSnowflakes();
|
||||
}
|
||||
|
||||
themeBtns.forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
setTheme(btn.dataset.themeTarget);
|
||||
});
|
||||
});
|
||||
|
||||
newJokeBtn.addEventListener('click', fetchJoke);
|
||||
|
||||
// Initial setup
|
||||
const savedTheme = localStorage.getItem('joke-theme') || 'light';
|
||||
setTheme(savedTheme);
|
||||
fetchJoke();
|
||||
});
|
||||
1
InfoGenie-frontend/public/60sapi/娱乐消遣/随机冷笑话/接口集合.json
Normal file
1
InfoGenie-frontend/public/60sapi/娱乐消遣/随机冷笑话/接口集合.json
Normal file
@@ -0,0 +1 @@
|
||||
["https://60s.api.shumengya.top"]
|
||||
8
InfoGenie-frontend/public/60sapi/娱乐消遣/随机冷笑话/返回接口.json
Normal file
8
InfoGenie-frontend/public/60sapi/娱乐消遣/随机冷笑话/返回接口.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"code": 200,
|
||||
"message": "获取成功。数据来自官方/权威源头,以确保稳定与实时。开源地址 https://github.com/vikiboss/60s,反馈群 595941841",
|
||||
"data": {
|
||||
"index": 121,
|
||||
"content": "这个世界上谁最懂猪?蜘蛛(知猪)人。"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user