From f7ca23eb90a88fcf2225734e249c83443b13f5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E5=8F=89=E6=A0=91=E6=A0=91?= Date: Fri, 5 Dec 2025 00:42:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(umami):=20=E8=BF=81=E7=A7=BBumami=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=88=B0=E8=87=AA=E5=BB=BA=E5=AE=9E=E4=BE=8B=E5=B9=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新所有umami API调用路径,移除`/analytics/us`前缀 将统计链接和配置从云服务迁移到自建实例 在todo列表中标记umami迁移任务为已完成 启用自建umami统计脚本并禁用云服务脚本 --- public/js/umami-share.js | 2 +- src/components/PostCard.astro | 2 +- src/components/PostMeta.astro | 2 +- src/components/widget/Profile.astro | 2 +- src/config.ts | 6 +++--- src/data/todo.ts | 2 +- src/layouts/Layout.astro | 8 ++++---- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/public/js/umami-share.js b/public/js/umami-share.js index 0078f50d3..5aefc823c 100644 --- a/public/js/umami-share.js +++ b/public/js/umami-share.js @@ -14,7 +14,7 @@ localStorage.removeItem(cacheKey); } } - const res = await fetch(`${baseUrl}/analytics/us/api/share/${shareId}`); + const res = await fetch(`${baseUrl}/api/share/${shareId}`); if (!res.ok) { throw new Error('获取 Umami 分享信息失败'); } diff --git a/src/components/PostCard.astro b/src/components/PostCard.astro index 99f6475c2..ada4a6fdc 100644 --- a/src/components/PostCard.astro +++ b/src/components/PostCard.astro @@ -132,7 +132,7 @@ const { remarkPluginFrontmatter } = await entry.render(); // 第二步:获取统计数据 const currentTimestamp = Date.now(); - const statsUrl = `${umamiConfig.baseUrl}/analytics/us/api/websites/${websiteId}/stats?startAt=0&endAt=${currentTimestamp}&unit=hour&timezone=${encodeURIComponent(umamiConfig.timezone)}&path=eq.%2Fposts%2F${slug}%2F&compare=false`; + const statsUrl = `${umamiConfig.baseUrl}/api/websites/${websiteId}/stats?startAt=0&endAt=${currentTimestamp}&unit=hour&timezone=${encodeURIComponent(umamiConfig.timezone)}&path=eq.%2Fposts%2F${slug}%2F&compare=false`; const statsResponse = await fetch(statsUrl, { headers: { diff --git a/src/components/PostMeta.astro b/src/components/PostMeta.astro index a919cafca..560b95f33 100644 --- a/src/components/PostMeta.astro +++ b/src/components/PostMeta.astro @@ -99,7 +99,7 @@ const className = Astro.props.class; // 第二步:获取统计数据 const currentTimestamp = Date.now(); - const statsUrl = `${umamiConfig.baseUrl}/analytics/us/api/websites/${websiteId}/stats?startAt=0&endAt=${currentTimestamp}&unit=hour&timezone=${encodeURIComponent(umamiConfig.timezone)}&path=eq.%2Fposts%2F${slug}%2F&compare=false`; + const statsUrl = `${umamiConfig.baseUrl}/api/websites/${websiteId}/stats?startAt=0&endAt=${currentTimestamp}&unit=hour&timezone=${encodeURIComponent(umamiConfig.timezone)}&path=eq.%2Fposts%2F${slug}%2F&compare=false`; const statsResponse = await fetch(statsUrl, { headers: { diff --git a/src/components/widget/Profile.astro b/src/components/widget/Profile.astro index b96af8ec1..d675f8575 100644 --- a/src/components/widget/Profile.astro +++ b/src/components/widget/Profile.astro @@ -68,7 +68,7 @@ const config = profileConfig; // 第二步:获取全站统计数据(不指定url参数获取全站数据) const currentTimestamp = Date.now(); - const statsUrl = `${umamiConfig.baseUrl}/analytics/us/api/websites/${websiteId}/stats?startAt=0&endAt=${currentTimestamp}&unit=hour&timezone=${encodeURIComponent(umamiConfig.timezone)}&compare=false`; + const statsUrl = `${umamiConfig.baseUrl}/api/websites/${websiteId}/stats?startAt=0&endAt=${currentTimestamp}&unit=hour&timezone=${encodeURIComponent(umamiConfig.timezone)}&compare=false`; const statsResponse = await fetch(statsUrl, { headers: { diff --git a/src/config.ts b/src/config.ts index a5db008f5..56aac1f2e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -82,7 +82,7 @@ export const navBarConfig: NavBarConfig = { }, { name: "统计", - url: "https://cloud.umami.is/share/hN3l7PGcxsUCBHfU", // Internal links should not include the base path, as it is automatically added + url: "https://umami.2b2x.cn/share/CdkXbGgZr6ECKOyK", // Internal links should not include the base path, as it is automatically added external: true, // Show an external link icon and will open in a new tab }, { @@ -125,8 +125,8 @@ export const imageFallbackConfig: ImageFallbackConfig = { export const umamiConfig: UmamiConfig = { enable: true, - baseUrl: "https://cloud.umami.is", - shareId: "hN3l7PGcxsUCBHfU", + baseUrl: "https://umami.2b2x.cn", + shareId: "CdkXbGgZr6ECKOyK", timezone: "Asia/Shanghai", }; diff --git a/src/data/todo.ts b/src/data/todo.ts index f7ade2ab1..42d700ce6 100644 --- a/src/data/todo.ts +++ b/src/data/todo.ts @@ -11,7 +11,7 @@ export const todoConfig: TodoConfig = { { content: "做视频:如何使用OBS优雅的录视频", completed: false }, { content: "做视频:博客时光流逝卡片", completed: false }, { content: "做视频:博客访客统计新UI", completed: false }, - { content: "自建Umami并从云迁移到自建", completed: false }, + { content: "自建Umami并从云迁移到自建", completed: true }, { content: "更改文章底下的链接,用正则删去查询(?=xxx)", completed: false }, { content: "做视频:anuneko.com米哈游AI上手体验", completed: true }, { content: "完善Bot插件:anuneko.com米哈游AI聊天机器人(支持pick)", completed: true }, diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index fc10c09bb..122f0063d 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -241,10 +241,10 @@ const bannerOffset = - {/* - */} - - + + + {/* + */}