1
This commit is contained in:
parent
d49794acf6
commit
59e7c3b1fb
@ -308,11 +308,7 @@ function generateListPage(options: GenerateOptions): string {
|
|||||||
|
|
||||||
return `import React, { useState, useEffect } from 'react';
|
return `import React, { useState, useEffect } from 'react';
|
||||||
import { PageContainer } from '@/components/ui/page-container';
|
import { PageContainer } from '@/components/ui/page-container';
|
||||||
import {
|
import { Plus, Pencil, Trash2, Loader2 } from 'lucide-react';
|
||||||
PlusOutlined,
|
|
||||||
EditOutlined,
|
|
||||||
DeleteOutlined,
|
|
||||||
} from '@ant-design/icons';
|
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
@ -509,7 +505,7 @@ const ${typeName}List: React.FC = () => {
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => handleEdit(row.original)}
|
onClick={() => handleEdit(row.original)}
|
||||||
>
|
>
|
||||||
<EditOutlined className="mr-1"/>
|
<Pencil className="mr-2 h-4 w-4" />
|
||||||
编辑
|
编辑
|
||||||
</Button>
|
</Button>
|
||||||
<AlertDialog>
|
<AlertDialog>
|
||||||
@ -519,7 +515,7 @@ const ${typeName}List: React.FC = () => {
|
|||||||
size="sm"
|
size="sm"
|
||||||
className="text-destructive"
|
className="text-destructive"
|
||||||
>
|
>
|
||||||
<DeleteOutlined className="mr-1"/>
|
<Trash2 className="mr-2 h-4 w-4" />
|
||||||
删除
|
删除
|
||||||
</Button>
|
</Button>
|
||||||
</AlertDialogTrigger>
|
</AlertDialogTrigger>
|
||||||
@ -551,7 +547,7 @@ const ${typeName}List: React.FC = () => {
|
|||||||
<h2 className="text-3xl font-bold tracking-tight">${description}</h2>
|
<h2 className="text-3xl font-bold tracking-tight">${description}</h2>
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<Button onClick={handleAdd}>
|
<Button onClick={handleAdd}>
|
||||||
<PlusOutlined className="mr-1"/>
|
<Plus className="mr-2 h-4 w-4" />
|
||||||
新建
|
新建
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@ -607,19 +603,42 @@ const ${typeName}List: React.FC = () => {
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{list.map((item) => (
|
{loading ? (
|
||||||
<TableRow key={item.id}>
|
<TableRow>
|
||||||
{columns.map((column) => (
|
<TableCell
|
||||||
<TableCell
|
colSpan={columns.length}
|
||||||
key={column.accessorKey || column.id}
|
className="h-24 text-center"
|
||||||
>
|
>
|
||||||
{column.cell
|
<div className="flex justify-center items-center">
|
||||||
? column.cell({row: {original: item}})
|
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||||
: item[column.accessorKey!]}
|
加载中...
|
||||||
</TableCell>
|
</div>
|
||||||
))}
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
) : list.length === 0 ? (
|
||||||
|
<TableRow>
|
||||||
|
<TableCell
|
||||||
|
colSpan={columns.length}
|
||||||
|
className="h-24 text-center"
|
||||||
|
>
|
||||||
|
暂无数据
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
) : (
|
||||||
|
list.map((item) => (
|
||||||
|
<TableRow key={item.id}>
|
||||||
|
{columns.map((column) => (
|
||||||
|
<TableCell
|
||||||
|
key={column.accessorKey || column.id}
|
||||||
|
>
|
||||||
|
{column.cell
|
||||||
|
? column.cell({row: {original: item}})
|
||||||
|
: item[column.accessorKey!]}
|
||||||
|
</TableCell>
|
||||||
|
))}
|
||||||
|
</TableRow>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
<div className="flex justify-end border-t border-border bg-muted/40">
|
<div className="flex justify-end border-t border-border bg-muted/40">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user