diff --git a/.husky/pre-commit b/.husky/pre-commit old mode 100644 new mode 100755 index fd92f4e77..e65f3812b --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,3 +1,13 @@ #!/bin/sh -pnpm run lint-fix \ No newline at end of file +pnpm run lint-fix + +# 将已暂存且被 lint-fix 修改过的文件重新加入暂存区 +STAGED=$(git diff --cached --name-only --diff-filter=d) +CHANGED=$(git diff --name-only) + +for file in $CHANGED; do + case "$STAGED" in + *"$file"*) git add "$file" ;; + esac +done diff --git a/.husky/pre-push b/.husky/pre-push old mode 100644 new mode 100755 diff --git a/src/pages/components/layout/MainLayout.tsx b/src/pages/components/layout/MainLayout.tsx index e2c670fbc..da09d41cf 100644 --- a/src/pages/components/layout/MainLayout.tsx +++ b/src/pages/components/layout/MainLayout.tsx @@ -119,6 +119,14 @@ const importByUrls = async (urls: string[]): Promise => return stat; }; +const getSafePopupParent = (p: Element) => { + p = (p.closest("button")?.parentNode as Element) || p; // 確保 ancestor 沒有 button 元素 + p = (p.closest("span")?.parentNode as Element) || p; // 確保 ancestor 沒有 span 元素 + p = (p.closest(".arco-collapse-item-content")?.parentNode as Element) || p; // 確保 ancestor 沒有 .arco-collapse-item-content 元素 + p = (p.closest("aside")?.parentNode as Element) || p; // 確保 ancestor 沒有 aside 元素 + return p; +}; + // --- 子组件:提取拖拽遮罩以优化性能 --- const DropzoneOverlay: React.FC<{ active: boolean; text: string }> = React.memo(({ active, text }) => { if (!active) return null; @@ -297,16 +305,12 @@ const MainLayout: React.FC<{ componentConfig={{ Select: { getPopupContainer: (node) => { - return node; + return getSafePopupParent(node as Element); }, }, }} getPopupContainer={(node) => { - let p = node.parentNode as Element; - p = (p.closest("button")?.parentNode as Element) || p; // 確保 ancestor 沒有 button 元素 - p = (p.closest("span")?.parentNode as Element) || p; // 確保 ancestor 沒有 span 元素 - p = (p.closest("aside")?.parentNode as Element) || p; // 確保 ancestor 沒有 aside 元素 - return p; + return getSafePopupParent(node.parentNode as Element); }} > {contextHolder} diff --git a/src/pages/options/routes/Logger.tsx b/src/pages/options/routes/Logger.tsx index 8cf1db927..93998300f 100644 --- a/src/pages/options/routes/Logger.tsx +++ b/src/pages/options/routes/Logger.tsx @@ -133,6 +133,7 @@ function LoggerPage() { style={{ width: 400 }} showTime shortcutsPlacementLeft + getPopupContainer={() => document.body} value={[startTime * 1000, endTime * 1000]} onChange={(_, time) => { setStartTime(time[0].unix());