成烁的主页v2.0.0源码
GitHub开源项目地址
https://github.com/CS-love/home-pudlic
提示
本项目采用MIT协议开源,如要进行二次开发部署请注明原作者为成烁(chengshuo.top)
项目目录
index.html
style.css
script.js
HTML
html
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>成烁 探索不停</title>
<meta name="description" content="成烁的主页">
<meta name="keywords" content="成烁,前端开发,腾讯音乐人,游戏开发,个人博客,音乐制作">
<meta name="author" content="成烁">
<link rel="canonical" href="https://chengshuo.top">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?a1c068720de18bf2ceefe8789fbe8a7a";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<meta name="baidu-site-verification" content="codeva-fvl2Ahrto7" />
<!-- Favicon 配置 -->
<link rel="icon" href="photo/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="photo/favicon.ico">
<script defer src="https://cloud.umami.is/script.js" data-website-id="0eee97b7-b1c6-43c4-9ad5-873c1d20c0cc"></script>
</head>
<body>
<div class="share-button">
<img src="https://s21.ax1x.com/2025/03/15/pEasvX4.png" alt="分享">
</div>
<div class="share-modal">
<div class="share-content">
<h3 class="share-title">分享到</h3>
<div class="share-options">
<div class="share-option" data-platform="qq">
<img src="https://s21.ax1x.com/2025/03/15/pEaYbHU.png" alt="QQ">
<span>QQ</span>
</div>
<div class="share-option" data-platform="wechat">
<img src="https://s21.ax1x.com/2025/03/15/pEa6DII.png" alt="微信">
<span>微信</span>
</div>
<div class="share-option" data-platform="timeline">
<img src="https://s21.ax1x.com/2025/03/15/pEa6jeJ.png" alt="朋友圈">
<span>朋友圈</span>
</div>
<div class="share-option" data-platform="qzone">
<img src="https://s21.ax1x.com/2025/03/15/pEa6GPx.png" alt="QQ空间">
<span>QQ空间</span>
</div>
</div>
<div class="copy-link">
<img src="https://s21.ax1x.com/2025/03/15/pEacpJx.png" alt="复制链接">
<span>复制链接</span>
</div>
</div>
</div>
<div class="loading-overlay">
<div class="loader"></div>
</div>
<div class="announcement">
<div class="container">
<p>🎉成烁的主页V2.0.0版本,这里<a href="./old/mmexport1740737083818.jpg">加我微信</a></p>
</div>
</div>
<!--弹窗公告栏-->
<div class="announcement-popup">
<div class="announcement-card">
<div class="announcement-close">
<img src="https://s21.ax1x.com/2025/03/22/pE01fk4.png" alt="关闭">
</div>
<div class="announcement-content">
<h3>WELCOME</h3>
<p>欢迎访问chengshuo.top!这是我的个人主页。</p>
<p>这是我主页的2.0.0版本</p>
<img src="https://s21.ax1x.com/2025/06/05/pVPxXwR.png" alt="" style="max-width: 280px; width: 90%; border-radius: 10px; margin: 15px auto 5px; display: block; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
</div>
</div>
</div>
<header class="header">
<div class="container">
<div class="profile">
<img src="https://s21.ax1x.com/2025/03/15/pEaYGX6.jpg" alt="个人头像" class="profile-image">
<h1 class="name">成烁</h1>
<div class="typing-effect">
<span class="prefix">Hey, I'm a</span>
<div class="words">
<span class="word">前端工程师</span>
<span class="word">腾讯音乐人</span>
<span class="word">游戏开发者</span>
<span class="word">音乐制作人</span>
<span class="word">网文作家</span>
</div>
</div>
<p class="title">- 自己定义未来 -</p>
<div class="social-links">
<a href="https://github.com/CS-love" class="social-icon"><img src="https://s21.ax1x.com/2025/03/15/pEaYIcq.png" alt="github"></a>
<a href="https://space.bilibili.com/3494369623542102?spm_id_from=333.33.0.0" class="social-icon"><img src="https://s21.ax1x.com/2025/03/15/pEaYwhd.png" alt="bilibili"></a>
<a href="https://weibo.com/u/7978116953" class="social-icon"><img src="https://s21.ax1x.com/2025/03/15/pEaYD1I.png" alt="微博"></a>
<a href="https://pd.qq.com/s/64i6eiexz?businessType=9" class="social-icon"><img src="https://s21.ax1x.com/2025/03/15/pEaYbHU.png" alt="qq"></a>
<a href="./old/mmexport1740737083818.jpg" class="social-icon"><img src="https://s21.ax1x.com/2025/03/16/pEaHmDI.png" alt="微信"></a>
<a href="mailto:[email protected]" class="social-icon"><img src="https://s21.ax1x.com/2025/03/15/pEatA4H.png" alt="邮箱"></a>
</div>
<div class="button-container">
<button class="button">
<svg class="svgIcon" viewBox="0 0 512 512" height="1em" xmlns="http://www.w3.org/2000/svg"><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm50.7-186.9L162.4 380.6c-19.4 7.5-38.5-11.6-31-31l55.5-144.3c3.3-8.5 9.9-15.1 18.4-18.4l144.3-55.5c19.4-7.5 38.5 11.6 31 31L325.1 306.7c-3.2 8.5-9.9 15.1-18.4 18.4zM288 256a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"></path></svg>
探索更多
</button>
</div>
</div>
</div>
</header>
<!-- 更多内容弹窗 -->
<div class="more-content-modal">
<div class="more-content-container">
<div class="modal-header">
<button class="modal-close" aria-label="关闭"></button>
</div>
<div class="modal-content">
<div class="modal-content-container">
<div class="modal-background-card">
<div class="hitokoto-text"></div>
</div>
<div class="modal-time-card">
<div class="time-info">
<div class="current-time"></div>
<div class="current-date"></div>
</div>
</div>
</div>
<div class="skills-container">
<div class="skills-scroll">
<a href="https://github.com/CS-love" class="skill-link">
<img src="https://s21.ax1x.com/2025/03/15/pEaYIcq.png" alt="github">
<span>GitHub</span>
</a>
<a href="https://afdian.com/a/chengshuo/plan" class="skill-link">
<img src="https://s21.ax1x.com/2025/03/15/pEatdbT.png" alt="赞赏">
<span>打赏站长</span>
</a>
<a href="https://a.chengshuo.top/" class="skill-link">
<img src="https://s21.ax1x.com/2025/06/05/pVPziOH.png" alt="潜望萤火">
<span>待补</span>
</a>
<a href="https://blog.chengshuo.top/" class="skill-link">
<img src="https://s21.ax1x.com/2025/06/05/pVPziOH.png" alt="博客">
<span>待补</span>
</a>
</div>
</div>
<section class="projects">
<div class="container">
<div class="projects-grid">
<a href="https://m.kugou.com/singer/14768167" class="project-card">
<img src="https://s21.ax1x.com/2025/06/05/pVPzClD.jpg" alt="博客预览">
<h3>音乐人主页</h3>
<p style="font-size: 15px;">我是腾讯音乐人,已入驻QQ音乐,酷狗音乐,酷我音乐</p>
</a>
<a href="https://toolku.top" class="project-card">
<img src="https://s21.ax1x.com/2025/06/05/pVPzSfK.jpg" alt="技术社区预览">
<h3>TOOLKU</h3>
<p style="font-size: 15px;">自主开发的工具库网站</p>
</a>
<a href="https://blog.chengshuo.top/" class="project-card">
<img src="https://s21.ax1x.com/2025/06/05/pVPzP6e.jpg" alt="个人网站预览">
<h3>成烁BLOG</h3>
<p style="font-size: 15px;">成烁博客网站,成烁互动文档中心</p>
</a>
</div>
</div>
</section>
<section class="contact">
<div class="container">
<div class="contact-card">
<div class="contact-links">
<a href="https://imgse.com/chengshuo" class="contact-link">图床</a>
<a href="https://blog.csdn.net/2501_90499794?spm=1000.2115.3001.5343" class="contact-link">CSDN</a>
<a href="https://juejin.cn/user/2830598706831091" class="contact-link">掘金</a>
<a href="https://www.zhihu.com/people/93-96-38-81-15" class="contact-link">知乎</a>
<a href="https://afdian.com/a/chengshuo" class="contact-link">爱发电</a>
<a href="https://cloud.umami.is/share/IC8X0w6TaapfnXfN/chengshuo.top" class="contact-link">监测</a>
</div>
</div>
</div>
</section>
<footer>
<div class="container">
<div id="cc-myssl-id" style="display:flex; align-items:center; justify-content:center; gap:15px;">
<a href="https://myssl.com/chengshuo.top?from=mysslid"><img src="https://static.myssl.com/res/images/myssl-id3.png" alt="SSL徽章" style="max-height:50px;"></a>
<a href="https://chengshuo.top" target="_blank"><img src="https://s21.ax1x.com/2025/06/05/pVPvpAx.png" alt="个人网站徽章" style="max-height:50px;"></a>
</div>
<div class="qr-codes">
<div class="qr-code-container">
<img src="https://s21.ax1x.com/2025/06/05/pVPz6tx.jpg" alt="微信二维码" class="qr-code">
<div class="qr-code-label">微信公众号</div>
</div>
<div class="qr-code-container">
<img src="https://s21.ax1x.com/2025/06/05/pVPzdcF.jpg" alt="QQ二维码" class="qr-code">
<div class="qr-code-label">QQ频道</div>
</div>
</div>
<div class="runtime">本站已运行:<span id="runtime">计算中...</span></div>
<a href="https://icp.gov.moe/?keyword=20256002" target="_blank">萌ICP备20256002号</a>
<p>CopyRight © 2024-2025 成烁. All rights reserved.</p>
</div>
</footer>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
CSS
css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}
img {
pointer-events: none;
-webkit-user-drag: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* 加载动画样式 */
.loading-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #f5f5f5;
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
transition: opacity 0.5s ease-in-out;
}
.loading-overlay.hidden {
opacity: 0;
pointer-events: none;
}
.loader {
width: 44.8px;
height: 44.8px;
color: #6495ED;
position: relative;
margin: 0 auto;
background: radial-gradient(11.2px, currentColor 94%, #0000);
}
.loader:before {
content: '';
position: absolute;
inset: 0;
border-radius: 50%;
background: radial-gradient(10.08px at bottom right, #0000 94%, currentColor) top left,
radial-gradient(10.08px at bottom left, #0000 94%, currentColor) top right,
radial-gradient(10.08px at top right, #0000 94%, currentColor) bottom left,
radial-gradient(10.08px at top left, #0000 94%, currentColor) bottom right;
background-size: 22.4px 22.4px;
background-repeat: no-repeat;
animation: loader 1.5s infinite cubic-bezier(0.3, 1, 0, 1);
}
@keyframes loader {
33% {
inset: -11.2px;
transform: rotate(0deg);
}
66% {
inset: -11.2px;
transform: rotate(90deg);
}
100% {
inset: 0;
transform: rotate(90deg);
}
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6;
color: #333;
background-color: #f5f5f5;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
.announcement {
position: absolute;
top: 20px;
left: 50%;
transform: translateX(-50%);
background-color: white;
padding: 6px 12px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
border-radius: 10px;
z-index: 2;
max-width: 90%;
width: fit-content;
font-size: 15px;
line-height: 1.4;
}
.announcement p {
margin: 0;
text-align: center;
color: #333;
font-size: 15px;
}
.announcement a {
color: #3553ff;
text-decoration: none;
}
.announcement a:visited,
.announcement a:hover,
.announcement a:active {
color: #3553ff;
text-decoration: none;
}
.share-button {
position: absolute;
top: 20px;
right: 20px;
width: 40px;
height: 40px;
background: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(10px);
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
z-index: 1000;
transition: transform 0.3s ease;
}
.share-button:hover {
transform: scale(1.1);
}
.share-button img {
width: 20px;
height: 20px;
filter: brightness(0) invert(1);
}
.share-modal {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(5px);
display: none;
justify-content: center;
align-items: center;
z-index: 1001;
}
.share-modal.active {
display: flex;
animation: fadeIn 0.3s ease;
}
.share-content {
background: rgba(255, 255, 255, 0.95);
padding: 20px;
border-radius: 15px;
width: 300px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
transform: scale(0.9);
opacity: 0;
transition: all 0.3s ease;
}
.share-modal.active .share-content {
transform: scale(1);
opacity: 1;
}
.share-title {
text-align: center;
margin-bottom: 20px;
font-size: 1.2em;
color: #333;
}
.share-options {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 15px;
margin-bottom: 20px;
}
.share-option {
display: flex;
flex-direction: column;
align-items: center;
gap: 5px;
cursor: pointer;
padding: 10px;
border-radius: 10px;
transition: background-color 0.3s ease;
}
.share-option:hover {
background-color: rgba(0, 0, 0, 0.05);
}
.share-option img {
width: 30px;
height: 30px;
/* 保持社交图标原有颜色 */
}
.share-option span {
font-size: 12px;
color: #666;
}
.copy-link {
display: flex;
align-items: center;
gap: 10px;
background: #f5f5f5;
padding: 10px;
border-radius: 8px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.copy-link:hover {
background-color: #ebebeb;
}
.copy-link img {
width: 20px;
height: 20px;
}
.copy-link span {
font-size: 14px;
color: #666;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* Header Styles */
.header {
background: linear-gradient(135deg, #af40ff, #5b42f3 60%, #00ddeb);
color: white;
min-height: 100vh;
display: flex;
align-items: center;
text-align: center;
position: relative;
}
.profile {
max-width: 600px;
margin: 0 auto;
position: relative;
z-index: 1;
}
.profile-image {
width: 150px;
height: 150px;
border-radius: 50%;
border: 4px solid rgba(255, 255, 255, 0.3);
margin-bottom: 20px;
transition: transform 0.3s ease;
}
.profile-image:hover {
transform: scale(1.05);
}
.name {
font-size: 2.5em;
margin-bottom: 10px;
}
.title {
font-size: 1.2em;
opacity: 0.95;
}
.social-links {
display: flex;
justify-content: center;
gap: 15px;
margin-top: 20px;
}
.social-icon {
display: flex;
justify-content: center;
align-items: center;
width: 30px;
height: 30px;
transition: all 0.3s ease;
}
.social-icon img {
width: 20px;
height: 20px;
filter: brightness(0) invert(1);
transition: transform 0.3s ease;
}
.social-icon:hover {
/* 移除背景色变化,只保留图标放大效果 */
}
.social-icon:hover img {
transform: scale(1.1);
}
.bio {
font-size: 1.1em;
opacity: 0.9;
max-width: 500px;
margin: 0 auto;
}
.typing-effect {
font-size: 1.2em;
margin: 15px auto;
min-height: 1.5em;
position: relative;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
max-width: 500px;
}
.typing-effect .prefix {
color: white;
display: inline-block;
margin-right: 8px;
white-space: nowrap;
}
.typing-effect .words {
overflow: hidden;
position: relative;
height: 1.5em;
}
.typing-effect .word {
display: block;
height: 100%;
padding-left: 0;
color: white;
animation: spin_words 12s infinite;
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes spin_words {
0% {
transform: translateY(0);
}
5% {
transform: translateY(-102%);
}
25% {
transform: translateY(-100%);
}
30% {
transform: translateY(-202%);
}
50% {
transform: translateY(-200%);
}
55% {
transform: translateY(-302%);
}
75% {
transform: translateY(-300%);
}
80% {
transform: translateY(-402%);
}
100% {
transform: translateY(-400%);
}
}
/* Skills Container */
.skills-container {
margin-bottom: 20px;
background-color: rgba(255, 255, 255, 0.9);
border-radius: 10px;
padding: 15px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
/* Desktop styles */
@media (min-width: 769px) {
.skills-scroll {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 15px;
}
.skill-link {
display: flex;
align-items: center;
text-decoration: none;
color: #333;
padding: 12px;
transition: all 0.2s ease;
border-radius: 8px;
}
.skill-link:hover {
background: rgba(0, 0, 0, 0.05);
transform: translateY(-1px);
}
.skill-link img {
width: 28px;
height: 28px;
margin-right: 12px;
}
.skill-link span {
font-size: 1em;
color: #444;
font-weight: 500;
}
}
/* Mobile styles */
@media (max-width: 768px) {
.skills-container {
padding: 12px;
}
.skills-scroll {
display: flex;
overflow-x: auto;
scroll-snap-type: x mandatory;
-webkit-overflow-scrolling: touch;
padding: 5px 0;
gap: 20px;
}
.skills-scroll::-webkit-scrollbar {
display: none;
}
.skill-link {
flex: 0 0 calc(25% - 15px);
scroll-snap-align: start;
display: flex;
flex-direction: column;
align-items: center;
text-decoration: none;
color: #333;
padding: 8px 0;
}
.skill-link img {
width: 24px;
height: 24px;
margin-bottom: 6px;
}
.skill-link span {
font-size: 0.75em;
color: #444;
text-align: center;
white-space: nowrap;
}
}
.btn-icon {
width: 1em;
height: 1em;
vertical-align: middle;
margin-right: 5px;
}
.contact-icon {
width: 1.2em;
height: 1.2em;
vertical-align: middle;
margin-right: 5px;
}
/* Projects Section */
.projects {
padding: 40px 0;
background-color: white;
}
.projects h2 {
text-align: center;
margin-bottom: 50px;
}
.projects-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 25px;
padding: 0 20px;
}
.project-card {
background: white;
border-radius: 15px;
overflow: hidden;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
transition: all 0.3s ease;
height: 100%;
display: flex;
flex-direction: column;
text-decoration: none;
color: inherit;
}
.project-card:hover {
transform: translateY(-5px);
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
cursor: pointer;
}
.project-card img {
width: 100%;
height: 160px;
object-fit: cover;
}
.project-card h3 {
padding: 20px 20px 10px;
font-size: 1.25rem;
color: #2d3748;
}
.project-card p {
padding: 0 20px;
color: #718096;
flex-grow: 1;
margin-bottom: 20px;
}
.project-links {
padding: 0 20px 20px;
display: flex;
justify-content: center;
}
.btn {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 12px 24px;
background-color: #6366f1;
color: white;
text-decoration: none;
border-radius: 6px;
transition: background-color 0.3s ease;
font-size: 1.1rem;
}
.btn:hover {
background-color: #4f46e5;
}
/* Contact Section */
.contact {
padding: 40px 0;
background-color: white;
text-align: center;
}
.contact-card {
background: white;
border-radius: 15px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
padding: 30px;
max-width: 800px;
margin: 0 auto;
}
.contact-card h3 {
color: #333;
font-size: 1.5em;
margin-bottom: 25px;
}
.contact-links {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 15px;
margin: 0 auto;
letter-spacing: -0.2px;
line-height: 1.3;
}
.contact-link {
color: #333;
text-decoration: none;
transition: color 0.3s ease;
font-size: 15px;
padding: 8px 14px;
}
.contact-link:hover {
color: #6366f1;
}
/* Footer */
footer {
background-color: white;
color: #333;
padding: 20px 0;
text-align: center;
}
footer a {
color: #333;
text-decoration: none;
margin: 0 10px;
font-size: 13px;
line-height: 1.5;
}
footer p {
display: inline-block;
margin: 0 10px;
font-size: 13px;
line-height: 1.5;
}
/* QR Codes */
.qr-codes {
display: flex;
justify-content: center;
gap: 20px;
margin: 20px 0;
padding: 0 15px;
}
.qr-code-container {
display: flex;
flex-direction: column;
align-items: center;
}
.qr-code-label {
margin-top: 8px;
font-size: 12px;
color: #666;
text-align: center;
}
.qr-code {
width: 120px;
height: 120px;
border-radius: 8px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
@media (max-width: 768px) {
.qr-code {
width: 100px;
height: 100px;
}
}
.runtime {
margin-bottom: 10px;
font-size: 13px;
line-height: 1.5;
color: #666;
}
/* Responsive Design */
/* 公告弹窗样式 */
.announcement-popup {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(5px);
display: flex;
justify-content: center;
align-items: center;
z-index: 2000;
animation: fadeIn 0.3s ease;
}
.announcement-card {
background: white;
border-radius: 15px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
width: fit-content;
min-width: 280px;
max-width: 90%;
position: relative;
animation: scaleIn 0.3s ease;
overflow: hidden;
}
.announcement-close {
position: absolute;
top: 15px;
right: 15px;
width: 24px;
height: 24px;
cursor: pointer;
z-index: 10;
transition: transform 0.3s ease;
}
.announcement-close:hover {
transform: scale(1.1);
}
.announcement-close img {
width: 100%;
height: 100%;
pointer-events: auto;
}
.announcement-content {
padding: 25px 20px;
width: 100%;
box-sizing: border-box;
}
.announcement-content h3 {
font-size: 1.5em;
margin-bottom: 15px;
color: #333;
text-align: center;
}
.announcement-content p {
margin-bottom: 10px;
line-height: 1.6;
color: #555;
}
@keyframes scaleIn {
from {
transform: scale(0.9);
opacity: 0;
}
to {
transform: scale(1);
opacity: 1;
}
}
/* 隐藏公告弹窗的类 */
.announcement-popup.hidden {
display: none;
}
/* 更多内容按钮 */
.more-content-btn {
display: block;
margin: 20px auto 0;
padding: 12px 24px;
background: rgba(255, 255, 255, 0.2);
color: white;
border: none;
border-radius: 25px;
cursor: pointer;
font-size: 16px;
transition: all 0.3s ease;
backdrop-filter: blur(10px);
}
.more-content-btn:hover {
background: rgba(255, 255, 255, 0.3);
transform: translateY(-2px);
}
/* 更多内容弹窗 */
.more-content-modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0);
backdrop-filter: blur(5px);
z-index: 2000;
transition: background-color 0.3s ease;
}
.more-content-container {
position: relative;
width: 80%;
max-width: 800px;
height: 80vh;
background: white;
border-radius: 15px;
padding: 10px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
opacity: 0;
transform: scale(0.9);
transition: all 0.3s ease;
overflow: hidden;
margin: auto;
}
.more-content-modal.show {
display: flex;
justify-content: center;
align-items: center;
background: rgba(0, 0, 0, 0.5);
}
.more-content-modal.show .more-content-container {
opacity: 1;
transform: scale(1);
}
.modal-content {
height: calc(100% - 30px);
overflow-y: auto;
padding: 0 20px;
scroll-behavior: smooth;
scrollbar-width: thin;
scrollbar-color: #4a90e2 #f0f0f0;
}
/* 电脑端两栏布局 */
@media (min-width: 769px) {
.modal-content-container {
display: flex;
gap: 20px;
margin-bottom: 20px;
}
.modal-background-card {
flex: 2;
height: 180px;
display: flex;
align-items: center;
justify-content: center;
}
.modal-time-card {
flex: 1.5;
max-width: 200px;
height: 180px;
background: #4060ffa1;
color: white;
display: flex;
align-items: center;
justify-content: center;
border-radius: 10px;
padding: 15px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.time-info {
text-align: center;
color: white;
}
.current-time {
font-size: 24px;
font-weight: bold;
margin-bottom: 5px;
}
.current-date {
font-size: 16px;
margin-bottom: 10px;
}
.location {
font-size: 14px;
font-style: italic;
}
}
/* 手机端保持原样 */
@media (max-width: 768px) {
.modal-time-card {
display: none;
}
}
/* 调整弹窗内容的间距和布局 */
.modal-content section {
margin: 10px 0;
padding: 0;
}
.modal-content section:first-child {
margin-top: 0;
}
.modal-content section:last-child {
margin-bottom: 0;
}
/* 调整弹窗内footer样式 */
.modal-content footer {
margin-top: 10px;
padding: 8px 0;
border-top: 1px solid #eee;
}
/* 确保弹窗内的容器不会超出范围 */
.modal-content .container {
width: 100%;
padding: 0;
margin: 0;
}
/* 自定义滚动条样式(Webkit浏览器) */
.modal-content::-webkit-scrollbar {
width: 8px;
}
.modal-content::-webkit-scrollbar-track {
background: #f0f0f0;
border-radius: 4px;
}
.modal-content::-webkit-scrollbar-thumb {
background: #4a90e2;
border-radius: 4px;
}
.modal-content::-webkit-scrollbar-thumb:hover {
background: #357abd;
}
/* 弹窗背景图片卡片 */
.modal-background-card {
width: 100%;
height: 180px;
background-image: url('https://s21.ax1x.com/2025/06/05/pVPvkge.jpg');
background-size: cover;
background-position: center;
border-radius: 10px;
margin-bottom: 20px;
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
.hitokoto-text {
color: white;
text-align: center;
padding: 0 20px;
font-size: 1.1em;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
max-width: 90%;
}
@media (max-width: 768px) {
.modal-background-card {
height: 160px;
}
.hitokoto-text {
font-size: 1em;
}
}
/* 弹窗头部区域 */
.modal-header {
position: sticky;
top: 0;
background: white;
padding: 1px 0;
margin-bottom: 2px;
display: flex;
justify-content: flex-end;
z-index: 2001;
}
.modal-close {
position: relative;
width: 18px;
height: 18px;
cursor: pointer;
border: none;
background: none;
padding: 0;
transition: transform 0.3s ease;
}
.modal-close::before,
.modal-close::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 14px;
height: 2px;
background: #666;
transition: background 0.3s ease;
}
.modal-close::before {
transform: translate(-50%, -50%) rotate(45deg);
}
.modal-close::after {
transform: translate(-50%, -50%) rotate(-45deg);
}
.modal-close:hover {
transform: rotate(90deg);
}
.modal-close:hover::before,
.modal-close:hover::after {
background: #333;
}
.modal-content {
padding: 8px;
}
/* 显示弹窗时禁止body滚动 */
body.modal-open {
overflow: hidden;
}
/* 弹窗显示状态 */
.more-content-modal.show {
display: flex;
justify-content: center;
align-items: center;
}
@keyframes modalSlideIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* From Uiverse.io by vinodjangid07 - 新按钮样式 */
.button-container {
display: flex;
justify-content: center;
align-items: center;
margin: 30px auto; /* 使用auto实现更精确的水平居中 */
width: fit-content; /* 使容器宽度适应内容 */
padding: 0 20px; /* 添加内边距确保美观 */
}
.button {
min-width: fit-content;
width: auto;
height: auto;
margin: 0 auto;
padding: 8px 16px;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 10px;
background-color: white;
border-radius: 30px;
color: black;
font-weight: 600;
border: none;
position: relative;
cursor: pointer;
transition: all 0.2s ease;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.116);
}
.svgIcon {
height: 25px;
transition-duration: 1.5s;
}
.bell path {
fill: rgb(19, 19, 19);
}
.button:hover {
background-color: rgb(255, 255, 255);
transition-duration: .5s;
}
.button:active {
transform: scale(0.97);
transition-duration: .2s;
}
.button:hover .svgIcon {
transform: rotate(250deg);
transition-duration: 1.5s;
}
@media (max-width: 768px) {
.header {
padding: 60px 0;
}
.name {
font-size: 2em;
}
.skills-grid,
.projects-grid {
grid-template-columns: 1fr;
}
.contact-links {
justify-content: center;
gap: 15px;
padding: 0 10px;
}
.announcement {
max-width: calc(100% - 40px);
padding: 8px 16px;
margin: 0 auto;
}
.announcement p {
font-size: 15px;
line-height: 1.4;
}
.announcement-card {
width: fit-content;
min-width: 280px;
max-width: 95%;
}
.announcement-content {
padding: 20px 15px;
}
}
JS
javascript
// 分享功能
const shareButton = document.querySelector('.share-button');
const shareModal = document.querySelector('.share-modal');
const shareContent = document.querySelector('.share-content');
const copyLink = document.querySelector('.copy-link');
// 点击分享按钮显示弹窗
shareButton.addEventListener('click', () => {
shareModal.classList.add('active');
});
// 点击空白处关闭弹窗
shareModal.addEventListener('click', (e) => {
if (e.target === shareModal) {
shareModal.classList.remove('active');
}
});
// 复制链接功能
copyLink.addEventListener('click', () => {
const url = window.location.href;
navigator.clipboard.writeText(url).then(() => {
alert('链接已复制到剪贴板');
shareModal.classList.remove('active');
}).catch(err => {
console.error('复制失败:', err);
});
});
// 社交媒体分享
document.querySelectorAll('.share-option').forEach(option => {
option.addEventListener('click', () => {
const platform = option.getAttribute('data-platform');
const url = encodeURIComponent(window.location.href);
const title = encodeURIComponent(document.title);
let shareUrl = '';
switch(platform) {
case 'qq':
// 使用QQ的通用分享链接
shareUrl = `https://connect.qq.com/widget/shareqq/index.html?url=${url}&title=${title}&source=${encodeURIComponent(window.location.host)}`;
break;
case 'qzone':
shareUrl = `https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=${url}&title=${title}&site=${encodeURIComponent(window.location.host)}`;
break;
case 'wechat':
// 使用微信的通用分享链接
window.open(`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${url}`, '_blank');
return;
break;
case 'timeline':
// 微信朋友圈也使用二维码分享
window.open(`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${url}`, '_blank');
return;
break;
}
if (shareUrl) {
window.open(shareUrl, '_blank');
}
shareModal.classList.remove('active');
});
});
// 更新时间显示
function updateTime() {
if (window.innerWidth >= 769) { // 只在电脑端显示
const now = new Date();
const timeElement = document.querySelector('.current-time');
const dateElement = document.querySelector('.current-date');
const locationElement = document.querySelector('.location');
if (timeElement) {
timeElement.textContent = now.toLocaleTimeString();
}
if (dateElement) {
dateElement.textContent = now.toLocaleDateString();
}
if (locationElement) {
// 使用浏览器地理定位API获取精确位置
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
(position) => {
// 这里可以接入逆地理编码API获取具体县市名称
// 示例数据 - 实际应用中应该调用API获取真实位置
locationElement.textContent = '中国·北京市·海淀区';
},
(error) => {
// 定位失败时显示默认位置
locationElement.textContent = '中国·北京市';
}
);
} else {
// 浏览器不支持定位时显示默认位置
locationElement.textContent = '中国·北京市';
}
}
}
}
document.addEventListener('DOMContentLoaded', () => {
// 初始化时间显示并设置定时器
updateTime();
setInterval(updateTime, 1000);
// 更多内容弹窗控制
const exploreButton = document.querySelector('.button');
const moreContentModal = document.querySelector('.more-content-modal');
const modalClose = document.querySelector('.modal-close');
// 获取一言函数
async function fetchHitokoto() {
try {
const response = await fetch('https://v1.hitokoto.cn');
const data = await response.json();
const hitokotoElement = document.querySelector('.hitokoto-text');
if (hitokotoElement) {
hitokotoElement.textContent = data.hitokoto;
}
} catch (error) {
console.error('获取一言失败:', error);
}
}
// 打开弹窗
exploreButton.addEventListener('click', () => {
moreContentModal.classList.add('show');
document.body.classList.add('modal-open');
// 获取一言
fetchHitokoto();
// 滚动到弹窗内容顶部
const modalContent = document.querySelector('.modal-content');
if (modalContent) {
modalContent.scrollTop = 0;
}
});
// 关闭弹窗
modalClose.addEventListener('click', () => {
moreContentModal.classList.remove('show');
document.body.classList.remove('modal-open');
});
// 点击遮罩层关闭弹窗
moreContentModal.addEventListener('click', (e) => {
if (e.target === moreContentModal) {
moreContentModal.classList.remove('show');
document.body.classList.remove('modal-open');
}
});
// ESC键关闭弹窗
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && moreContentModal.classList.contains('show')) {
moreContentModal.classList.remove('show');
document.body.classList.remove('modal-open');
}
});
// 隐藏加载动画
const loadingOverlay = document.querySelector('.loading-overlay');
if (loadingOverlay) {
loadingOverlay.classList.add('hidden');
}
// 公告弹窗控制
const announcementPopup = document.querySelector('.announcement-popup');
const announcementClose = document.querySelector('.announcement-close');
// 点击关闭按钮隐藏弹窗
if (announcementClose && announcementPopup) {
announcementClose.addEventListener('click', () => {
announcementPopup.classList.add('hidden');
});
}
// 更新版权年份
const currentYear = new Date().getFullYear();
const copyrightElement = document.querySelector('footer p');
if (copyrightElement) {
copyrightElement.textContent = `© 2024-${currentYear} 成烁. All rights reserved.`;
}
// 计算网站运行时间
function calculateRuntime() {
const startTime = new Date('2025-02-06T09:43:00');
const currentTime = new Date();
// 确保时间差为正数
let timeDiff = currentTime - startTime;
if (timeDiff < 0) timeDiff = 0;
const days = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
const hours = Math.floor((timeDiff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((timeDiff % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((timeDiff % (1000 * 60)) / 1000);
const runtimeElement = document.getElementById('runtime');
if (runtimeElement) {
runtimeElement.textContent = `${days}天${hours}小时${minutes}分${seconds}秒`;
}
}
// 初始计算并每秒更新
calculateRuntime();
setInterval(calculateRuntime, 1000);
});