From f3bc912b0d936099e2f2ba64f5f4860700a47612 Mon Sep 17 00:00:00 2001 From: Neila Date: Sun, 7 Apr 2024 16:13:21 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20=E4=BD=BF=E7=94=A8=E5=8F=AF?= =?UTF-8?q?=E9=80=89=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/components/window/Window.tsx | 11 ++++------- src/app/index/Selects.tsx | 6 +----- src/app/loading.tsx | 2 +- src/app/setting/extensions/DialogButtons.tsx | 18 +++++++----------- src/app/tools/getToolColor.tsx | 2 +- src/app/tools/jigsaw/page.tsx | 8 ++------ 6 files changed, 16 insertions(+), 31 deletions(-) diff --git a/src/app/components/window/Window.tsx b/src/app/components/window/Window.tsx index 8b0c4ae1..0d6db603 100644 --- a/src/app/components/window/Window.tsx +++ b/src/app/components/window/Window.tsx @@ -42,13 +42,10 @@ export interface WindowOptions { export default function Window(props: WindowOptions): JSX.Element { const { id - } = props; - var realSx: CSSProperties = {}; - const router = useRouter(); - if (props.sx !== undefined) { - realSx = props.sx; - } - const [open, setOpen] = useState(true), + } = props, + realSx: CSSProperties = props?.sx === undefined ? {} : props?.sx, + router = useRouter(), + [open, setOpen] = useState(true), nodeRef = useRef(null), [size, setSize] = useState<[number, number]>([50, 50]), /* height, width */ [extension, setExtension] = useState(false), diff --git a/src/app/index/Selects.tsx b/src/app/index/Selects.tsx index f5603952..8e549b26 100644 --- a/src/app/index/Selects.tsx +++ b/src/app/index/Selects.tsx @@ -171,11 +171,7 @@ export default function Selects(props: { setRemoveDialogOpen, setList, left: gotToolsList.filter(tool => { - const found = list.find(single => single[0] === dialogListName); - if (found !== undefined) { - return found[1].includes(tool.to); - } - return false; + return list.find(single => single[0] === dialogListName)?.[1]?.includes(tool.to); }).map(tool => tool.name) })} {createElement(dynamic(() => import("dialog/Check")), { diff --git a/src/app/loading.tsx b/src/app/loading.tsx index 0559277e..97a4d803 100644 --- a/src/app/loading.tsx +++ b/src/app/loading.tsx @@ -9,7 +9,7 @@ import Image from "next/image"; export default function Loading(props: { children?: ReactNode; }) { - var isLoading = props.children === undefined; + const isLoading = props.children === undefined; return ( list[0] === "__global__"), to = `/tools/extension?tool=${props.fileInfo.to}`; - if (index !== undefined) { - if (!index[1].includes(to)) { - lists.set(lists.value.map(singleList => { - if (singleList[0] === "__global__") { - return [singleList[0], [...singleList[1], to]]; - } - return singleList; - })); + const index = lists?.value.find(list => list[0] === "__global__"), to = `/tools/extension?tool=${props.fileInfo.to}`; + if (!index?.[1].includes(to)) { + lists.set(lists.value.map(singleList => { + if (singleList[0] === "__global__") { + return [singleList[0], [...singleList[1], to]]; } - } + return singleList; + })); } props.reset(); }}> diff --git a/src/app/tools/getToolColor.tsx b/src/app/tools/getToolColor.tsx index da9dfcd6..4eb79278 100644 --- a/src/app/tools/getToolColor.tsx +++ b/src/app/tools/getToolColor.tsx @@ -8,7 +8,7 @@ import { export default function getToolColor(toolsInfo: tool[], toolID: string) { const tool = toolsInfo.find(si => si.to === toolID); if (tool !== undefined) { - const tColor: [Hex.Hex, Hex.Hex] = tool.color; + const tColor = tool.color; return `linear-gradient(45deg, #${tColor[0]}, #${tColor[1]})`; } return ""; diff --git a/src/app/tools/jigsaw/page.tsx b/src/app/tools/jigsaw/page.tsx index e7f77f3b..cc4777e3 100644 --- a/src/app/tools/jigsaw/page.tsx +++ b/src/app/tools/jigsaw/page.tsx @@ -300,12 +300,8 @@ export default function JigsawEntry(): JSX.Element { }); return old; } - if (n.blocks[indexb1] !== null && n.blocks[indexb1] !== undefined) { - if (n.blocks[indexb1][indexc1] !== null) { - return n.blocks[indexb1][indexc1]; - } - } - })) + return n.blocks?.[indexb1]?.[indexc1]; + })).filter(item => item !== undefined) }, booleans = await Promise.all(jigsaws.map(async jigsaw => await blobToInt8Array(jigsaw.all) === await blobToInt8Array(imageFile))), index = booleans.indexOf(true);