refactor(script): 重构脚本加载和错误处理

- 添加 moments.js 新脚本文件,分离瞬间功能逻辑
- 为百度统计和 Google Analytics 添加错误处理
- 更新 main.js,移除瞬间功能相关代码
This commit is contained in:
hehh
2025-07-17 00:35:01 +08:00
parent 95c5fc25e9
commit c635de68fb
3 changed files with 54 additions and 42 deletions

View File

@@ -89,37 +89,4 @@ $('.btn-mobile-menu__icon').click(function () {
$('.btn-mobile-menu__icon').toggleClass('social iconfont icon-list social iconfont icon-ngleup animated fadeIn');
});
// 处理瞬间链接点击事件
$('.moments-link').on('click', function (e) {
e.preventDefault(); // 阻止默认跳转
// 获取链接地址
var url = "https://moments.hehouhui.cn";
console.log("当前用户UA-", navigator.userAgent)
// 判断是否是移动端
var isMobile = /iPhone|Android/i.test(navigator.userAgent);
if (isMobile) {
// 移动端:直接跳转
window.location.href = url;
} else {
// PC端在模拟器中显示
$('#moment-frame').attr('src', url);
$('.iphone-simulator').show();
$('.overlay').show();
}
});
// 关闭按钮点击事件
$('.close-btn').on('click', function () {
$('.iphone-simulator').hide();
$('.overlay').hide();
$('#moment-frame').attr('src', ''); // 清空iframe内容
});
// 遮罩层点击事件
$('.overlay').on('click', function () {
$(this).hide();
$('.iphone-simulator').hide();
$('#moment-frame').attr('src', '');
});