From fa227600fec15d5e302aa60c8645e7d461a40b86 Mon Sep 17 00:00:00 2001 From: butubb <1422726308@qq.com> Date: Thu, 8 Oct 2026 07:52:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(creator):=20=E6=9D=83=E9=99=90=E5=BC=80?= =?UTF-8?q?=E9=80=9A=E5=90=8E=E7=9A=84=E7=8A=B6=E6=80=81=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=20+=20=E5=90=8C=E6=AD=A5=E8=8C=83=E5=9B=B4=E5=8F=AF=E9=80=89?= =?UTF-8?q?=E5=8F=AF=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 权限显示:实测今天 display/status 已变成 1,但 tip 是「数据正在更新中,请耐心等待」, 作品仍是 0 条。原逻辑只在未开通时显示提示条,于是会一边写着「数据已开通」一边列不出 作品,自相矛盾。现在只要后台有话要说就显示,并按状态区分措辞。 - 同步范围:原本写死 90 天,界面上既看不见也改不了。现在可选 7/30/90/180/365/730 天, 与后端校验上限一致。 - 新增 creator_account.last_sync_days,记录上次实际使用的范围 —— 否则界面只能说 「同步过了」,说不清覆盖的是哪一段。选择器也会对齐到它,避免上次同步 1 年、这次 点一下悄悄缩回 90 天。 --- api/creator/models.py | 3 + api/creator/service.py | 3 + .../src/components/creator/OperationView.tsx | 82 ++++++++++++++++--- webui/src/types/creator.ts | 2 + 4 files changed, 79 insertions(+), 11 deletions(-) diff --git a/api/creator/models.py b/api/creator/models.py index d131d7e..f8ab1cb 100644 --- a/api/creator/models.py +++ b/api/creator/models.py @@ -73,6 +73,9 @@ class CreatorAccount(MonitorBase): last_checked_at: Mapped[Optional[int]] = mapped_column(BigInteger) last_synced_at: Mapped[Optional[int]] = mapped_column(BigInteger) + # 上次同步用的时间范围(天,按发布时间)。当前展示的数据就是这个范围的产物 —— + # 不记下来的话,界面只能说明"同步过了",说不清是哪一段。 + last_sync_days: Mapped[int] = mapped_column(Integer, nullable=False, default=0) last_error: Mapped[Optional[str]] = mapped_column(Text) created_at: Mapped[int] = mapped_column(BigInteger, nullable=False) diff --git a/api/creator/service.py b/api/creator/service.py index 06e7a92..caa7e54 100644 --- a/api/creator/service.py +++ b/api/creator/service.py @@ -64,6 +64,7 @@ def _account_dict(account: CreatorAccount, note_count: int = 0) -> Dict[str, Any "permission_tip": account.permission_tip, "last_checked_at": account.last_checked_at, "last_synced_at": account.last_synced_at, + "last_sync_days": account.last_sync_days, "last_error": account.last_error, "has_cookie": bool(account.cookie), "created_at": account.created_at, @@ -344,6 +345,7 @@ async def sync_account( ) account.last_synced_at = now + account.last_sync_days = days account.last_error = None account.updated_at = now await refresh_permission(session, account) @@ -352,6 +354,7 @@ async def sync_account( return { "account_id": account_id, "fetched": len(collected), + "days": days, "permission_status": account.permission_status, "permission_tip": account.permission_tip, } diff --git a/webui/src/components/creator/OperationView.tsx b/webui/src/components/creator/OperationView.tsx index 7a87ba8..d7127fc 100644 --- a/webui/src/components/creator/OperationView.tsx +++ b/webui/src/components/creator/OperationView.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { useEffect, useState } from 'react' import { AlertTriangle, Briefcase, @@ -11,6 +11,13 @@ import { import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from '@/components/ui/select' import { useCheckCreatorAccount, useCreatorAccount, @@ -33,6 +40,17 @@ const PERMISSION_LABEL: Record = [ { key: 'exposure', label: '曝光' }, { key: 'views', label: '观看' }, @@ -112,6 +130,16 @@ function AccountPanel({ accountId }: { accountId: number }) { const sync = useSyncCreatorAccount() const check = useCheckCreatorAccount() const remove = useDeleteCreatorAccount() + // 拉取范围是**同步参数**,不是展示筛选:数据按这个范围取回来存库。 + // 默认 90 天,与后端的默认值一致。 + const [days, setDays] = useState('90') + + // 选择器对齐到上次实际用的范围。不对齐的话,上次同步了 1 年、这次点同步会悄悄 + // 缩回 90 天,而界面上没有任何迹象。 + const lastDays = data?.account.last_sync_days ?? 0 + useEffect(() => { + if (lastDays > 0) setDays(String(lastDays)) + }, [lastDays]) if (isLoading || !data) { return

加载中…

@@ -139,6 +167,9 @@ function AccountPanel({ accountId }: { accountId: number }) { 上次同步 {account.last_synced_at ? formatRelative(account.last_synced_at) : '从未'} + {/* 当前列出的作品就是上一次同步范围里的产物,所以要说清是哪一段 —— + 否则只看"同步过了"分不清覆盖了多少。 */} + {account.last_sync_days > 0 && ` · 覆盖近 ${account.last_sync_days} 天发布的`}
@@ -151,7 +182,23 @@ function AccountPanel({ accountId }: { accountId: number }) { 检测 - @@ -162,18 +209,31 @@ function AccountPanel({ accountId }: { accountId: number }) {
- {/* 权限状态必须显眼:它解释了"为什么没有数据"。后台的原话照抄,不改写。 */} - {account.permission_status !== 'active' && ( -
- + {/* 只要后台有话要说就显示,**包括已经开通的时候**。 + 实测开通后的原话是「数据正在更新中,请耐心等待」—— 若只在未开通时才显示, + 就会一边写着"数据已开通"、一边列不出作品,自相矛盾。 */} + {account.permission_tip && ( +
+
{permission.text} - {account.permission_tip && ( - {account.permission_tip} - )} + {account.permission_tip}
- 数据权限由创作者后台按天开通。在此之前同步会成功但返回 0 条 —— 那是正常的, - 不是采集失败。 + {account.permission_status === 'active' + ? '权限已开通,但后台的数据可能还在准备中 —— 稍后重新同步即可。' + : '数据权限由创作者后台按天开通。在此之前同步会成功但返回 0 条 —— 那是正常的,不是采集失败。'}
diff --git a/webui/src/types/creator.ts b/webui/src/types/creator.ts index 38899b9..5145edd 100644 --- a/webui/src/types/creator.ts +++ b/webui/src/types/creator.ts @@ -23,6 +23,8 @@ export interface CreatorAccount { permission_tip: string last_checked_at: number | null last_synced_at: number | null + /** 上次同步用的范围(天)。0 表示从未同步过。 */ + last_sync_days: number last_error: string | null has_cookie: boolean created_at: number