Skip to content

Commit c28434c

Browse files
ymkiuxclaude
andauthored
fix: ResponsiveContainer -1 error & projects sort order (#242)
* fix: 修复托盘设置路由跳转 * fix: 清理URL中的target残留 * style: 优化侧边栏底部式样 * fix: resolve Recharts ResponsiveContainer width/height -1 error - Use fixed pixel height instead of percentage for ResponsiveContainer - Add minHeight guard to ChartContainer's ResponsiveContainer - Upgrade bytedance/sonic v1.14.2 → v1.15.0 for Go 1.26.0 compat - Add keepPreviousData to usage stats query Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(web): sort projects by createdAt to ensure consistent order Closes #204 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2589cea commit c28434c

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

web/src/components/layout/app-sidebar/nav-user.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,4 @@ export function NavUser() {
201201
</SidebarMenu>
202202
);
203203
}
204+

web/src/components/ui/chart.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ function ChartContainer({
6363
{...props}
6464
>
6565
<ChartStyle id={chartId} config={config} />
66-
<RechartsPrimitive.ResponsiveContainer>{children}</RechartsPrimitive.ResponsiveContainer>
66+
<RechartsPrimitive.ResponsiveContainer width="100%" height="100%" minHeight={1}>
67+
{children}
68+
</RechartsPrimitive.ResponsiveContainer>
6769
</div>
6870
</ChartContext.Provider>
6971
);

web/src/hooks/queries/use-usage-stats.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* 支持多层级时间粒度聚合
44
*/
55

6-
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
6+
import { keepPreviousData, useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
77
import { getTransport, type UsageStatsFilter, type StatsGranularity } from '@/lib/transport';
88

99
// Query Keys
@@ -117,6 +117,7 @@ export function useUsageStats(filter?: UsageStatsFilter) {
117117
return useQuery({
118118
queryKey: usageStatsKeys.list(filter),
119119
queryFn: () => getTransport().getUsageStats(filter),
120+
placeholderData: keepPreviousData,
120121
});
121122
}
122123

web/src/pages/projects/index.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from 'react';
1+
import { useMemo, useState } from 'react';
22
import { useNavigate } from 'react-router-dom';
33
import { useTranslation } from 'react-i18next';
44
import {
@@ -41,6 +41,24 @@ export function ProjectsPage() {
4141
navigate(`/projects/${id}`);
4242
};
4343

44+
const sortedProjects = useMemo(() => {
45+
if (!projects) {
46+
return undefined;
47+
}
48+
return projects.slice().sort((a, b) => {
49+
const timeA = Number.isFinite(new Date(a.createdAt).getTime())
50+
? new Date(a.createdAt).getTime()
51+
: 0;
52+
const timeB = Number.isFinite(new Date(b.createdAt).getTime())
53+
? new Date(b.createdAt).getTime()
54+
: 0;
55+
if (timeA !== timeB) {
56+
return timeA - timeB;
57+
}
58+
return a.id - b.id;
59+
});
60+
}, [projects]);
61+
4462
return (
4563
<div className="flex flex-col h-full bg-background">
4664
<PageHeader
@@ -89,9 +107,9 @@ export function ProjectsPage() {
89107
<div className="flex items-center justify-center p-12">
90108
<Loader2 className="h-8 w-8 animate-spin text-accent" />
91109
</div>
92-
) : projects && projects.length > 0 ? (
110+
) : sortedProjects && sortedProjects.length > 0 ? (
93111
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
94-
{projects.map((project) => (
112+
{sortedProjects.map((project) => (
95113
<Card
96114
key={project.id}
97115
className="group border-border bg-surface-primary cursor-pointer hover:border-accent/50 hover:shadow-card-hover transition-all duration-200 flex flex-col"

web/src/pages/stats/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,8 @@ export function StatsPage() {
898898
</Tabs>
899899
</CardHeader>
900900
<CardContent className="pt-2">
901-
<div className="w-full" style={{ height: '400px' }}>
902-
<ResponsiveContainer width="100%" height="100%">
901+
<div className="w-full h-[400px] min-h-[400px]">
902+
<ResponsiveContainer width="100%" height={400}>
903903
<ComposedChart data={chartData}>
904904
<CartesianGrid strokeDasharray="3 3" stroke="var(--border)" opacity={0.5} />
905905
<XAxis

0 commit comments

Comments
 (0)