refactor: 移除标签相关功能及优化统计代码

- 删除标签相关的组件、页面和工具函数
- 简化文章卡片和元数据组件,移除标签显示
- 优化Umami统计代码,提取公共函数
- 删除未使用的组件和布局
This commit is contained in:
二叉树树
2025-12-15 11:17:30 +08:00
parent 98a0e93feb
commit ac2bcf7521
16 changed files with 64 additions and 497 deletions

View File

@@ -44,4 +44,48 @@
localStorage.removeItem(cacheKey);
delete global.__umamiSharePromise;
};
/**
* 获取 Umami 统计数据
* 自动处理 token 获取和过期重试
* @param {string} baseUrl
* @param {string} shareId
* @param {object} queryParams
* @returns {Promise<any>}
*/
global.fetchUmamiStats = async function (baseUrl, shareId, queryParams) {
async function doFetch(isRetry = false) {
const { websiteId, token } = await global.getUmamiShareData(baseUrl, shareId);
const currentTimestamp = Date.now();
const params = new URLSearchParams({
startAt: 0,
endAt: currentTimestamp,
unit: 'hour',
timezone: queryParams.timezone || 'Asia/Shanghai',
compare: false,
...queryParams
});
const statsUrl = `${baseUrl}/api/websites/${websiteId}/stats?${params.toString()}`;
const res = await fetch(statsUrl, {
headers: {
'x-umami-share-token': token
}
});
if (!res.ok) {
if (res.status === 401 && !isRetry) {
global.clearUmamiShareCache();
return doFetch(true);
}
throw new Error('获取统计数据失败');
}
return await res.json();
}
return doFetch();
};
})(window);