refactor(index): 重构瞬间功能并优化页面结构
- 移除 iPhone 模拟器,改为直接使用 iframe 嵌入瞬间页面 - 更新瞬间链接为实际 URL,取消 javascript:void(0)- 调整 iframe 容器样式,设置初始隐藏状态- 重构 moments.js,简化代码结构,优化动画效果 - 更新 CSS 链接为相对路径,提高性能
This commit is contained in:
13736
css/style.css
13736
css/style.css
File diff suppressed because it is too large
Load Diff
21
index.html
21
index.html
@@ -13,7 +13,7 @@
|
|||||||
<meta name="keywords" content="Honesty,HeHouHui,HeHui,明厚">
|
<meta name="keywords" content="Honesty,HeHouHui,HeHui,明厚">
|
||||||
<meta name="author" content="HeHouHui">
|
<meta name="author" content="HeHouHui">
|
||||||
<title>Honesty的主页</title>
|
<title>Honesty的主页</title>
|
||||||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdmirror.com/gh/listener-He/Home/css/style.css?version=2">
|
<link rel="stylesheet" type="text/css" href="/css/style.css?version=2">
|
||||||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdmirror.com/gh/listener-He/Home/css/iconfont.css">
|
<link rel="stylesheet" type="text/css" href="https://cdn.jsdmirror.com/gh/listener-He/Home/css/iconfont.css">
|
||||||
<link rel="apple-touch-icon" href="https://blog-file.hehouhui.cn/bj/logo.png">
|
<link rel="apple-touch-icon" href="https://blog-file.hehouhui.cn/bj/logo.png">
|
||||||
<link rel="icon" href="https://cdn.jsdmirror.com/gh/listener-He/Home/favicon.ico?version=1">
|
<link rel="icon" href="https://cdn.jsdmirror.com/gh/listener-He/Home/favicon.ico?version=1">
|
||||||
@@ -121,7 +121,8 @@
|
|||||||
<a href="https://nav.hehouhui.cn/"><span>导航</span><i></i></a>
|
<a href="https://nav.hehouhui.cn/"><span>导航</span><i></i></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="navigation__item">
|
<li class="navigation__item">
|
||||||
<a href="javascript:void(0)" class="moments-link"><span>瞬间</span><i></i></a>
|
<!-- javascript:void(0) -->
|
||||||
|
<a href="https://moments.hehouhui.cn" class="moments-link"><span>瞬间</span><i></i></a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -194,17 +195,9 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<!-- 模拟iPhone 16容器 -->
|
<!-- iframe容器 -->
|
||||||
<div class="iphone-simulator" style="display: none">
|
<div id="moments-container" style="display: none;">
|
||||||
<div class="dynamic-island">
|
<iframe id="moment-frame" src="" width="100%" height="500px" frameborder="0"></iframe>
|
||||||
<p class="content"></p>
|
|
||||||
</div>
|
|
||||||
<div class="back-btn"></div>
|
|
||||||
<div class="browser-view">
|
|
||||||
<div class="close-btn"></div>
|
|
||||||
<div class="skeleton"></div>
|
|
||||||
<iframe id="moment-frame" width="100%" height="100%" frameborder="0"></iframe>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 遮罩层 -->
|
<!-- 遮罩层 -->
|
||||||
@@ -215,7 +208,7 @@
|
|||||||
<script type="text/javascript" src="https://cdn.jsdmirror.com/gh/listener-He/Home/js/fetch.min.js"></script>
|
<script type="text/javascript" src="https://cdn.jsdmirror.com/gh/listener-He/Home/js/fetch.min.js"></script>
|
||||||
<script type="text/javascript" src="https://cdn.jsdmirror.com/gh/listener-He/Home/js/main.js?version=2"></script>
|
<script type="text/javascript" src="https://cdn.jsdmirror.com/gh/listener-He/Home/js/main.js?version=2"></script>
|
||||||
<script type="text/javascript" src="https://cdn.jsdmirror.com/gh/listener-He/Home/js/bj.js"></script>
|
<script type="text/javascript" src="https://cdn.jsdmirror.com/gh/listener-He/Home/js/bj.js"></script>
|
||||||
<script type="text/javascript" src="https://cdn.jsdmirror.com/gh/listener-He/Home/js/moments.js"></script>
|
<!--<script type="text/javascript" src="https://cdn.jsdmirror.com/gh/listener-He/Home/js/moments.js"></script>-->
|
||||||
<script async src="https://analyse.hehouhui.cn/tracker.js" data-ackee-server="https://analyse.hehouhui.cn"
|
<script async src="https://analyse.hehouhui.cn/tracker.js" data-ackee-server="https://analyse.hehouhui.cn"
|
||||||
data-ackee-domain-id="7887135f-a413-46e2-a98c-52d4f18d9973"></script>
|
data-ackee-domain-id="7887135f-a413-46e2-a98c-52d4f18d9973"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -1,47 +1,33 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
const iframe = document.getElementById('moment-frame');
|
const iframe = document.getElementById('moment-frame');
|
||||||
function animateDynamicIsland(text = '正在加载...') {
|
const momentsContainer = document.getElementById('moments-container');
|
||||||
const island = document.querySelector('.dynamic-island');
|
|
||||||
const content = island.querySelector('.content');
|
|
||||||
|
|
||||||
content.textContent = text;
|
function animateIframe() {
|
||||||
island.classList.add('expand');
|
momentsContainer.style.display = 'block';
|
||||||
|
momentsContainer.classList.add('visible');
|
||||||
setTimeout(() => {
|
|
||||||
island.classList.remove('expand');
|
|
||||||
}, (iframe.src == null || iframe.src === '') ? 2000 : 250); // 2秒后收缩
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function openSimulator(url) {
|
function openMoments(url) {
|
||||||
const sim = document.querySelector('.iphone-simulator');
|
|
||||||
const overlay = document.querySelector('.overlay');
|
|
||||||
const skeleton = document.querySelector('.skeleton');
|
|
||||||
sim.style.display = 'block';
|
|
||||||
overlay.style.display = 'block';
|
|
||||||
if (iframe.src == null || iframe.src === '' || iframe.src !== url) {
|
if (iframe.src == null || iframe.src === '' || iframe.src !== url) {
|
||||||
const browserView = document.querySelector('.browser-view');
|
|
||||||
iframe.src = url;
|
iframe.src = url;
|
||||||
|
|
||||||
iframe.onload = () => {
|
iframe.onload = () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
skeleton.style.display = 'none';
|
animateIframe();
|
||||||
browserView.classList.add('loaded');
|
|
||||||
}, 300); // 延迟更自然
|
}, 300); // 延迟更自然
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
skeleton.style.display = 'none';
|
animateIframe();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 处理瞬间链接点击事件
|
// 处理瞬间链接点击事件
|
||||||
$('.moments-link').on('click', function (e) {
|
$('.moments-link').on('click', function (e) {
|
||||||
e.preventDefault(); // 阻止默认跳转
|
e.preventDefault(); // 阻止默认跳转
|
||||||
|
|
||||||
// 获取链接地址
|
// 获取链接地址
|
||||||
const url = "https://moments.hehouhui.cn";
|
const url = "https://moments.hehouhui.cn";
|
||||||
|
|
||||||
// 判断是否是移动端
|
// 判断是否是移动端
|
||||||
const isMobile = /iPhone|Android/i.test(navigator.userAgent);
|
const isMobile = /iPhone|Android/i.test(navigator.userAgent);
|
||||||
|
|
||||||
@@ -49,35 +35,24 @@ $(document).ready(function () {
|
|||||||
// 移动端:直接跳转
|
// 移动端:直接跳转
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
} else {
|
} else {
|
||||||
animateDynamicIsland('正在加载瞬间...');
|
// PC端:在iframe中显示
|
||||||
// PC端:在模拟器中显示
|
openMoments(url);
|
||||||
openSimulator(url);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 关闭按钮点击事件
|
// 关闭按钮点击事件
|
||||||
$('.close-btn').on('click', function () {
|
$('.close-btn').on('click', function () {
|
||||||
$('.iphone-simulator').hide();
|
momentsContainer.classList.remove('visible');
|
||||||
$('.overlay').hide();
|
setTimeout(() => {
|
||||||
$('.iphone-simulator').removeClass('visible');
|
momentsContainer.style.display = 'none';
|
||||||
|
}, 500); // 等待动画结束后隐藏
|
||||||
});
|
});
|
||||||
|
|
||||||
// 遮罩层点击事件 点击空白处关闭模拟器
|
// 遮罩层点击事件 点击空白处关闭模拟器
|
||||||
$('.overlay').on('click', function () {
|
$('.overlay').on('click', function () {
|
||||||
$(this).hide();
|
momentsContainer.classList.remove('visible');
|
||||||
$('.iphone-simulator').hide();
|
setTimeout(() => {
|
||||||
$('.iphone-simulator').removeClass('visible');
|
momentsContainer.style.display = 'none';
|
||||||
});
|
}, 500); // 等待动画结束后隐藏
|
||||||
|
|
||||||
document.querySelector('.back-btn').addEventListener('click', () => {
|
|
||||||
try {
|
|
||||||
// 安全地尝试让 iframe 内部回退
|
|
||||||
if (iframe.contentWindow && iframe.contentWindow.history.length > 1) {
|
|
||||||
iframe.contentWindow.history.back();
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
// 跨域或权限问题
|
|
||||||
console.error('无法回退:', e);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user