Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/api/APIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export const Fetch = axios.create({
*/
const getErrorMessage = (error: AxiosError): string => {
if (error.response) {
if (error.response.status === 429) {
const retryAfter = Number(error.response.headers['retry-after']);
if (Number.isFinite(retryAfter)) return `请在 ${Math.ceil(retryAfter)} 秒后重试`;
}

const data = error.response.data as any;
// 如果后端返回的是字符串,直接使用;如果是对象,尝试获取 message 或 error 字段
if (typeof data === 'string') return data;
Expand Down
1 change: 1 addition & 0 deletions src/components/Login/LoginWithPasswordComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export default function LoginWithPasswordComponent() {
</Button>
<Button
colorPalette="brand"
loading={isSubmitting}
onClick={handleSubmit(handleRegister)}
>
注册
Expand Down