diff --git a/index.html b/index.html index 2f3eb22..1634793 100644 --- a/index.html +++ b/index.html @@ -214,26 +214,35 @@ + diff --git a/js/main.js b/js/main.js index efafa29..5425f25 100644 --- a/js/main.js +++ b/js/main.js @@ -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', ''); -}); diff --git a/js/moments.js b/js/moments.js new file mode 100644 index 0000000..687990a --- /dev/null +++ b/js/moments.js @@ -0,0 +1,36 @@ +$(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', ''); + }); +}); \ No newline at end of file