Files
home/js/moments.js
hehh c635de68fb refactor(script): 重构脚本加载和错误处理
- 添加 moments.js 新脚本文件,分离瞬间功能逻辑
- 为百度统计和 Google Analytics 添加错误处理
- 更新 main.js,移除瞬间功能相关代码
2025-07-17 00:35:01 +08:00

36 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

$(document).ready(function () {
// 处理瞬间链接点击事件
$('.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', '');
});
});