From 8e1bfb8af22ee2ed928a470cc044f22660cbd1d1 Mon Sep 17 00:00:00 2001 From: Dream Hunter Date: Sat, 5 Sep 2026 00:32:34 +0800 Subject: [PATCH] fix: load AdSense script without event attributes (#1136) --- CHANGELOG.md | 1 + CHANGELOG_EN.md | 1 + frontend/src/App.vue | 13 +++++++------ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6d59f2..3134126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ ### Bug Fixes +- fix: |Frontend| 修复 AdSense 脚本包含不受支持的 `data-onload` 和 `data-onerror` 属性 - fix: |Admin| 修复权限设置加载完成前短暂显示管理员密码输入框的问题 - fix: |Admin| 修复切换一级标签页时二级标签页偶发无选中项、内容不显示及指示条偏移的问题 - fix: |发信页面| 统一邮箱与名称字段顺序,并修复空正文输入框的光标与占位文字错位 diff --git a/CHANGELOG_EN.md b/CHANGELOG_EN.md index d2ef948..f761249 100644 --- a/CHANGELOG_EN.md +++ b/CHANGELOG_EN.md @@ -19,6 +19,7 @@ ### Bug Fixes +- fix: |Frontend| Remove unsupported `data-onload` and `data-onerror` attributes from the AdSense script - fix: |Admin| Avoid briefly showing the Admin password dialog before access settings finish loading - fix: |Admin| Fix secondary tabs occasionally losing their active item, hiding content, and leaving the indicator offset after switching primary tabs - fix: |Send Mail| Use a consistent address/name field order and align the empty content editor caret with its placeholder diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 7bc3adb..40759c8 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -3,7 +3,7 @@ import { darkTheme, } from 'naive-ui' import { computed, onMounted, watchEffect } from 'vue' -import { useScript } from '@unhead/vue' +import { useHead } from '@unhead/vue' import { useI18n } from 'vue-i18n' import { useGlobalState } from './store' import { useIsMobile } from './utils/composables' @@ -32,12 +32,13 @@ watchEffect(() => { document.documentElement.lang = isSupportedLocale(locale.value) ? locale.value : DEFAULT_LOCALE }) -// Load Google Ad script at top level (not inside onMounted) if (showAd.value) { - useScript({ - src: `https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${adClient}`, - async: true, - crossorigin: "anonymous", + useHead({ + script: [{ + src: `https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${adClient}`, + async: true, + crossorigin: 'anonymous', + }], }) }