Skip to content

Commit 482ad8b

Browse files
夏一飞夏一飞
夏一飞
authored and
夏一飞
committed
refactor: simplify time range handling and add loading state
1 parent 9890bca commit 482ad8b

File tree

7 files changed

+189
-289
lines changed

7 files changed

+189
-289
lines changed

app/models/page.tsx

+26-14
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,16 @@ const TestProgressPanel = ({
237237
);
238238
};
239239

240+
// 添加 LoadingState 组件
241+
const LoadingState = ({ t }: { t: (key: string) => string }) => (
242+
<div className="flex flex-col items-center justify-center py-12 px-4">
243+
<div className="h-12 w-12 rounded-full border-4 border-primary/10 border-t-primary animate-spin mb-4" />
244+
<h3 className="text-lg font-medium text-foreground/70">
245+
{t("models.loading")}
246+
</h3>
247+
</div>
248+
);
249+
240250
export default function ModelsPage() {
241251
const { t } = useTranslation("common");
242252
const [models, setModels] = useState<Model[]>([]);
@@ -905,26 +915,28 @@ export default function ModelsPage() {
905915
{/* 桌面端表格视图 */}
906916
<div className="hidden sm:block">
907917
<div className="rounded-xl border border-border/40 bg-card shadow-sm overflow-hidden">
908-
<Table
909-
columns={columns}
910-
dataSource={models}
911-
rowKey="id"
912-
loading={loading}
913-
pagination={false}
914-
size="middle"
915-
className={tableClassName}
916-
scroll={{ x: 500 }}
917-
rowClassName={() => "group"}
918-
/>
918+
{loading ? (
919+
<LoadingState t={t} />
920+
) : (
921+
<Table
922+
columns={columns}
923+
dataSource={models}
924+
rowKey="id"
925+
loading={false}
926+
pagination={false}
927+
size="middle"
928+
className={tableClassName}
929+
scroll={{ x: 500 }}
930+
rowClassName={() => "group"}
931+
/>
932+
)}
919933
</div>
920934
</div>
921935

922936
{/* 移动端卡片视图 */}
923937
<div className="sm:hidden">
924938
{loading ? (
925-
<div className="flex justify-center py-12">
926-
<div className="w-8 h-8 border-3 border-primary/20 border-t-primary animate-spin rounded-full"></div>
927-
</div>
939+
<LoadingState t={t} />
928940
) : (
929941
<div className="grid gap-4">
930942
{models.map((model) => (

0 commit comments

Comments
 (0)