refactor: 移除域名列表接口并统一为站点列表接口

- 移除独立的 `/admin/stats/domains` 接口及相关文档
- 将原 `fetchDomainList` 重命名为 `fetchSiteList`,统一站点获取逻辑
- 优化后台界面中的站点显示,为空站点显示“默认站点 (Default)”
- 移除设置页面中的“站点管理”选项卡,简化后台功能结构
- 保持 `/admin/stats/sites` 接口功能不变,作为统一的站点数据源
This commit is contained in:
anghunk
2026-02-09 15:44:54 +08:00
parent 098d668a15
commit 3d2f1b0620
7 changed files with 55 additions and 106 deletions

View File

@@ -5,7 +5,6 @@ export const getSites = async (c: Context<{ Bindings: Bindings }>) => {
try {
const sites = new Set<string>();
// 1. Get sites from Comment
const { results: commentRows } = await c.env.CWD_DB.prepare(
'SELECT DISTINCT site_id FROM Comment'
).all<{ site_id: string }>();
@@ -16,7 +15,6 @@ export const getSites = async (c: Context<{ Bindings: Bindings }>) => {
}
}
// 2. Get sites from page_stats
const { results: pageRows } = await c.env.CWD_DB.prepare(
'SELECT DISTINCT site_id FROM page_stats'
).all<{ site_id: string }>();
@@ -27,16 +25,15 @@ export const getSites = async (c: Context<{ Bindings: Bindings }>) => {
}
}
// 3. Get sites from page_visit_daily
const { results: dailyRows } = await c.env.CWD_DB.prepare(
'SELECT DISTINCT site_id FROM page_visit_daily'
).all<{ site_id: string }>();
const { results: dailyRows } = await c.env.CWD_DB.prepare(
'SELECT DISTINCT site_id FROM page_visit_daily'
).all<{ site_id: string }>();
for (const row of dailyRows) {
if (row.site_id !== undefined && row.site_id !== null) {
sites.add(row.site_id);
}
}
for (const row of dailyRows) {
if (row.site_id !== undefined && row.site_id !== null) {
sites.add(row.site_id);
}
}
const list = Array.from(sites);
list.sort();

View File

@@ -296,10 +296,9 @@ app.get('/admin/export/backup', exportBackup);
app.post('/admin/import/backup', importBackup);
app.put('/admin/comments/status', updateStatus);
app.put('/admin/comments/update', updateComment);
app.get('/admin/stats/comments', getStats);
app.get('/admin/stats/sites', getSites);
app.get('/admin/analytics/overview', getVisitOverview);
app.get('/admin/analytics/pages', getVisitPages);
app.get('/admin/stats/sites', getSites);
app.get('/admin/likes/list', listLikes);
app.get('/admin/likes/stats', getLikeStats);
app.get('/admin/settings/features', getFeatureSettings);