From 8a2fdf7c90d2c3f35e7eb63ca347034c6e5a33d6 Mon Sep 17 00:00:00 2001 From: fzk <458813868@qq.com> Date: Mon, 18 Nov 2024 10:25:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=8C=E7=BA=A7=E5=85=84?= =?UTF-8?q?=E5=BC=9F=E8=8A=82=E7=82=B9=E7=9A=84=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contents/custom.tsx | 51 +++++++++++++++++++++++++++++++++++++++++---- package.json | 2 +- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/contents/custom.tsx b/contents/custom.tsx index 54707e7..41d332f 100644 --- a/contents/custom.tsx +++ b/contents/custom.tsx @@ -3,6 +3,8 @@ import { CheckOutlined, CloseOutlined, DownSquareOutlined, + LeftSquareOutlined, + RightSquareOutlined, UpSquareOutlined } from "@ant-design/icons" import { Button, Flex, message, Modal } from "antd" @@ -49,7 +51,6 @@ let isSelect = false export default function CustomOverlay() { const [cssCode, runCss] = useCssCodeHook("custom") - const [closeLog] = useStorage("config-closeLog", true) const [content, setContent] = useContent() const [validTime, setValidTime] = useStorage("app-validTime", "1730390400") const [isCurrentDom, setIsCurrentDom] = useState(false) @@ -163,8 +164,8 @@ export default function CustomOverlay() { const rect = currentDom.getBoundingClientRect() const distanceTop = rect.top + window.scrollY const distanceLeft = rect.left + window.scrollX - const top = distanceTop < 50 ? distanceTop + 10 : distanceTop - 40 - const left = distanceLeft + 10 + const top = distanceTop < 50 ? distanceTop + 15 : distanceTop - 40 + const left = distanceLeft + 5 setRect({ top, left }) scrollToTop(currentDom) @@ -277,6 +278,28 @@ export default function CustomOverlay() { event.stopPropagation() } + function handleSetPrev(event) { + const currentDom = document.querySelector(".codebox-current") + const previousSibling = currentDom.previousElementSibling + if (previousSibling) { + removeCurrentDom() + previousSibling.classList.add("codebox-current") + setTooltip() + } + event.stopPropagation() + } + + function handleSetNext(event) { + const currentDom = document.querySelector(".codebox-current") + const nextSibling = currentDom.nextElementSibling + if (nextSibling) { + removeCurrentDom() + nextSibling.classList.add("codebox-current") + setTooltip() + } + event.stopPropagation() + } + return ( {contextHolder} @@ -288,7 +311,7 @@ export default function CustomOverlay() { position: "absolute", top: `${rect.top}px`, left: `${rect.left}px`, - width: "390px", + width: "520px", background: "#fff", border: "1px solid #eee", borderRadius: "5px" @@ -297,6 +320,7 @@ export default function CustomOverlay() { + +