From e11d3647ad8422c8372a1f4205728b3463973545 Mon Sep 17 00:00:00 2001 From: xmanrui <841206367@qq.com> Date: Tue, 3 Mar 2026 03:23:56 +0800 Subject: [PATCH] feat: paginate mobile office agents in fixed 3x3 grid --- app/pixel-office/page.tsx | 59 ++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/app/pixel-office/page.tsx b/app/pixel-office/page.tsx index 30e82c6..c65060f 100644 --- a/app/pixel-office/page.tsx +++ b/app/pixel-office/page.tsx @@ -158,6 +158,7 @@ const MOBILE_MIN_ZOOM = 0.55 const MOBILE_MAX_ZOOM = 6 const MOBILE_FIT_PADDING_PX = 2 const MOBILE_TOP_EXTRA_TILES = 0.5 +const MOBILE_VIEW_NUDGE_Y_PX = -10 const CODE_SNIPPET_LIFETIME_SEC = 5.5 const FLOATING_TICK_INTERVAL_DESKTOP_MS = 48 const FLOATING_TICK_INTERVAL_MOBILE_MS = 32 @@ -356,7 +357,8 @@ export default function PixelOfficePage() { const topExtraPx = topExtraTiles * TILE_SIZE * nextZoom const minPanY = MOBILE_FIT_PADDING_PX + topExtraPx - centerOffsetY const maxPanY = height - MOBILE_FIT_PADDING_PX - (centerOffsetY + mapH) - const targetPanY = minPanY > maxPanY ? minPanY : Math.min(maxPanY, Math.max(minPanY, 0)) + const basePanY = minPanY > maxPanY ? minPanY : Math.min(maxPanY, Math.max(minPanY, 0)) + const targetPanY = Math.min(maxPanY, Math.max(minPanY - 16, basePanY + MOBILE_VIEW_NUDGE_Y_PX)) panRef.current = { x: 0, y: Math.round(targetPanY) } } else { zoomRef.current = DESKTOP_CANVAS_ZOOM @@ -1246,6 +1248,28 @@ export default function PixelOfficePage() { isMobileViewport ? `w-full ${maxHeight} overflow-y-auto rounded-t-2xl border-x border-t border-[var(--border)] bg-[var(--card)] shadow-2xl p-4 pb-6` : `${desktopWidth} ${maxHeight} overflow-y-auto rounded-xl border border-[var(--border)] bg-[var(--card)] shadow-2xl p-4` + const mobileAgentPages: AgentActivity[][] = [] + for (let i = 0; i < agents.length; i += 9) { + mobileAgentPages.push(agents.slice(i, i + 9)) + } + const renderAgentChip = (agent: AgentActivity, mobileGrid = false) => ( +
+ {agent.emoji} + {agent.name} + {agent.state === 'working' && {t('pixelOffice.state.working')}} + {agent.state === 'idle' && {t('pixelOffice.state.idle')}} + {agent.state === 'offline' && {t('pixelOffice.state.offline')}} + {agent.state === 'waiting' && {t('pixelOffice.state.waiting')}} +
+ ) return (
@@ -1304,23 +1328,24 @@ export default function PixelOfficePage() {
-
- {agents.map(agent => ( -
- {agent.emoji} - {agent.name} - {agent.state === 'working' && {t('pixelOffice.state.working')}} - {agent.state === 'idle' && {t('pixelOffice.state.idle')}} - {agent.state === 'offline' && {t('pixelOffice.state.offline')}} - {agent.state === 'waiting' && {t('pixelOffice.state.waiting')}} +
+ {agents.length === 0 ? ( +
{t('common.noData')}
+ ) : ( +
+ {mobileAgentPages.map((page, pageIndex) => ( +
+ {page.map((agent) => renderAgentChip(agent, true))} + {page.length < 9 && Array.from({ length: 9 - page.length }).map((_, i) => ( +
+ ))} +
+ ))}
- ))} + )} +
+
+ {agents.map((agent) => renderAgentChip(agent))} {agents.length === 0 && (
{t('common.noData')}
)}