diff --git a/app/components/MarketIndexAccordion.jsx b/app/components/MarketIndexAccordion.jsx index 10af6e6..26ddfe5 100644 --- a/app/components/MarketIndexAccordion.jsx +++ b/app/components/MarketIndexAccordion.jsx @@ -317,8 +317,8 @@ export default function MarketIndexAccordion({ position: 'sticky', top: topMargin, zIndex: 10, - width: 'calc(100% + 24px)', - marginLeft: -12, + width: isMobile ? 'calc(100% + 24px)' : '100%', + marginLeft: isMobile ? -12 : 0, }; if (loading && indices.length === 0) { @@ -454,7 +454,11 @@ export default function MarketIndexAccordion({ {visibleIndices.map((item, i) => (
diff --git a/app/components/MarketSettingModal.jsx b/app/components/MarketSettingModal.jsx index 9ad9ccf..9f7bd68 100644 --- a/app/components/MarketSettingModal.jsx +++ b/app/components/MarketSettingModal.jsx @@ -1,7 +1,8 @@ "use client"; -import { useMemo, useState } from "react"; -import { AnimatePresence } from "framer-motion"; +import { useEffect, useMemo, useState } from "react"; +import { createPortal } from "react-dom"; +import { AnimatePresence, motion } from "framer-motion"; import { DndContext, KeyboardSensor, @@ -25,18 +26,11 @@ import { DrawerTitle, DrawerClose, } from "@/components/ui/drawer"; -import { - Dialog, - DialogContent, - DialogHeader, - DialogTitle, - DialogClose, -} from "@/components/ui/dialog"; import { CloseIcon, MinusIcon, ResetIcon, SettingsIcon } from "./Icons"; import ConfirmModal from "./ConfirmModal"; import { cn } from "@/lib/utils"; -function SortableIndexItem({ item, canRemove, onRemove }) { +function SortableIndexItem({ item, canRemove, onRemove, isMobile }) { const { attributes, listeners, @@ -50,7 +44,9 @@ function SortableIndexItem({ item, canRemove, onRemove }) { transform: CSS.Transform.toString(transform), transition, cursor: isDragging ? "grabbing" : "grab", - flex: "0 0 calc((100% - 24px) / 3)", + flex: isMobile + ? "0 0 calc((100% - 24px) / 3)" + : "0 0 calc((100% - 48px) / 5)", touchAction: "none", ...(isDragging && { position: "relative", @@ -164,6 +160,19 @@ export default function MarketSettingModal({ const [resetConfirmOpen, setResetConfirmOpen] = useState(false); + useEffect(() => { + if (!open) setResetConfirmOpen(false); + }, [open]); + + useEffect(() => { + if (!open) return; + const prev = document.body.style.overflow; + document.body.style.overflow = "hidden"; + return () => { + document.body.style.overflow = prev; + }; + }, [open]); + const sensors = useSensors( useSensor(PointerSensor, { activationConstraint: { distance: 5 } }), useSensor(KeyboardSensor) @@ -244,6 +253,7 @@ export default function MarketSettingModal({ item={item} canRemove={selectedCodes.length > 1} onRemove={handleToggleCode} + isMobile={isMobile} /> ))} @@ -390,65 +400,75 @@ export default function MarketSettingModal({ ); } - return ( - { - if (!v) onClose?.(); - }} - > - -
- + {open && ( + + e.stopPropagation()} + style={{ width: 690 }} > -
- - 指数个性化设置 -
- +
+
+ + 指数个性化设置 +
- - -
- {body} -
-
- {resetConfirmOpen && ( - - } - confirmVariant="primary" - confirmText="恢复默认" - onConfirm={() => { - onResetDefault?.(); - setResetConfirmOpen(false); - }} - onCancel={() => setResetConfirmOpen(false)} - /> - )} - -
+ +
{body}
+ + + )} + {resetConfirmOpen && ( + + } + confirmVariant="primary" + confirmText="恢复默认" + onConfirm={() => { + onResetDefault?.(); + setResetConfirmOpen(false); + }} + onCancel={() => setResetConfirmOpen(false)} + /> + )} + ); + + if (typeof document === "undefined") return null; + return createPortal(pcContent, document.body); } diff --git a/app/globals.css b/app/globals.css index d65a052..99dc86f 100644 --- a/app/globals.css +++ b/app/globals.css @@ -2032,6 +2032,11 @@ input[type="number"] { box-shadow: -8px 0 32px rgba(0, 0, 0, 0.3); } +/* 指数个性化设置侧弹框:加宽以一行展示 5 个指数卡片 */ +.pc-market-setting-drawer.pc-table-setting-drawer { + width: 560px; +} + .pc-table-setting-header { display: flex; align-items: center;