refactor: 优化eslint配置,提升代码质量 (#1341)

* feat: 统一并标准化eslint

* lint: napcat.webui

* lint: napcat.webui

* lint: napcat.core

* build: fix

* lint: napcat.webui

* refactor: 重构eslint

* Update README.md
This commit is contained in:
时瑾 authored and GitHub committed 2025-11-03 16:30:45 +08:00
1 parent d5b8f886d6
commit 06f6a542f5
651 files changed
+37978 -37584

No files matched your search

@@ -1,44 +1,44 @@
import { Button } from '@heroui/button'
import { Input } from '@heroui/input'
import { useRef, useState } from 'react'
import { Button } from '@heroui/button';
import { Input } from '@heroui/input';
import { useRef, useState } from 'react';
export interface FileInputProps {
onChange: (file: File) => Promise<void> | void
onDelete?: () => Promise<void> | void
label?: string
accept?: string
onChange: (file: File) => Promise<void> | void;
onDelete?: () => Promise<void> | void;
label?: string;
accept?: string;
}
const FileInput: React.FC<FileInputProps> = ({
onChange,
onDelete,
label,
accept
accept,
}) => {
const inputRef = useRef<HTMLInputElement>(null)
const [isLoading, setIsLoading] = useState(false)
const inputRef = useRef<HTMLInputElement>(null);
const [isLoading, setIsLoading] = useState(false);
return (
<div className="flex items-end gap-2">
<div className="flex-grow">
<div className='flex items-end gap-2'>
<div className='flex-grow'>
<Input
isDisabled={isLoading}
ref={inputRef}
label={label}
type="file"
placeholder="选择文件"
type='file'
placeholder='选择文件'
accept={accept}
onChange={async (e) => {
try {
setIsLoading(true)
const file = e.target.files?.[0]
setIsLoading(true);
const file = e.target.files?.[0];
if (file) {
await onChange(file)
await onChange(file);
}
} catch (error) {
console.error(error)
console.error(error);
} finally {
setIsLoading(false)
if (inputRef.current) inputRef.current.value = ''
setIsLoading(false);
if (inputRef.current) inputRef.current.value = '';
}
}}
/>
@@ -47,23 +47,23 @@ const FileInput: React.FC<FileInputProps> = ({
isDisabled={isLoading}
onPress={async () => {
try {
setIsLoading(true)
if (onDelete) await onDelete()
setIsLoading(true);
if (onDelete) await onDelete();
} catch (error) {
console.error(error)
console.error(error);
} finally {
setIsLoading(false)
if (inputRef.current) inputRef.current.value = ''
setIsLoading(false);
if (inputRef.current) inputRef.current.value = '';
}
}}
color="primary"
variant="flat"
size="sm"
color='primary'
variant='flat'
size='sm'
>
删除
</Button>
</div>
)
}
);
};
export default FileInput
export default FileInput;
@@ -1,7 +1,7 @@
import { Button } from '@heroui/button'
import { Image } from '@heroui/image'
import { Input } from '@heroui/input'
import { useRef } from 'react'
import { Button } from '@heroui/button';
import { Image } from '@heroui/image';
import { Input } from '@heroui/input';
import { useRef } from 'react';
export interface ImageInputProps {
onChange: (base64: string) => void
@@ -10,47 +10,47 @@ export interface ImageInputProps {
}
const ImageInput: React.FC<ImageInputProps> = ({ onChange, value, label }) => {
const inputRef = useRef<HTMLInputElement>(null)
const inputRef = useRef<HTMLInputElement>(null);
return (
<div className="flex items-end gap-2">
<div className="w-5 h-5 flex-shrink-0">
<div className='flex items-end gap-2'>
<div className='w-5 h-5 flex-shrink-0'>
<Image
src={value}
alt={label}
className="w-5 h-5 flex-shrink-0 rounded-none"
className='w-5 h-5 flex-shrink-0 rounded-none'
/>
</div>
<Input
ref={inputRef}
label={label}
type="file"
placeholder="选择图片"
accept="image/*"
type='file'
placeholder='选择图片'
accept='image/*'
onChange={async (e) => {
const file = e.target.files?.[0]
const file = e.target.files?.[0];
if (file) {
const reader = new FileReader()
const reader = new FileReader();
reader.onload = async () => {
const base64 = reader.result as string
onChange(base64)
}
reader.readAsDataURL(file)
const base64 = reader.result as string;
onChange(base64);
};
reader.readAsDataURL(file);
}
}}
/>
<Button
onPress={() => {
onChange('')
if (inputRef.current) inputRef.current.value = ''
onChange('');
if (inputRef.current) inputRef.current.value = '';
}}
color="primary"
variant="flat"
size="sm"
color='primary'
variant='flat'
size='sm'
>
删除
</Button>
</div>
)
}
);
};
export default ImageInput
export default ImageInput;