feat(iconfont): 新增朋友图标并优化瞬间功能
- 在 iconfont.css 中添加了新的朋友图标 (\e84d) -优化了瞬间功能的加载和显示逻辑 - 更新了 CDN链接为更快的镜像源 - 修复了一些小的前端问题,如百度统计和 Google Analytics 的加载顺序
This commit is contained in:
@@ -1,11 +1,41 @@
|
||||
$(document).ready(function () {
|
||||
function animateDynamicIsland(text = '正在加载...') {
|
||||
const island = document.querySelector('.dynamic-island');
|
||||
const content = island.querySelector('.content');
|
||||
|
||||
content.textContent = text;
|
||||
island.classList.add('expand');
|
||||
|
||||
setTimeout(() => {
|
||||
island.classList.remove('expand');
|
||||
}, 2000); // 2秒后收缩
|
||||
}
|
||||
|
||||
function openSimulator(url) {
|
||||
const sim = document.querySelector('.iphone-simulator');
|
||||
const iframe = document.getElementById('moment-frame');
|
||||
const skeleton = document.querySelector('.skeleton');
|
||||
const browserView = document.querySelector('.browser-view');
|
||||
|
||||
sim.style.display = 'block';
|
||||
document.querySelector('.overlay').style.display = 'block';
|
||||
|
||||
iframe.src = url;
|
||||
|
||||
iframe.onload = () => {
|
||||
setTimeout(() => {
|
||||
skeleton.style.display = 'none';
|
||||
browserView.classList.add('loaded');
|
||||
}, 300); // 延迟更自然
|
||||
};
|
||||
}
|
||||
|
||||
// 处理瞬间链接点击事件
|
||||
$('.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);
|
||||
|
||||
@@ -13,24 +43,38 @@ $(document).ready(function () {
|
||||
// 移动端:直接跳转
|
||||
window.location.href = url;
|
||||
} else {
|
||||
animateDynamicIsland('正在加载瞬间...');
|
||||
// PC端:在模拟器中显示
|
||||
$('#moment-frame').attr('src', url);
|
||||
$('.iphone-simulator').show();
|
||||
$('.overlay').show();
|
||||
openSimulator(url);
|
||||
}
|
||||
});
|
||||
|
||||
// 关闭按钮点击事件
|
||||
// 关闭按钮点击事件
|
||||
$('.close-btn').on('click', function () {
|
||||
$('.iphone-simulator').hide();
|
||||
$('.overlay').hide();
|
||||
$('.iphone-simulator').removeClass('visible');
|
||||
$('#moment-frame').attr('src', ''); // 清空iframe内容
|
||||
});
|
||||
|
||||
// 遮罩层点击事件
|
||||
// 遮罩层点击事件 点击空白处关闭模拟器
|
||||
$('.overlay').on('click', function () {
|
||||
$(this).hide();
|
||||
$('.iphone-simulator').hide();
|
||||
$('.iphone-simulator').removeClass('visible');
|
||||
$('#moment-frame').attr('src', '');
|
||||
});
|
||||
|
||||
const iframe = document.getElementById('moment-frame');
|
||||
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