From 12574cd7eed4afdbb890876e2a32529a22d107e3 Mon Sep 17 00:00:00 2001 From: Snowball_233 Date: Fri, 22 Dec 2023 00:36:13 +0800 Subject: [PATCH 1/6] format code --- app/about/layout.tsx | 2 + app/authenticate/components/check-code.tsx | 45 ++++---- app/authenticate/components/count-down.tsx | 20 ++-- .../components/password-robustness-list.tsx | 21 ++-- app/authenticate/hooks/useButton.ts | 40 +++---- app/authenticate/hooks/useCountDown.ts | 51 +++++---- app/authenticate/hooks/useType.ts | 20 ++-- app/authenticate/hooks/useValid.ts | 23 ++-- app/authenticate/page.tsx | 20 ++-- app/buy/layout.tsx | 4 +- app/buy/page.tsx | 2 +- app/dashboard/page.tsx | 60 +++++----- app/layout.tsx | 103 +++++++++--------- app/providers.tsx | 42 +++---- app/setting/hooks/use-shared-links.ts | 34 +++--- components/click-to-edit.tsx | 4 +- components/message.tsx | 6 +- components/password.tsx | 34 +++--- components/picture.tsx | 12 +- components/price.tsx | 6 +- components/share-table.tsx | 8 +- config/prices.tsx | 17 ++- interface/model/user.ts | 9 +- providers/http.ts | 16 +-- providers/index.ts | 6 +- providers/picture.ts | 1 + providers/user.ts | 45 +++++--- 27 files changed, 338 insertions(+), 313 deletions(-) diff --git a/app/about/layout.tsx b/app/about/layout.tsx index 78bbb74..53d5ddc 100644 --- a/app/about/layout.tsx +++ b/app/about/layout.tsx @@ -1,3 +1,5 @@ +import React from "react"; + export default function AboutLayout({children,}: { children: React.ReactNode; }) { diff --git a/app/authenticate/components/check-code.tsx b/app/authenticate/components/check-code.tsx index 495ccfc..5584347 100644 --- a/app/authenticate/components/check-code.tsx +++ b/app/authenticate/components/check-code.tsx @@ -1,45 +1,46 @@ 'use client' -import { useState } from "react"; +import {useState} from "react"; import IOC from "@/providers"; -import { Button } from "@nextui-org/react"; +import {Button} from "@nextui-org/react"; import CountDown from "./count-down"; -const CheckCode = (props: {type: 'email' | 'phone' | 'unknown', userInput: string}) => { +const CheckCode = (props: { type: 'email' | 'phone' | 'unknown', userInput: string }) => { const {type} = props; const [cd, setCD] = useState(0) const onCountdownFinish = () => { setCD(0) } const getCode = () => { - if (type === 'email'){ + if (type === 'email') { IOC.user.getCheckCodeByEmail(props.userInput) - .then((val)=>{ - setCD(val.data.cd + 1); - }) - .catch((err)=>{ - console.log(err); - setCD(60 * 1000); - }) + .then((val) => { + setCD(val.data.cd + 1); + }) + .catch((err) => { + console.log(err); + setCD(60 * 1000); + }) } - if (type === 'phone'){ + if (type === 'phone') { IOC.user.getCheckCodeByPhone(props.userInput) - .then((val)=>{ - setCD(val.data.cd + 1); - console.log(val.data.cd) - }) - .catch(()=>{ - setCD(60 * 1000); - }) + .then((val) => { + setCD(val.data.cd + 1); + console.log(val.data.cd) + }) + .catch(() => { + setCD(60 * 1000); + }) } } return ( - ) } -export default CheckCode; \ No newline at end of file +export default CheckCode; diff --git a/app/authenticate/components/count-down.tsx b/app/authenticate/components/count-down.tsx index f334b70..9bd1e00 100644 --- a/app/authenticate/components/count-down.tsx +++ b/app/authenticate/components/count-down.tsx @@ -1,26 +1,26 @@ 'use client' -import { useEffect, useRef, useState } from "react"; -import { useCountDown } from "../hooks" +import {useEffect, useState} from "react"; +import {useCountDown} from "../hooks" const CountDown = ( - props: {countDown: number, onFinish: () => void} + props: { countDown: number, onFinish: () => void } ) => { - const [cd, setCD] = useState( + const [cd] = useState( Number((props.countDown / 1000).toFixed()) ); const [time, start] = useCountDown(cd); - useEffect(()=>{ + useEffect(() => { start(); - },[]) - useEffect(()=>{ - if (time === 0){ + }, []) + useEffect(() => { + if (time === 0) { props.onFinish(); } - },[time, props]) + }, [time, props]) return ( {time}秒后重新获取 ) } -export default CountDown; \ No newline at end of file +export default CountDown; diff --git a/app/authenticate/components/password-robustness-list.tsx b/app/authenticate/components/password-robustness-list.tsx index b02b98c..f5a223a 100644 --- a/app/authenticate/components/password-robustness-list.tsx +++ b/app/authenticate/components/password-robustness-list.tsx @@ -1,6 +1,6 @@ -import { IoCheckmark, IoCloseSharp } from "react-icons/io5"; +import {IoCheckmark, IoCloseSharp} from "react-icons/io5"; -const PasswordRobustnessList = (props: {active: boolean[]}) => { +const PasswordRobustnessList = (props: { active: boolean[] }) => { const labels = [ { key: 'min', @@ -21,21 +21,22 @@ const PasswordRobustnessList = (props: {active: boolean[]}) => { return (