feat: PC端指数排序
This commit is contained in:
@@ -317,8 +317,8 @@ export default function MarketIndexAccordion({
|
|||||||
position: 'sticky',
|
position: 'sticky',
|
||||||
top: topMargin,
|
top: topMargin,
|
||||||
zIndex: 10,
|
zIndex: 10,
|
||||||
width: 'calc(100% + 24px)',
|
width: isMobile ? 'calc(100% + 24px)' : '100%',
|
||||||
marginLeft: -12,
|
marginLeft: isMobile ? -12 : 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (loading && indices.length === 0) {
|
if (loading && indices.length === 0) {
|
||||||
@@ -454,7 +454,11 @@ export default function MarketIndexAccordion({
|
|||||||
{visibleIndices.map((item, i) => (
|
{visibleIndices.map((item, i) => (
|
||||||
<div
|
<div
|
||||||
key={item.code || i}
|
key={item.code || i}
|
||||||
style={{ flex: '0 0 calc((100% - 24px) / 3)' }}
|
style={{
|
||||||
|
flex: isMobile
|
||||||
|
? '0 0 calc((100% - 24px) / 3)'
|
||||||
|
: '0 0 calc((100% - 48px) / 5)',
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<IndexCard item={item} />
|
<IndexCard item={item} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { AnimatePresence } from "framer-motion";
|
import { createPortal } from "react-dom";
|
||||||
|
import { AnimatePresence, motion } from "framer-motion";
|
||||||
import {
|
import {
|
||||||
DndContext,
|
DndContext,
|
||||||
KeyboardSensor,
|
KeyboardSensor,
|
||||||
@@ -25,18 +26,11 @@ import {
|
|||||||
DrawerTitle,
|
DrawerTitle,
|
||||||
DrawerClose,
|
DrawerClose,
|
||||||
} from "@/components/ui/drawer";
|
} from "@/components/ui/drawer";
|
||||||
import {
|
|
||||||
Dialog,
|
|
||||||
DialogContent,
|
|
||||||
DialogHeader,
|
|
||||||
DialogTitle,
|
|
||||||
DialogClose,
|
|
||||||
} from "@/components/ui/dialog";
|
|
||||||
import { CloseIcon, MinusIcon, ResetIcon, SettingsIcon } from "./Icons";
|
import { CloseIcon, MinusIcon, ResetIcon, SettingsIcon } from "./Icons";
|
||||||
import ConfirmModal from "./ConfirmModal";
|
import ConfirmModal from "./ConfirmModal";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
function SortableIndexItem({ item, canRemove, onRemove }) {
|
function SortableIndexItem({ item, canRemove, onRemove, isMobile }) {
|
||||||
const {
|
const {
|
||||||
attributes,
|
attributes,
|
||||||
listeners,
|
listeners,
|
||||||
@@ -50,7 +44,9 @@ function SortableIndexItem({ item, canRemove, onRemove }) {
|
|||||||
transform: CSS.Transform.toString(transform),
|
transform: CSS.Transform.toString(transform),
|
||||||
transition,
|
transition,
|
||||||
cursor: isDragging ? "grabbing" : "grab",
|
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",
|
touchAction: "none",
|
||||||
...(isDragging && {
|
...(isDragging && {
|
||||||
position: "relative",
|
position: "relative",
|
||||||
@@ -164,6 +160,19 @@ export default function MarketSettingModal({
|
|||||||
|
|
||||||
const [resetConfirmOpen, setResetConfirmOpen] = useState(false);
|
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(
|
const sensors = useSensors(
|
||||||
useSensor(PointerSensor, { activationConstraint: { distance: 5 } }),
|
useSensor(PointerSensor, { activationConstraint: { distance: 5 } }),
|
||||||
useSensor(KeyboardSensor)
|
useSensor(KeyboardSensor)
|
||||||
@@ -244,6 +253,7 @@ export default function MarketSettingModal({
|
|||||||
item={item}
|
item={item}
|
||||||
canRemove={selectedCodes.length > 1}
|
canRemove={selectedCodes.length > 1}
|
||||||
onRemove={handleToggleCode}
|
onRemove={handleToggleCode}
|
||||||
|
isMobile={isMobile}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -390,45 +400,53 @@ export default function MarketSettingModal({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
const pcContent = (
|
||||||
<Dialog
|
<AnimatePresence>
|
||||||
open={open}
|
{open && (
|
||||||
onOpenChange={(v) => {
|
<motion.div
|
||||||
if (!v) onClose?.();
|
key="market-index-setting-overlay"
|
||||||
}}
|
className="pc-table-setting-overlay"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-label="指数个性化设置"
|
||||||
|
initial={{ opacity: 0 }}
|
||||||
|
animate={{ opacity: 1 }}
|
||||||
|
exit={{ opacity: 0 }}
|
||||||
|
transition={{ duration: 0.2 }}
|
||||||
|
onClick={onClose}
|
||||||
|
style={{ zIndex: 10001 }}
|
||||||
>
|
>
|
||||||
<DialogContent
|
<motion.aside
|
||||||
className="!p-0 max-w-xl"
|
className="pc-market-setting-drawer pc-table-setting-drawer glass"
|
||||||
overlayClassName="modal-overlay"
|
initial={{ x: "100%" }}
|
||||||
showCloseButton={false}
|
animate={{ x: 0 }}
|
||||||
|
exit={{ x: "100%" }}
|
||||||
|
transition={{ type: "spring", damping: 30, stiffness: 300 }}
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
style={{ width: 690 }}
|
||||||
>
|
>
|
||||||
<div className="glass card modal">
|
<div className="pc-table-setting-header">
|
||||||
<DialogHeader
|
<div style={{ display: "flex", alignItems: "center", gap: 10 }}>
|
||||||
className="flex flex-row items-center justify-between gap-2 mb-3"
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-2.5">
|
|
||||||
<SettingsIcon width="20" height="20" />
|
<SettingsIcon width="20" height="20" />
|
||||||
<DialogTitle>指数个性化设置</DialogTitle>
|
<span>指数个性化设置</span>
|
||||||
</div>
|
</div>
|
||||||
<DialogClose asChild>
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="icon-button border-none bg-transparent p-1"
|
className="icon-button"
|
||||||
|
onClick={onClose}
|
||||||
title="关闭"
|
title="关闭"
|
||||||
|
style={{ border: "none", background: "transparent" }}
|
||||||
>
|
>
|
||||||
<CloseIcon width="20" height="20" />
|
<CloseIcon width="20" height="20" />
|
||||||
</button>
|
</button>
|
||||||
</DialogClose>
|
|
||||||
</DialogHeader>
|
|
||||||
<div
|
|
||||||
className="flex flex-col gap-4"
|
|
||||||
style={{ maxHeight: "70vh", overflowY: "auto" }}
|
|
||||||
>
|
|
||||||
{body}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div className="pc-table-setting-body">{body}</div>
|
||||||
|
</motion.aside>
|
||||||
|
</motion.div>
|
||||||
|
)}
|
||||||
{resetConfirmOpen && (
|
{resetConfirmOpen && (
|
||||||
<ConfirmModal
|
<ConfirmModal
|
||||||
|
key="pc-index-reset-confirm"
|
||||||
title="恢复默认指数"
|
title="恢复默认指数"
|
||||||
message="是否恢复已添加指数为默认配置?"
|
message="是否恢复已添加指数为默认配置?"
|
||||||
icon={
|
icon={
|
||||||
@@ -447,8 +465,10 @@ export default function MarketSettingModal({
|
|||||||
onCancel={() => setResetConfirmOpen(false)}
|
onCancel={() => setResetConfirmOpen(false)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</DialogContent>
|
</AnimatePresence>
|
||||||
</Dialog>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (typeof document === "undefined") return null;
|
||||||
|
return createPortal(pcContent, document.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2032,6 +2032,11 @@ input[type="number"] {
|
|||||||
box-shadow: -8px 0 32px rgba(0, 0, 0, 0.3);
|
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 {
|
.pc-table-setting-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
Reference in New Issue
Block a user