diff --git a/src/components/StatsCorner.vue b/src/components/StatsCorner.vue
index a462b8a..536485f 100644
--- a/src/components/StatsCorner.vue
+++ b/src/components/StatsCorner.vue
@@ -27,12 +27,6 @@
-
-
statsStore.serviceStatuses.get('api'))
@@ -100,48 +92,28 @@ const statusIconClass = computed(() => {
return 'text-red-500'
})
-// 检查不蒜子数据是否加载
-function checkBusuanziData() {
- const pvElement = document.getElementById('busuanzi_value_site_pv')
- const uvElement = document.getElementById('busuanzi_value_site_uv')
-
- if (pvElement && uvElement) {
- const pvValue = parseInt(pvElement.textContent || '0', 10)
- const uvValue = parseInt(uvElement.textContent || '0', 10)
+// 使用新的 busuanzi API 获取统计
+async function fetchBusuanziStats() {
+ try {
+ const res = await fetch('https://bsz.saop.cc/api', {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'x-bsz-referer': window.location.href },
+ })
- if (pvValue > 0 && uvValue > 0) {
- // 更新 statsStore
- statsStore.updateVisitorStats(pvValue, uvValue)
+ if (!res.ok) {return}
+
+ const { success, data } = await res.json()
+
+ if (success && data) {
+ statsStore.updateVisitorStats(data.site_pv, data.site_uv)
showStats.value = true
-
- if (checkInterval !== null) {
- clearInterval(checkInterval)
- checkInterval = null
- }
-
- if (observer) {
- observer.disconnect()
- observer = null
- }
}
+ } catch (error) {
+ console.warn('[Busuanzi] Failed to fetch stats:', error)
}
}
-// 使用 MutationObserver 监听不蒜子元素的变化
-function setupObserver() {
- const pvElement = document.getElementById('busuanzi_value_site_pv')
- const uvElement = document.getElementById('busuanzi_value_site_uv')
-
- if (!pvElement || !uvElement) {return}
-
- observer = new MutationObserver(() => {
- checkBusuanziData()
- })
-
- observer.observe(pvElement, { childList: true, characterData: true, subtree: true })
- observer.observe(uvElement, { childList: true, characterData: true, subtree: true })
-}
-
// 监听 visitorStats 变化,自动显示统计
watch(() => statsStore.visitorStats.pv, (pv) => {
if (pv > 0) {
@@ -153,39 +125,13 @@ onMounted(() => {
// 使用 statsStore 进行状态检测
statsStore.startStatusCheck(30000)
- // 不蒜子统计
- setupObserver()
- checkBusuanziData()
-
- let attempts = 0
- const maxAttempts = 40
-
- checkInterval = window.setInterval(() => {
- attempts++
- checkBusuanziData()
-
- if (showStats.value || attempts >= maxAttempts) {
- if (checkInterval !== null) {
- clearInterval(checkInterval)
- checkInterval = null
- }
- }
- }, 500)
+ // 获取不蒜子统计
+ void fetchBusuanziStats()
})
onUnmounted(() => {
// 停止状态检测
statsStore.stopStatusCheck()
-
- if (checkInterval !== null) {
- clearInterval(checkInterval)
- checkInterval = null
- }
-
- if (observer) {
- observer.disconnect()
- observer = null
- }
})
diff --git a/src/components/UpdateToast.vue b/src/components/UpdateToast.vue
index 7f7b85e..3bdfdf6 100644
--- a/src/components/UpdateToast.vue
+++ b/src/components/UpdateToast.vue
@@ -13,49 +13,24 @@
>
-
+
发现新版本
-
-
- 正在更新...
-
-
- {{ countdown }} 秒后自动更新...
-
-
- 准备更新...
-
-
+
正在更新...
-
-
-
diff --git a/vite.config.ts b/vite.config.ts
index 94ae073..16682dd 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -28,7 +28,7 @@ export default defineConfig({
tailwindcss(),
// PWA 配置
VitePWA({
- registerType: 'prompt', // 提示用户更新
+ registerType: 'autoUpdate', // 收到新版本立即更新
includeAssets: ['logo.svg', 'robots.txt'],
manifest: {
name: 'SearchGal - Galgame 聚合搜索',