From 0a7dca07ed51974ff2ba654ec4a2c6adbc73a3d5 Mon Sep 17 00:00:00 2001 From: anghunk Date: Thu, 22 Jan 2026 10:44:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=95=B0=E6=8D=AE=E5=BA=93):=20=E5=B0=86?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=88=B3=E5=AD=97=E6=AE=B5=E4=BB=8ETEXT?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E6=94=B9=E4=B8=BAINTEGER=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改page_visit_daily表的created_at和updated_at字段类型,从TEXT改为INTEGER 同时更新相关插入和更新操作,使用时间戳而非ISO格式字符串 --- cwd-api/src/api/admin/visitAnalytics.ts | 2 +- cwd-api/src/api/public/trackVisit.ts | 6 +++--- docs/api/public.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cwd-api/src/api/admin/visitAnalytics.ts b/cwd-api/src/api/admin/visitAnalytics.ts index 8290f73..a1e4a80 100644 --- a/cwd-api/src/api/admin/visitAnalytics.ts +++ b/cwd-api/src/api/admin/visitAnalytics.ts @@ -52,7 +52,7 @@ export const getVisitOverview = async ( ).run(); await c.env.CWD_DB.prepare( - 'CREATE TABLE IF NOT EXISTS page_visit_daily (id INTEGER PRIMARY KEY AUTOINCREMENT, date TEXT NOT NULL, domain TEXT, count INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL, updated_at TEXT NOT NULL)' + 'CREATE TABLE IF NOT EXISTS page_visit_daily (id INTEGER PRIMARY KEY AUTOINCREMENT, date TEXT NOT NULL, domain TEXT, count INTEGER NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL)' ).run(); const { results } = await c.env.CWD_DB.prepare( diff --git a/cwd-api/src/api/public/trackVisit.ts b/cwd-api/src/api/public/trackVisit.ts index 212407d..7da99ba 100644 --- a/cwd-api/src/api/public/trackVisit.ts +++ b/cwd-api/src/api/public/trackVisit.ts @@ -43,7 +43,7 @@ export const trackVisit = async (c: Context<{ Bindings: Bindings }>) => { ).run(); await c.env.CWD_DB.prepare( - 'CREATE TABLE IF NOT EXISTS page_visit_daily (id INTEGER PRIMARY KEY AUTOINCREMENT, date TEXT NOT NULL, domain TEXT, count INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL, updated_at TEXT NOT NULL)' + 'CREATE TABLE IF NOT EXISTS page_visit_daily (id INTEGER PRIMARY KEY AUTOINCREMENT, date TEXT NOT NULL, domain TEXT, count INTEGER NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL)' ).run(); const nowDate = new Date(); @@ -117,14 +117,14 @@ export const trackVisit = async (c: Context<{ Bindings: Bindings }>) => { await c.env.CWD_DB.prepare( 'INSERT INTO page_visit_daily (date, domain, count, created_at, updated_at) VALUES (?, ?, ?, ?, ?)' ) - .bind(today, domain, 1, nowIso, nowIso) + .bind(today, domain, 1, nowTs, nowTs) .run(); } else { const newCount = (dailyRow.count || 0) + 1; await c.env.CWD_DB.prepare( 'UPDATE page_visit_daily SET count = ?, updated_at = ? WHERE id = ?' ) - .bind(newCount, nowIso, dailyRow.id) + .bind(newCount, nowTs, dailyRow.id) .run(); } diff --git a/docs/api/public.md b/docs/api/public.md index 9a70b7a..fa50c4a 100644 --- a/docs/api/public.md +++ b/docs/api/public.md @@ -1,4 +1,4 @@ -# 公开 API +# 公开 API 相关 无需认证即可访问的公开接口,包括评论获取、评论提交、配置获取和身份验证。