Skip to content

Commit

Permalink
🎨 使用可选链
Browse files Browse the repository at this point in the history
  • Loading branch information
neila-a committed Apr 7, 2024
1 parent 30bf5e7 commit f3bc912
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 31 deletions.
11 changes: 4 additions & 7 deletions src/app/components/window/Window.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>(true),
} = props,
realSx: CSSProperties = props?.sx === undefined ? {} : props?.sx,
router = useRouter(),
[open, setOpen] = useState<boolean>(true),
nodeRef = useRef<HTMLDivElement>(null),
[size, setSize] = useState<[number, number]>([50, 50]), /* height, width */
[extension, setExtension] = useState<boolean>(false),
Expand Down
6 changes: 1 addition & 5 deletions src/app/index/Selects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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")), {
Expand Down
2 changes: 1 addition & 1 deletion src/app/loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Box sx={{
display: "flex",
Expand Down
18 changes: 7 additions & 11 deletions src/app/setting/extensions/DialogButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,14 @@ export default function DialogButtons(props: {
...props.fileInfo,
files: props.files
});
if (lists !== undefined) {
const index = lists.value.find(list => 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();
}}>
Expand Down
2 changes: 1 addition & 1 deletion src/app/tools/getToolColor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
Expand Down
8 changes: 2 additions & 6 deletions src/app/tools/jigsaw/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f3bc912

Please sign in to comment.