🐛 fix(ui): Bugs
This commit is contained in:
parent
059a8921d5
commit
b023d0feff
@ -36,10 +36,10 @@ export default function Page() {
|
||||
<div className='flex flex-col justify-center pb-14 lg:flex-auto lg:pb-20'>
|
||||
<UserAuthForm />
|
||||
</div>
|
||||
<div className='flex items-center justify-between'>
|
||||
<div className='text-primary flex gap-5 text-sm font-semibold'>
|
||||
<div className='flex items-center justify-end'>
|
||||
{/* <div className='text-primary flex gap-5 text-sm font-semibold'>
|
||||
<Link href='/tos'>{t('tos')}</Link>
|
||||
</div>
|
||||
</div> */}
|
||||
<div className='flex items-center gap-5'>
|
||||
<LanguageSwitch />
|
||||
<ThemeSwitch />
|
||||
|
||||
@ -7,10 +7,7 @@ import {
|
||||
import useGlobalStore from '@/config/use-global';
|
||||
import { checkUser, resetPassword, userLogin, userRegister } from '@/services/common/auth';
|
||||
import { getRedirectUrl, setAuthorization } from '@/utils/common';
|
||||
import { Icon } from '@iconify/react';
|
||||
import { Button } from '@shadcn/ui/button';
|
||||
import { toast } from '@shadcn/ui/lib/sonner';
|
||||
import { cn } from '@shadcn/ui/lib/utils';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { ReactNode, useState, useTransition } from 'react';
|
||||
@ -131,7 +128,7 @@ export default function UserAuthForm() {
|
||||
{t(`${type || 'check'}.description`)}
|
||||
</div>
|
||||
</div>
|
||||
{!((type === 'register' && register.stop_register) || type === 'reset') && (
|
||||
{/* {!((type === 'register' && register.stop_register) || type === 'reset') && (
|
||||
<>
|
||||
<div className='mb-3 flex flex-wrap items-center justify-center gap-3 font-bold'>
|
||||
<Button type='button' variant='outline'>
|
||||
@ -157,7 +154,7 @@ export default function UserAuthForm() {
|
||||
<span className='text-muted-foreground w-[125px] text-sm'>{t('orWithEmail')}</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
)} */}
|
||||
|
||||
{UserForm}
|
||||
</>
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import useGlobalStore from '@/config/use-global';
|
||||
import { Icon } from '@iconify/react';
|
||||
import { Button } from '@shadcn/ui/button';
|
||||
import { Form, FormControl, FormField, FormItem, FormMessage } from '@shadcn/ui/form';
|
||||
@ -18,22 +17,20 @@ export default function UserCheckForm({
|
||||
initialValues: any;
|
||||
}) {
|
||||
const t = useTranslations('auth.check');
|
||||
const { common } = useGlobalStore();
|
||||
const { register } = common;
|
||||
// const { common } = useGlobalStore();
|
||||
// const { register } = common;
|
||||
const formSchema = z.object({
|
||||
email: z
|
||||
.string()
|
||||
.email(t('email'))
|
||||
.refine(
|
||||
(email) => {
|
||||
if (!register.enable_email_domain_suffix) return true;
|
||||
const domain = email.split('@')[1] as string;
|
||||
return register.email_domain_suffix_list.split('\n').includes(domain);
|
||||
},
|
||||
{
|
||||
message: t('whitelist'),
|
||||
},
|
||||
),
|
||||
email: z.string().email(t('email')),
|
||||
// .refine(
|
||||
// (email) => {
|
||||
// if (!register.enable_email_domain_suffix) return true;
|
||||
// const domain = email.split('@')[1] as string;
|
||||
// return register.email_domain_suffix_list.split('\n').includes(domain);
|
||||
// },
|
||||
// {
|
||||
// message: t('whitelist'),
|
||||
// },
|
||||
// ),
|
||||
});
|
||||
|
||||
const form = useForm<z.infer<typeof formSchema>>({
|
||||
|
||||
@ -491,7 +491,7 @@ export default function SubscribeForm<T extends Record<string, any>>({
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='grid grid-cols-2 gap-4'>
|
||||
<div className='flex flex-col gap-4'>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name='server_group'
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
"smtpAccount": "SMTP Account",
|
||||
"smtpAccountDescription": "The email account used for authentication.",
|
||||
"smtpEncryptionMethod": "SMTP Encryption Method",
|
||||
"smtpEncryptionMethodDescription": "Choose whether to enable SSL encryption.",
|
||||
"smtpEncryptionMethodDescription": "Choose whether to enable SSL/TLS encryption.",
|
||||
"smtpPassword": "SMTP Password",
|
||||
"smtpPasswordDescription": "The password for the SMTP account.",
|
||||
"smtpServerAddress": "SMTP Server Address",
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
"smtpAccount": "SMTP 账号",
|
||||
"smtpAccountDescription": "用于身份验证的邮件账号。",
|
||||
"smtpEncryptionMethod": "SMTP 加密方式",
|
||||
"smtpEncryptionMethodDescription": "选择是否启用 SSL 加密。",
|
||||
"smtpEncryptionMethodDescription": "选择是否启用 SSL/TLS 加密。",
|
||||
"smtpPassword": "SMTP 密码",
|
||||
"smtpPasswordDescription": "该 SMTP 账号的密码。",
|
||||
"smtpServerAddress": "SMTP 服务器地址",
|
||||
|
||||
@ -26,7 +26,7 @@ export function EnhancedInput({
|
||||
...props
|
||||
}: EnhancedInputProps) {
|
||||
const getProcessedValue = (inputValue: unknown) => {
|
||||
const newValue = String(inputValue ?? '');
|
||||
const newValue = inputValue === '' || inputValue === 0 ? '' : String(inputValue ?? '');
|
||||
return formatInput ? formatInput(newValue) : newValue;
|
||||
};
|
||||
|
||||
@ -47,16 +47,19 @@ export function EnhancedInput({
|
||||
|
||||
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
let inputValue = e.target.value;
|
||||
if (props.type === 'number') {
|
||||
if (props.type === 'number' && inputValue) {
|
||||
const numericValue = Number(inputValue);
|
||||
if (!isNaN(numericValue)) {
|
||||
const min = Number.isFinite(props.min) ? props.min : -Infinity;
|
||||
const max = Number.isFinite(props.max) ? props.max : Infinity;
|
||||
inputValue = String(Math.max(min!, Math.min(max!, numericValue)));
|
||||
}
|
||||
}
|
||||
setValue(inputValue === '0' ? '' : inputValue);
|
||||
} else {
|
||||
setValue(inputValue);
|
||||
}
|
||||
const outputValue = processValue(inputValue);
|
||||
console.log();
|
||||
onValueChange?.(outputValue);
|
||||
};
|
||||
|
||||
|
||||
@ -2,13 +2,12 @@
|
||||
|
||||
import { Button } from '@shadcn/ui/button';
|
||||
import { cn } from '@shadcn/ui/lib/utils';
|
||||
import { ScrollArea } from '@shadcn/ui/scroll-area';
|
||||
import 'katex/dist/katex.min.css';
|
||||
import { Check, Copy } from 'lucide-react';
|
||||
import { useCallback, useState } from 'react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
||||
import { oneDark, oneLight } from 'react-syntax-highlighter/dist/esm/styles/prism';
|
||||
import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism';
|
||||
import rehypeKatex from 'rehype-katex';
|
||||
import rehypeRaw from 'rehype-raw';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
@ -39,39 +38,38 @@ function CodeBlock({ className, children, dark, ...props }: CodeBlockProps) {
|
||||
|
||||
if (match) {
|
||||
return (
|
||||
<div className='group relative w-full'>
|
||||
<div className='bg-muted flex items-center justify-between gap-4 rounded-t-lg px-4 py-2 text-sm font-semibold'>
|
||||
<div className='group relative my-4 w-full overflow-hidden rounded-lg'>
|
||||
<div className='bg-muted flex items-center justify-between gap-4 px-4 py-2 text-sm font-semibold'>
|
||||
<span className='lowercase [&>span]:text-xs'>{match[1]}</span>
|
||||
<Button
|
||||
variant='ghost'
|
||||
size='sm'
|
||||
size='icon'
|
||||
onClick={() => handleCopy(String(children).replace(/\n$/, ''))}
|
||||
className='absolute right-2 top-2 z-20 opacity-0 transition-opacity duration-200 group-hover:opacity-100'
|
||||
className='absolute right-2 top-0 z-20 p-0.5 opacity-0 transition-opacity duration-200 group-hover:opacity-100'
|
||||
>
|
||||
{copied ? <Check size={16} /> : <Copy size={16} />}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<ScrollArea className='max-h-96 w-full overflow-auto'>
|
||||
<SyntaxHighlighter
|
||||
{...props}
|
||||
PreTag='div'
|
||||
language={match[1]}
|
||||
style={dark ? oneDark : oneLight}
|
||||
style={oneDark}
|
||||
showLineNumbers
|
||||
customStyle={{
|
||||
margin: 0,
|
||||
borderRadius: 0,
|
||||
}}
|
||||
>
|
||||
{String(children).replace(/\n$/, '')}
|
||||
</SyntaxHighlighter>
|
||||
</ScrollArea>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<code {...props} className={cn(className, 'bg-muted rounded border font-semibold')}>
|
||||
<code {...props} className={cn(className, 'rounded border font-semibold')}>
|
||||
{children}
|
||||
</code>
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user