feat: 去除配置项等待
Some checks failed
CI / build (20.15.1) (push) Failing after 55s

This commit is contained in:
speakeloudest 2025-12-10 04:41:15 -08:00
parent f86e3b4725
commit b0c8cfb024
2 changed files with 123 additions and 162 deletions

View File

@ -13,13 +13,12 @@ import {
} from '@workspace/airo-ui/components/form'; } from '@workspace/airo-ui/components/form';
import { Input } from '@workspace/airo-ui/components/input'; import { Input } from '@workspace/airo-ui/components/input';
import { Icon } from '@workspace/airo-ui/custom-components/icon'; import { Icon } from '@workspace/airo-ui/custom-components/icon';
import { Markdown } from '@workspace/airo-ui/custom-components/markdown';
import { useRouter } from 'next/navigation'; import { useRouter } from 'next/navigation';
import { Dispatch, SetStateAction, useEffect, useRef, useState } from 'react'; import { Dispatch, SetStateAction, useEffect, useRef, useState } from 'react';
import { useForm } from 'react-hook-form'; import { useForm } from 'react-hook-form';
import { z } from 'zod'; import { z } from 'zod';
import SendCode from '../send-code'; import SendCode from '../send-code';
import CloudFlareTurnstile, { TurnstileRef } from '../turnstile'; import { TurnstileRef } from '../turnstile';
export default function RegisterForm({ export default function RegisterForm({
loading, loading,
@ -35,35 +34,15 @@ export default function RegisterForm({
onSwitchForm: Dispatch<SetStateAction<'register' | 'reset' | 'login'>>; onSwitchForm: Dispatch<SetStateAction<'register' | 'reset' | 'login'>>;
}) { }) {
const { common } = useGlobalStore(); const { common } = useGlobalStore();
const { verify, auth, invite } = common;
const router = useRouter(); const router = useRouter();
const handleCheckUser = async (email: string) => {
try {
if (!auth.email.enable_domain_suffix) return true;
const domain = email.split('@')[1];
const isValid = auth.email?.domain_suffix_list.split('\n').includes(domain || '');
return isValid;
} catch (error) {
console.log('Error checking user:', error);
return false;
}
};
const formSchema = z const formSchema = z
.object({ .object({
email: z.string().email('请输入有效的电子邮件地址。').refine(handleCheckUser, { email: z.string().email('请输入有效的电子邮件地址。'),
message: '电子邮件域名不在允许的白名单中。',
}),
password: z.string().min(1, '请输入密码'), // 必填提示 password: z.string().min(1, '请输入密码'), // 必填提示
repeat_password: z.string().min(1, '请重复输入密码'), // 必填 repeat_password: z.string().min(1, '请重复输入密码'), // 必填
code: auth.email.enable_verify code: z.string().min(1, '请输入验证码'), // 必填,
? z.string().min(1, '请输入验证码') // 必填 invite: z.string().nullish(),
: z.string().nullish(),
invite: invite.forced_invite ? z.string().min(1, '请输入邀请码') : z.string().nullish(),
cf_token:
verify.enable_register_verify && verify.turnstile_site_key
? z.string()
: z.string().nullish(),
}) })
.superRefine(({ password, repeat_password }, ctx) => { .superRefine(({ password, repeat_password }, ctx) => {
if (password !== repeat_password) { if (password !== repeat_password) {
@ -103,155 +82,137 @@ export default function RegisterForm({
<> <>
<div className={'h-[84px] text-2xl font-bold leading-[84px]'}>线</div> <div className={'h-[84px] text-2xl font-bold leading-[84px]'}>线</div>
{auth.register.stop_register ? ( <Form {...form}>
<Markdown></Markdown> <form onSubmit={handleSubmit}>
) : ( <div className='grid gap-5'>
<Form {...form}> <FormField
<form onSubmit={handleSubmit}> control={form.control}
<div className='grid gap-5'> name='email'
<FormField render={({ field }) => (
control={form.control} <FormItem>
name='email' <FormControl>
render={({ field }) => ( <Input
<FormItem> className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
<FormControl> placeholder='电子邮箱'
<Input type='email'
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'} {...field}
placeholder='电子邮箱' />
type='email' </FormControl>
{...field} <FormMessage />
/> </FormItem>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name='password'
render={({ field }) => (
<FormItem>
<FormControl>
<Input
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
placeholder='设置密码'
type='password'
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name='repeat_password'
render={({ field }) => (
<FormItem>
<FormControl>
<Input
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
disabled={loading}
placeholder='再次输入密码'
type='password'
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{auth.email.enable_verify && (
<FormField
control={form.control}
name='code'
render={({ field }) => (
<FormItem>
<FormControl>
<div className='flex items-center gap-8'>
<Input
disabled={loading}
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
placeholder='邮箱验证码'
type='text'
{...field}
value={field.value as string}
/>
<SendCode
type='email'
form={form}
params={{
...form.getValues(),
type: 1,
}}
/>
</div>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
)} )}
/>
<FormField
control={form.control}
name='password'
render={({ field }) => (
<FormItem>
<FormControl>
<Input
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
placeholder='设置密码'
type='password'
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name='repeat_password'
render={({ field }) => (
<FormItem>
<FormControl>
<Input
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
disabled={loading}
placeholder='再次输入密码'
type='password'
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{
<FormField <FormField
control={form.control} control={form.control}
name='invite' name='code'
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormControl> <FormControl>
<Input <div className='flex items-center gap-8'>
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'} <Input
disabled={loading || !!inviteDefault} disabled={loading}
placeholder={'邀请码(非必填)'} className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
{...field} placeholder='邮箱验证码'
value={field.value || ''} type='text'
/> {...field}
value={field.value as string}
/>
<SendCode
type='email'
form={form}
params={{
...form.getValues(),
type: 1,
}}
/>
</div>
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
)} )}
/> />
{verify.enable_register_verify && ( }
<FormField <FormField
control={form.control} control={form.control}
name='cf_token' name='invite'
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormControl> <FormControl>
<CloudFlareTurnstile id='register' {...field} ref={turnstile} /> <Input
</FormControl> className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
<FormMessage /> disabled={loading || !!inviteDefault}
</FormItem> placeholder={'邀请码(非必填)'}
)} {...field}
/> value={field.value || ''}
/>
</FormControl>
<FormMessage />
</FormItem>
)} )}
</div> />
</div>
<div className='text-right text-sm'> <div className='text-right text-sm'>
&nbsp; &nbsp;
<Button <Button
variant='link' variant='link'
type='button' type='button'
className='p-0 text-[#225BA9]' className='p-0 text-[#225BA9]'
onClick={() => { onClick={() => {
router.replace('/'); router.replace('/');
}} }}
> >
</Button> </Button>
</div> </div>
<div className='mt-6 flex justify-center'> <div className='mt-6 flex justify-center'>
<AiroButton <AiroButton
type='submit' type='submit'
disabled={loading} disabled={loading}
className='h-auto min-w-[157px] py-2 text-lg font-medium' className='h-auto min-w-[157px] py-2 text-lg font-medium'
> >
{loading && <Icon icon='mdi:loading' className='animate-spin' />} {loading && <Icon icon='mdi:loading' className='animate-spin' />}
</AiroButton> </AiroButton>
</div> </div>
</form> </form>
</Form> </Form>
)}
</> </>
); );
} }

View File

@ -33,7 +33,7 @@ export default function Providers({
const { setCommon, setUser } = useGlobalStore(); const { setCommon, setUser } = useGlobalStore();
const pathname = usePathname(); const pathname = usePathname();
const whiteList = ['/']; const whiteList = ['/', '/register'];
const isWhite = whiteList.includes(pathname); const isWhite = whiteList.includes(pathname);
useEffect(() => { useEffect(() => {