mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-09-29 07:56:37 +08:00
修复平铺模式用户切换与图表TS构建
This commit is contained in:
@@ -741,31 +741,45 @@ export default function DashboardPage() {
|
||||
tickLine={false}
|
||||
axisLine={{ stroke: '#e5e7eb', strokeWidth: 1 }}
|
||||
/>
|
||||
<YAxis
|
||||
tick={{ fontSize: 12 }}
|
||||
tickLine={false}
|
||||
axisLine={{ stroke: '#e5e7eb', strokeWidth: 1 }}
|
||||
tickFormatter={(value) => {
|
||||
if (value === 0) return '0';
|
||||
if (value < 1024) return `${value}B`;
|
||||
if (value < 1024 * 1024) return `${(value / 1024).toFixed(1)}K`;
|
||||
if (value < 1024 * 1024 * 1024) return `${(value / (1024 * 1024)).toFixed(1)}M`;
|
||||
return `${(value / (1024 * 1024 * 1024)).toFixed(1)}G`;
|
||||
}}
|
||||
/>
|
||||
<Tooltip
|
||||
content={({ active, payload, label }) => {
|
||||
if (active && payload && payload.length) {
|
||||
return (
|
||||
<div className="bg-white dark:bg-default-100 border border-default-200 rounded-lg shadow-lg p-3">
|
||||
<p className="font-medium text-foreground">{`时间: ${label}`}</p>
|
||||
<p className="text-primary">
|
||||
{`流量: ${formatFlow(payload[0]?.value as number || 0)}`}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
<YAxis
|
||||
tick={{ fontSize: 12 }}
|
||||
tickLine={false}
|
||||
axisLine={{ stroke: '#e5e7eb', strokeWidth: 1 }}
|
||||
tickFormatter={(value: number | string) => {
|
||||
const v = typeof value === 'number' ? value : Number(value);
|
||||
if (!Number.isFinite(v)) return String(value);
|
||||
if (v === 0) return '0';
|
||||
if (v < 1024) return `${v}B`;
|
||||
if (v < 1024 * 1024) return `${(v / 1024).toFixed(1)}K`;
|
||||
if (v < 1024 * 1024 * 1024) return `${(v / (1024 * 1024)).toFixed(1)}M`;
|
||||
return `${(v / (1024 * 1024 * 1024)).toFixed(1)}G`;
|
||||
}}
|
||||
/>
|
||||
<Tooltip
|
||||
content={({
|
||||
active,
|
||||
payload,
|
||||
label,
|
||||
}: {
|
||||
active?: boolean;
|
||||
payload?: Array<{ value?: number | string }>;
|
||||
label?: string | number;
|
||||
}) => {
|
||||
if (active && payload && payload.length) {
|
||||
const firstValue = payload[0]?.value;
|
||||
const numericValue = typeof firstValue === 'number' ? firstValue : Number(firstValue);
|
||||
const flowValue = Number.isFinite(numericValue) ? numericValue : 0;
|
||||
|
||||
return (
|
||||
<div className="bg-white dark:bg-default-100 border border-default-200 rounded-lg shadow-lg p-3">
|
||||
<p className="font-medium text-foreground">{`时间: ${label ?? ''}`}</p>
|
||||
<p className="text-primary">
|
||||
{`流量: ${formatFlow(flowValue)}`}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}}
|
||||
/>
|
||||
<Line
|
||||
@@ -983,4 +997,4 @@ export default function DashboardPage() {
|
||||
</div>
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1117,6 +1117,8 @@ export default function ForwardPage() {
|
||||
})
|
||||
);
|
||||
|
||||
const tokenUserId = JwtUtil.getUserIdFromToken();
|
||||
|
||||
// 根据排序顺序获取转发列表
|
||||
const sortedForwards = useMemo((): Forward[] => {
|
||||
// 确保 forwards 数组存在且有效
|
||||
@@ -1127,9 +1129,8 @@ export default function ForwardPage() {
|
||||
// 在平铺模式下,只显示当前用户的转发
|
||||
let filteredForwards = forwards;
|
||||
if (viewMode === 'direct') {
|
||||
const currentUserId = JwtUtil.getUserIdFromToken();
|
||||
if (currentUserId !== null) {
|
||||
filteredForwards = forwards.filter(forward => forward.userId === currentUserId);
|
||||
if (tokenUserId !== null) {
|
||||
filteredForwards = forwards.filter(forward => forward.userId === tokenUserId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1168,7 +1169,7 @@ export default function ForwardPage() {
|
||||
}
|
||||
|
||||
return sortedByDb;
|
||||
}, [forwards, forwardOrder, viewMode]);
|
||||
}, [forwards, forwardOrder, viewMode, tokenUserId]);
|
||||
|
||||
const sortableForwardIds = useMemo(
|
||||
() => sortedForwards.map(f => f.id).filter(id => id > 0),
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
declare module 'recharts' {
|
||||
import * as React from 'react';
|
||||
|
||||
export const LineChart: React.ComponentType<Record<string, unknown>>;
|
||||
export const Line: React.ComponentType<Record<string, unknown>>;
|
||||
export const XAxis: React.ComponentType<Record<string, unknown>>;
|
||||
export const YAxis: React.ComponentType<Record<string, unknown>>;
|
||||
export const CartesianGrid: React.ComponentType<Record<string, unknown>>;
|
||||
export const Tooltip: React.ComponentType<Record<string, unknown>>;
|
||||
export const ResponsiveContainer: React.ComponentType<Record<string, unknown>>;
|
||||
}
|
||||
Reference in New Issue
Block a user