feat: 合并代码,增加分页默认值

This commit is contained in:
speakeloudest 2025-08-21 21:38:58 -07:00
parent f90f431540
commit fe704d1611
4 changed files with 126 additions and 8 deletions

View File

@ -315,6 +315,9 @@ export default function NodeTable() {
return updatedItems;
}}
initialPagination={{
initialPageSize: 200,
}}
/>
);
}

View File

@ -34,6 +34,9 @@ import { z } from 'zod';
const inviteSchema = z.object({
forced_invite: z.boolean().optional(),
referral_percentage: z.number().optional(),
non_first_purchase_percentage: z.number().optional(),
first_yearly_purchase_percentage: z.number().optional(),
first_purchase_percentage: z.number().optional(),
only_first_purchase: z.boolean().optional(),
});
@ -60,6 +63,9 @@ export default function InviteConfig() {
forced_invite: false,
referral_percentage: 0,
only_first_purchase: false,
non_first_purchase_percentage: 0,
first_yearly_purchase_percentage: 0,
first_purchase_percentage: 0,
},
});
@ -123,7 +129,6 @@ export default function InviteConfig() {
className='float-end !mt-0'
/>
</FormControl>
<FormDescription>{t('forcedInviteDescription')}</FormDescription>
<FormMessage />
</FormItem>
)}
@ -131,10 +136,10 @@ export default function InviteConfig() {
<FormField
control={form.control}
name='referral_percentage'
name='first_yearly_purchase_percentage'
render={({ field }) => (
<FormItem>
<FormLabel>{t('referralPercentage')}</FormLabel>
<FormLabel></FormLabel>
<FormControl>
<EnhancedInput
placeholder={t('inputPlaceholder')}
@ -146,11 +151,108 @@ export default function InviteConfig() {
onValueBlur={(value) => field.onChange(Number(value))}
/>
</FormControl>
<FormDescription>{t('referralPercentageDescription')}</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name='first_purchase_percentage'
render={({ field }) => (
<FormItem>
<FormLabel></FormLabel>
<FormControl>
<EnhancedInput
placeholder={t('inputPlaceholder')}
value={field.value}
type='number'
min={0}
max={100}
suffix='%'
onValueBlur={(value) => field.onChange(Number(value))}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name='non_first_purchase_percentage'
render={({ field }) => (
<FormItem>
<FormLabel></FormLabel>
<FormControl>
<EnhancedInput
placeholder={t('inputPlaceholder')}
value={field.value}
type='number'
min={0}
max={100}
suffix='%'
onValueBlur={(value) => field.onChange(Number(value))}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{/*
<TableRow>
<TableCell>
<Label></Label>
<p className='text-muted-foreground text-xs'></p>
</TableCell>
<TableCell className='text-right'>
<EnhancedInput
placeholder={t('inputPlaceholder')}
value={data?.first_yearly_purchase_percentage}
type='number'
min={0}
max={100}
suffix='%'
onValueBlur={(value) => updateConfig('first_yearly_purchase_percentage', value)}
/>
</TableCell>
</TableRow>
<TableRow>
<TableCell>
<Label></Label>
<p className='text-muted-foreground text-xs'></p>
</TableCell>
<TableCell className='text-right'>
<EnhancedInput
placeholder={t('inputPlaceholder')}
value={data?.first_purchase_percentage}
type='number'
min={0}
max={100}
suffix='%'
onValueBlur={(value) => updateConfig('first_purchase_percentage', value)}
/>
</TableCell>
</TableRow>
<TableRow>
<TableCell>
<Label></Label>
<p className='text-muted-foreground text-xs'></p>
</TableCell>
<TableCell className='text-right'>
<EnhancedInput
placeholder={t('inputPlaceholder')}
value={data?.non_first_purchase_percentage}
type='number'
min={0}
max={100}
suffix='%'
onValueBlur={(value) => updateConfig('non_first_purchase_percentage', value)}
/>
</TableCell>
</TableRow>
*/}
<FormField
control={form.control}

View File

@ -4,6 +4,7 @@
"": {
"name": "ppanel-web",
"devDependencies": {
"@netlify/plugin-nextjs": "^5.11.6",
"@umijs/openapi": "^1.13.0",
"@workspace/commitlint-config": "workspace:*",
"@workspace/eslint-config": "workspace:*",
@ -280,6 +281,7 @@
"input-otp": "^1.4.2",
"lucide-react": "^0.473.0",
"mathjs": "^14.0.1",
"monaco-themes": "^0.4.6",
"motion": "^11.18.1",
"next-themes": "^0.4.4",
"react-day-picker": "8.10.1",
@ -707,6 +709,8 @@
"@monaco-editor/react": ["@monaco-editor/react@4.7.0", "", { "dependencies": { "@monaco-editor/loader": "^1.5.0" }, "peerDependencies": { "monaco-editor": ">= 0.25.0 < 1", "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-cyzXQCtO47ydzxpQtCGSQGOC8Gk3ZUeBXFAxD+CWXYFo5OqZyZUonFl0DwUlTyAfRHntBfw2p3w4s9R6oe1eCA=="],
"@netlify/plugin-nextjs": ["@netlify/plugin-nextjs@5.12.1", "", {}, "sha512-b2Ic9NkNnnh0lKC/YWDZ2+HdLd/uYdBzLvLKYOkPyFt8KEszoC+Je3GRcwBeOLxaNtK8lji7YPIjtGz8K2sLVQ=="],
"@next/env": ["@next/env@15.4.6", "", {}, "sha512-yHDKVTcHrZy/8TWhj0B23ylKv5ypocuCwey9ZqPyv4rPdUdRzpGCkSi03t04KBPyU96kxVtUqx6O3nE1kpxASQ=="],
"@next/eslint-plugin-next": ["@next/eslint-plugin-next@15.4.6", "", { "dependencies": { "fast-glob": "3.3.1" } }, "sha512-2NOu3ln+BTcpnbIDuxx6MNq+pRrCyey4WSXGaJIyt0D2TYicHeO9QrUENNjcf673n3B1s7hsiV5xBYRCK1Q8kA=="],
@ -1573,6 +1577,8 @@
"fast-levenshtein": ["fast-levenshtein@2.0.6", "", {}, "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw=="],
"fast-plist": ["fast-plist@0.1.3", "", {}, "sha512-d9cEfo/WcOezgPLAC/8t8wGb6YOD6JTCPMw2QcG2nAdFmyY+9rTUizCTaGjIZAloWENTEUMAPpkUAIJJJ0i96A=="],
"fast-safe-stringify": ["fast-safe-stringify@2.1.1", "", {}, "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA=="],
"fast-uri": ["fast-uri@3.0.6", "", {}, "sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw=="],
@ -2147,6 +2153,8 @@
"monaco-editor": ["monaco-editor@0.52.2", "", {}, "sha512-GEQWEZmfkOGLdd3XK8ryrfWz3AIP8YymVXiPHEdewrUq7mh0qrKrfHLNCXcbB6sTnMLnOZ3ztSiKcciFUkIJwQ=="],
"monaco-themes": ["monaco-themes@0.4.6", "", { "dependencies": { "fast-plist": "^0.1.3" } }, "sha512-g8E1CNT6bRyinPSQxVnNrs5b12zmKBpA83l3MEyOETr+KvoyUP4SS1AfHxyxaFBnLiyuyRwoPO4+R4PvzCJzPw=="],
"motion": ["motion@11.18.2", "", { "dependencies": { "framer-motion": "^11.18.2", "tslib": "^2.4.0" }, "peerDependencies": { "@emotion/is-prop-valid": "*", "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0" }, "optionalPeers": ["@emotion/is-prop-valid", "react", "react-dom"] }, "sha512-JLjvFDuFr42NFtcVoMAyC2sEjnpA8xpy6qWPyzQvCloznAyQ8FIXioxWfHiLtgYhoVpfUqSWpn1h9++skj9+Wg=="],
"motion-dom": ["motion-dom@11.18.1", "", { "dependencies": { "motion-utils": "^11.18.1" } }, "sha512-g76KvA001z+atjfxczdRtw/RXOM3OMSdd1f4DL77qCTF/+avrRJiawSG4yDibEQ215sr9kpinSlX2pCTJ9zbhw=="],

View File

@ -69,6 +69,9 @@ export interface ProTableProps<TData, TValue> {
targetId: string | number | null,
items: TData[],
) => Promise<TData[]>;
initialPagination: {
initialPageSize: number;
};
}
export interface ProTableActions {
@ -89,6 +92,7 @@ export function ProTable<
texts,
empty,
onSort,
initialPagination,
}: ProTableProps<TData, TValue>) {
const [sorting, setSorting] = useState<SortingState>([]);
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
@ -98,7 +102,7 @@ export function ProTable<
const [rowCount, setRowCount] = useState<number>(0);
const [pagination, setPagination] = useState({
pageIndex: 0,
pageSize: 10,
pageSize: initialPagination?.initialPageSize ?? 10,
});
const [loading, setLoading] = useState(false);
@ -132,9 +136,9 @@ export function ProTable<
header: texts?.actions,
cell: ({ row }) => (
<div className='flex items-center justify-end gap-2'>
{actions
?.render?.(row.original)
.map((item, index) => <Fragment key={index}>{item}</Fragment>)}
{actions?.render?.(row.original).map((item, index) => (
<Fragment key={index}>{item}</Fragment>
))}
</div>
),
enableSorting: false,
@ -197,6 +201,7 @@ export function ProTable<
useImperativeHandle(action, () => ({
refresh: fetchData,
reset,
setPagination,
}));
useEffect(() => {