.agents/skills/system/pr-review/style/front.md
FastGPT 使用 React + TypeScript + Chakra UI。
审查要点:
React.memo 优化性能示例:
import React from 'react';
import { Box, Button } from '@chakra-ui/react';
type YourComponentProps = {
title: string;
onClick: () => void;
disabled?: boolean;
};
export const YourComponent = React.memo(function YourComponent({
title,
onClick,
disabled = false
}: YourComponentProps) {
return (
<Box>
<Button onClick={onClick} isDisabled={disabled}>
{title}
</Button>
</Box>
);
});
审查要点:
useStateuseForm (react-hook-form)useReducer审查要点:
styles/theme.ts示例:
// ❌ 不好的实践
<Box style={{ backgroundColor: 'blue', padding: '16px' }}>
// ✅ 好的实践
<Box bg="blue.500" p={4}>
审查要点:
t, 服务端使用i18nT示例:
import { i18nT } from '@fastgpt/web/i18n/utils';
const message = i18nT('user:welcome', { name: userName });
import { useTranslation } from 'next-i18next';
const { t } = useTranslation();
const message = t('user:welcome', { name: userName });
审查要点:
useMemo 缓存计算结果useCallback 缓存函数