From 19bd9b0122c85f67330d8746ffa4fedbb9205236 Mon Sep 17 00:00:00 2001 From: lyun Date: Sun, 1 Nov 2026 14:49:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=B9=B3=E6=BB=91=E5=88=87=E6=8D=A2=E4=B8=8E?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=9C=88=E4=BB=BD=E9=AB=98=E4=BA=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DESIGN.md | 16 ++ web/src/CachedWorkspacePages.tsx | 33 ++- web/src/QueryPage.tsx | 203 +++++++++--------- web/src/QueryResultMotion.tsx | 68 ++++++ web/src/StageProductPage.tsx | 41 ++-- web/src/periodDefaults.ts | 12 ++ web/src/query-motion.css | 3 + web/src/styles.css | 21 ++ web/src/types.ts | 2 + web/src/workspaceTransition.ts | 84 ++++++++ web/verification/metric_workbook.test.mjs | 6 +- web/verification/period_defaults.test.mjs | 27 +++ web/verification/query_result_motion.test.mjs | 26 +++ .../workspace_transition.test.mjs | 34 +++ 14 files changed, 450 insertions(+), 126 deletions(-) create mode 100644 web/src/QueryResultMotion.tsx create mode 100644 web/src/workspaceTransition.ts create mode 100644 web/verification/period_defaults.test.mjs create mode 100644 web/verification/query_result_motion.test.mjs create mode 100644 web/verification/workspace_transition.test.mjs diff --git a/DESIGN.md b/DESIGN.md index 3e76890..7aa9a31 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -63,3 +63,19 @@ - 未选中月份保色 50%,替代原来的 28%;既有 340 毫秒过渡及再次点击取消选择保持。 - 六主题共用 web/src/trendBarPalette.ts;其他浅色主题沿用各自蓝色方向,午夜黑同步增强对比度。 - 方案已获用户明确发布授权。候选预览控制栏和其他深度候选不进入正式页面。 + +## 2026-11-01:查询结果连续更新与阅读顺序 + +- 按用户要求调整为:指标卡、趋势图、汇总表、不良具体构成;总体、产业部、业务分组、产品、黑片和亮片查询保持一致。 +- 查询期间保留最后一次成功的卡片数据和表格及其期间、视图信息;旧结果暂时禁止打开明细及导出,新响应到达后恢复操作。 +- 卡片和已存在的表格单元格数字、表格高度采用 520 毫秒连续过渡;减少动态效果设置下直接更新。 +- Excel 始终使用最终服务端数值,不导出动画中的中间值。六主题逐帧检查、黑片与亮片实际页面检查及 42 项相关检查通过;当前仅本地修改,待用户发布。 + +## 2026-11-01:默认可用月份与页面切换(本地) + +- 无显式查询期间的新页面默认进入月度:优先上个月;上个月未出现在已发布月份列表时,仅回退到上上个月。重置和切回月度采用同一规则。 +- 复用 `/api/options` 的 `periods` / `latestDataPeriod`,不额外拉取完整报表判断。手动选择、分享链接、已缓存查询期间不被自动覆盖。 +- 不同页面之间采用 280ms 新旧内容交叉淡化,取消整页位移,顶部和侧栏保持稳定。目标页面先提交内容及滚动位置,再交接画面;首次加载等待最多 900ms,内容稳定 32ms 后提前开始。连续导航立即打断上一次切换,返回保留筛选及滚动位置。减少动态效果或浏览器不支持时直接切换。 +- 六个查询页默认月份、六主题切换、手动选择的慢加载保护、显式年月和返回时的筛选/滚动位置均已在本地验证。页面转场补充快速连续点击、取消等待及不可见控件保护验证,53 项相关检查通过,尚未发布。 +- 黑片与亮片页移除指标卡下方的来源统计与计算口径整行,回收空隙;计算说明仍可从指标卡或表头查看。趋势图关联已生效的月份/季度,默认月份及查询后同步选中加深,年度取消月份高亮。六主题选中效果已检查。 +- 2026-11-01 发布前生产构建与 57 项相关检查通过;此次仅更新前端,不修改计算逻辑或业务数据。 diff --git a/web/src/CachedWorkspacePages.tsx b/web/src/CachedWorkspacePages.tsx index f2345fd..dfce0d4 100644 --- a/web/src/CachedWorkspacePages.tsx +++ b/web/src/CachedWorkspacePages.tsx @@ -1,3 +1,5 @@ +import { flushSync } from 'react-dom'; +import { createWorkspaceTransition, waitForWorkspaceContent } from './workspaceTransition'; import { forwardRef, lazy, Suspense, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react'; import { Alert, Button, Spin } from 'antd'; import { api } from './api'; @@ -22,12 +24,20 @@ export const CachedWorkspacePages = forwardRef void; onUserChange: (user: AuthUser) => void; onUnauthorized: (error: unknown) => boolean; }>(function CachedWorkspacePages({ page, user, onPageChange, onUserChange, onUnauthorized }, ref) { const entries = useRef(new Map([[page, { initialSearch: location.search, search: location.search, key: 0, scroll: 0 }]])); + const requested = useRef(page); const current = useRef(page), generation = useRef(0), key = useRef(0); const revisions = useRef<{ authRevision: string; dataRevision: string } | null>(null); const validation = useRef | null>(null); const [refreshKey, setRefreshKey] = useState(0), [, render] = useState(0); const [ready, setReady] = useState(false), [error, setError] = useState(''); + const [navigationBusy, setNavigationBusy] = useState(false); const alive = useRef(true); + const transitions = useRef | null>(null); + if (!transitions.current) transitions.current = createWorkspaceTransition( + typeof document.startViewTransition === 'function' ? document.startViewTransition.bind(document) : undefined, + () => window.matchMedia('(prefers-reduced-motion: reduce)').matches, + busy => { if (alive.current) setNavigationBusy(busy); }, + ); const validate = () => { if (validation.current) return validation.current; const epoch = generation.current; @@ -39,6 +49,7 @@ export const CachedWorkspacePages = forwardRef value + 1); @@ -66,14 +77,22 @@ export const CachedWorkspacePages = forwardRef value + 1); - // 本地页面先响应点击,网络校验在后台进行;连续切换共享尚未结束的请求。 - void validate(); + requested.current = next; + transitions.current!.run(async signal => { + if (!alive.current || entries.current.get(next) !== entry) return; + // 与浏览器快照同步提交页面及滚动位置,避免转场结束后再补一次定位。 + flushSync(() => { + if (!pop) history.pushState({}, '', `${location.pathname}${entry.search}`); + current.current = next; onPageChange(next); render(value => value + 1); + }); + window.scrollTo(0, entry.scroll); + void validate(); + await waitForWorkspaceContent(() => document.querySelector(`.page-view[data-page="${next}"]`), signal); + }); }; const navigate = (next: PageKey, query?: QueryParams, resultRef?: ResultRef) => { if (next === 'imports') next = 'sources'; - if (next === current.current && !query && !resultRef) return; + if (next === requested.current && !query && !resultRef) return; const params = new URLSearchParams({ page: next }); if (query) params.set('context', encode({ query, ...(resultRef ? { resultRef } : {}) })); const cached = entries.current.get(next); @@ -89,7 +108,7 @@ export const CachedWorkspacePages = forwardRef setRefreshKey(value => value + 1); window.addEventListener(WORKSPACE_INVALIDATED, invalidate); - return () => { alive.current = false; generation.current++; validation.current = null; window.removeEventListener(WORKSPACE_INVALIDATED, invalidate); }; + return () => { alive.current = false; transitions.current?.cancel(); generation.current++; validation.current = null; window.removeEventListener(WORKSPACE_INVALIDATED, invalidate); }; }, []); const activeEntryKey = entries.current.get(page)?.key; useLayoutEffect(() => { @@ -101,7 +120,7 @@ export const CachedWorkspacePages = forwardRef正在打开工作台…; return <>{connectionNotice}{Array.from(entries.current.entries()).filter(([name]) => retained(name) || name === page).map(([name, entry]) => { const active = name === page; - return