diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..009b3f8 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +pnpm lint diff --git a/eslint.config.mjs b/eslint.config.mjs index 56ab80b..e4e9331 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -26,6 +26,7 @@ const eslintConfig = [ '@stylistic/jsx-closing-bracket-location': 'off', '@stylistic/jsx-curly-newline': 'off', '@stylistic/multiline-ternary': 'off', + '@stylistic/block-spacing': 'off', '@typescript-eslint/no-empty-object-type': 'off', '@typescript-eslint/no-unused-vars': 'off', }, diff --git a/package.json b/package.json index 750b44e..00b5d34 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "dev": "next dev -H 0.0.0.0 --turbo", "build": "next build", "start": "next start", - "lint": "next lint" + "lint": "next lint --fix", + "prepare": "husky" }, "dependencies": { "@hookform/resolvers": "^4.1.3", @@ -62,6 +63,7 @@ "eslint": "^9", "eslint-config-next": "15.2.1", "eslint-plugin-react-hooks": "^5.2.0", + "husky": "^9.1.7", "tailwindcss": "^4", "typescript": "^5" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9e885dc..cb783b9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -165,6 +165,9 @@ importers: eslint-plugin-react-hooks: specifier: ^5.2.0 version: 5.2.0(eslint@9.21.0(jiti@2.4.2)) + husky: + specifier: ^9.1.7 + version: 9.1.7 tailwindcss: specifier: ^4 version: 4.0.9 @@ -2348,6 +2351,11 @@ packages: hast-util-whitespace@3.0.0: resolution: {integrity: sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==} + husky@9.1.7: + resolution: {integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==} + engines: {node: '>=18'} + hasBin: true + ieee754@1.2.1: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} @@ -5873,6 +5881,8 @@ snapshots: dependencies: '@types/hast': 3.0.4 + husky@9.1.7: {} + ieee754@1.2.1: {} ignore@5.3.2: {} diff --git a/src/actions/auth.ts b/src/actions/auth.ts index c7d90a8..f8c0db6 100644 --- a/src/actions/auth.ts +++ b/src/actions/auth.ts @@ -17,7 +17,6 @@ export async function login(props: { password: string remember: boolean }): Promise { - // 尝试登录 const result = await callByDevice('/api/auth/token', { ...props, diff --git a/src/actions/whitelist.ts b/src/actions/whitelist.ts index 4816128..aba47cd 100644 --- a/src/actions/whitelist.ts +++ b/src/actions/whitelist.ts @@ -1,6 +1,6 @@ 'use server' -import { PageRecord} from '@/lib/api' -import { callByUser } from '@/actions/base' +import {PageRecord} from '@/lib/api' +import {callByUser} from '@/actions/base' type Whitelist = { id: number diff --git a/src/app/(api)/identify/callback/page.tsx b/src/app/(api)/identify/callback/page.tsx index 0848c91..e14b907 100644 --- a/src/app/(api)/identify/callback/page.tsx +++ b/src/app/(api)/identify/callback/page.tsx @@ -15,7 +15,7 @@ export default function Page(props: PageProps) { ) } - function Page1() { +function Page1() { const params = useSearchParams() const success = params.get('success') === 'true' const id = params.get('id') || '' @@ -27,7 +27,7 @@ export default function Page(props: PageProps) { useEffect(() => { if (success) { - IdentifyCallback({id}).then(resp => { + IdentifyCallback({id}).then((resp) => { if (!resp.success) { setResult({ status: 'fail', @@ -55,28 +55,34 @@ export default function Page(props: PageProps) { }, []) return ( -
+
- {result.status === 'load' ? (<> - -

{result.message}

-

- 请保持网络畅通 -

- ) : result.status === 'done' ? (<> - -

{result.message}

-

- 认证已完成,您现在可以关闭此页面 -

- ) : (<> - -

{result.message}

-

- 认证失败,请重新发起认证 -

- )} + {result.status === 'load' ? ( + <> + +

{result.message}

+

+ 请保持网络畅通 +

+ + ) : result.status === 'done' ? ( + <> + +

{result.message}

+

+ 认证已完成,您现在可以关闭此页面 +

+ + ) : ( + <> + +

{result.message}

+

+ 认证失败,请重新发起认证 +

+ + )}
diff --git a/src/app/(api)/proxies/route.ts b/src/app/(api)/proxies/route.ts index a227550..728ea3b 100644 --- a/src/app/(api)/proxies/route.ts +++ b/src/app/(api)/proxies/route.ts @@ -50,7 +50,7 @@ export async function GET(req: NextRequest) { const body = JSON.stringify(params) return NextResponse.json(body) case 'text': - const text = result.data.map(item => { + const text = result.data.map((item) => { const list = [item.host, item.port] if (item.username && item.password) { list.push(item.username) diff --git a/src/app/(auth)/captcha/route.ts b/src/app/(auth)/captcha/route.ts index 44601ee..71bb53e 100644 --- a/src/app/(auth)/captcha/route.ts +++ b/src/app/(auth)/captcha/route.ts @@ -14,7 +14,7 @@ function generateCaptchaText(length: number = 4): string { } // 哈希验证码文本并使用随机盐值 -function hashCaptcha(text: string): { hash: string, salt: string } { +function hashCaptcha(text: string): {hash: string, salt: string} { const salt = crypto.randomBytes(16).toString('hex') const hash = crypto .createHmac('sha256', salt) diff --git a/src/app/(auth)/login/captcha.tsx b/src/app/(auth)/login/captcha.tsx index 643819b..0caf05d 100644 --- a/src/app/(auth)/login/captcha.tsx +++ b/src/app/(auth)/login/captcha.tsx @@ -63,7 +63,7 @@ export default function Captcha(props: CaptchaProps) { setCaptchaCode(e.target.value)} + onChange={e => setCaptchaCode(e.target.value)} className="w-full" />
diff --git a/src/app/(auth)/login/layout.tsx b/src/app/(auth)/login/layout.tsx index 30c3605..aef625d 100644 --- a/src/app/(auth)/login/layout.tsx +++ b/src/app/(auth)/login/layout.tsx @@ -1,6 +1,5 @@ - -import { ReactNode } from 'react' -import { Metadata } from 'next' +import {ReactNode} from 'react' +import {Metadata} from 'next' export async function generateMetadata(): Promise { return { @@ -9,9 +8,9 @@ export async function generateMetadata(): Promise { } export type LoginLayoutProps = { - children: ReactNode + children: ReactNode } export default async function LoginLayout(props: LoginLayoutProps) { return props.children -} \ No newline at end of file +} diff --git a/src/app/(auth)/login/page.tsx b/src/app/(auth)/login/page.tsx index 450eaf4..23de5d6 100644 --- a/src/app/(auth)/login/page.tsx +++ b/src/app/(auth)/login/page.tsx @@ -193,7 +193,7 @@ export default function LoginPage(props: LoginPageProps) { const params = useSearchParams() const redirect = params.get('redirect') - const refreshProfile = useProfileStore(store=>store.refreshProfile) + const refreshProfile = useProfileStore(store => store.refreshProfile) // ====================== // render @@ -205,9 +205,9 @@ export default function LoginPage(props: LoginPageProps) { `h-screen w-screen xl:pr-64 bg-cover bg-left`, `flex justify-center xl:justify-end items-center`, )}> - {`背景图`} + 背景图 - {`logo`} + logo {/* 登录表单 */} @@ -215,9 +215,9 @@ export default function LoginPage(props: LoginPageProps) { 登录/注册 - + className="space-y-6" onSubmit={onSubmit} form={form}> - + {({id, field}) => ( - + {({id, field}) => (

- 登录即表示您同意《用户协议》《隐私政策》 + 登录即表示您同意 + 《用户协议》 + 和 + 《隐私政策》

diff --git a/src/app/(home)/@footer/page.tsx b/src/app/(home)/@footer/page.tsx index 60088c4..a5dcc54 100644 --- a/src/app/(home)/@footer/page.tsx +++ b/src/app/(home)/@footer/page.tsx @@ -6,24 +6,24 @@ export default function Footer(props: FooterProps) { return (