Revert "fix: 修复移动端深色模式和毛玻璃效果兼容性问题"

This reverts commit 9996ebf00e.
This commit is contained in:
2026-01-15 17:13:05 +08:00
parent 9996ebf00e
commit aef6ef6790
2 changed files with 25 additions and 66 deletions

View File

@@ -289,81 +289,40 @@
<?php wp_head(); ?> <?php wp_head(); ?>
<!-- 移动端兼容性修复 --> <!-- 移动端资源加载修复 - 确保 CSS 完全应用 -->
<script> <script>
(function() { (function() {
var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); // 检测移动端并强制重新计算样式
var html = document.documentElement; if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
// 确保 CSS 已加载
var checkCSS = function() {
var testEl = document.createElement('div');
testEl.className = 'container';
testEl.style.cssText = 'position:absolute;visibility:hidden;';
document.body.appendChild(testEl);
var computed = window.getComputedStyle(testEl);
var isLoaded = computed.width !== 'auto' && computed.width !== '';
document.body.removeChild(testEl);
return isLoaded;
};
// 检测 backdrop-filter 支持 // 如果 CSS 未完全加载,强制重新加载
var supportsBackdrop = CSS.supports && ( document.addEventListener('DOMContentLoaded', function() {
CSS.supports('backdrop-filter', 'blur(1px)') || if (!checkCSS()) {
CSS.supports('-webkit-backdrop-filter', 'blur(1px)') // 触发重排以应用样式
);
if (!supportsBackdrop) {
html.classList.add('no-backdrop-filter');
}
if (isMobile) {
html.classList.add('is-mobile-device');
// 监听深色模式切换,强制刷新样式
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.attributeName === 'class') {
// 强制重新计算所有样式
document.body.style.display = 'none'; document.body.style.display = 'none';
void document.body.offsetHeight; document.body.offsetHeight; // 强制重排
document.body.style.display = ''; document.body.style.display = '';
} }
}); });
});
observer.observe(html, { attributes: true, attributeFilter: ['class'] });
} }
})(); })();
// 用户角色检测 // 用户角色检测 - 传递给前端JavaScript
window.argonUserRole = '<?php echo current_user_can('administrator') ? 'administrator' : (is_user_logged_in() ? 'user' : 'guest'); ?>'; window.argonUserRole = '<?php echo current_user_can('administrator') ? 'administrator' : (is_user_logged_in() ? 'user' : 'guest'); ?>';
</script> </script>
<!-- 移动端降级样式 --> <!-- Argon 修复补丁 - 必须在 wp_head() 之后立即执行 -->
<style>
/* 不支持 backdrop-filter 时的降级方案 */
html.no-backdrop-filter .card.bg-white,
html.no-backdrop-filter article.post.card,
html.no-backdrop-filter #comments.card,
html.no-backdrop-filter #post_comment.card {
background-color: rgba(255, 255, 255, 0.95) !important;
}
html.no-backdrop-filter.darkmode .card.bg-white,
html.no-backdrop-filter.darkmode article.post.card,
html.no-backdrop-filter.darkmode #comments.card,
html.no-backdrop-filter.darkmode #post_comment.card {
background-color: rgba(50, 50, 50, 0.95) !important;
}
/* 移动端深色模式文字颜色强制修复 */
html.is-mobile-device.darkmode body,
html.is-mobile-device.darkmode .post-content,
html.is-mobile-device.darkmode .card-body,
html.is-mobile-device.darkmode p,
html.is-mobile-device.darkmode span,
html.is-mobile-device.darkmode li {
color: #eee !important;
}
html.is-mobile-device:not(.darkmode) body,
html.is-mobile-device:not(.darkmode) .post-content,
html.is-mobile-device:not(.darkmode) .card-body,
html.is-mobile-device:not(.darkmode) p,
html.is-mobile-device:not(.darkmode) span:not(.badge),
html.is-mobile-device:not(.darkmode) li {
color: #525f7f !important;
}
</style>
<!-- Argon 修复补丁 -->
<script src="<?php echo get_template_directory_uri(); ?>/assets/js/argon.min.js?ver=<?php echo $GLOBALS['theme_version']; ?>"></script> <script src="<?php echo get_template_directory_uri(); ?>/assets/js/argon.min.js?ver=<?php echo $GLOBALS['theme_version']; ?>"></script>
<?php $GLOBALS['wp_path'] = get_option('argon_wp_path') == '' ? '/' : get_option('argon_wp_path'); ?> <?php $GLOBALS['wp_path'] = get_option('argon_wp_path') == '' ? '/' : get_option('argon_wp_path'); ?>

View File

@@ -1,4 +1,4 @@
{ {
"branch": "master", "branch": "master",
"commit": "14edc70" "commit": "5ecbacb"
} }