feat: 排序个性化新增排序形式切换
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog';
|
||||
import { Progress } from '@/components/ui/progress';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import ConfirmModal from './ConfirmModal';
|
||||
import { ResetIcon, SettingsIcon } from './Icons';
|
||||
|
||||
@@ -19,10 +20,13 @@ export default function SettingsModal({
|
||||
containerWidth = 1200,
|
||||
setContainerWidth,
|
||||
onResetContainerWidth,
|
||||
showMarketIndex = true,
|
||||
setShowMarketIndex,
|
||||
}) {
|
||||
const [sliderDragging, setSliderDragging] = useState(false);
|
||||
const [resetWidthConfirmOpen, setResetWidthConfirmOpen] = useState(false);
|
||||
const [localSeconds, setLocalSeconds] = useState(tempSeconds);
|
||||
const [localShowMarketIndex, setLocalShowMarketIndex] = useState(showMarketIndex);
|
||||
const pageWidthTrackRef = useRef(null);
|
||||
|
||||
const clampedWidth = Math.min(2000, Math.max(600, Number(containerWidth) || 1200));
|
||||
@@ -55,6 +59,10 @@ export default function SettingsModal({
|
||||
setLocalSeconds(tempSeconds);
|
||||
}, [tempSeconds]);
|
||||
|
||||
useEffect(() => {
|
||||
setLocalShowMarketIndex(showMarketIndex);
|
||||
}, [showMarketIndex]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open
|
||||
@@ -162,6 +170,22 @@ export default function SettingsModal({
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div hidden className="form-group" style={{ marginBottom: 16 }}>
|
||||
<div className="muted" style={{ marginBottom: 8, fontSize: '0.8rem' }}>显示大盘指数</div>
|
||||
<div className="row" style={{ justifyContent: 'flex-start', alignItems: 'center' }}>
|
||||
<Switch
|
||||
checked={localShowMarketIndex}
|
||||
className="ml-2 scale-125"
|
||||
onCheckedChange={(checked) => {
|
||||
const nextValue = Boolean(checked);
|
||||
setLocalShowMarketIndex(nextValue);
|
||||
setShowMarketIndex?.(nextValue);
|
||||
}}
|
||||
aria-label="显示大盘指数"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="form-group" style={{ marginBottom: 16 }}>
|
||||
<div className="muted" style={{ marginBottom: 8, fontSize: '0.8rem' }}>数据导出</div>
|
||||
<div className="row" style={{ gap: 8 }}>
|
||||
@@ -188,7 +212,7 @@ export default function SettingsModal({
|
||||
<div className="row" style={{ justifyContent: 'flex-end', marginTop: 24 }}>
|
||||
<button
|
||||
className="button"
|
||||
onClick={(e) => saveSettings(e, localSeconds)}
|
||||
onClick={(e) => saveSettings(e, localSeconds, localShowMarketIndex)}
|
||||
disabled={localSeconds < 30}
|
||||
>
|
||||
保存并关闭
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
DrawerTitle,
|
||||
DrawerClose,
|
||||
} from "@/components/ui/drawer";
|
||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||
import { CloseIcon, DragIcon, ResetIcon, SettingsIcon } from "./Icons";
|
||||
import ConfirmModal from "./ConfirmModal";
|
||||
|
||||
@@ -33,6 +34,8 @@ export default function SortSettingModal({
|
||||
rules = [],
|
||||
onChangeRules,
|
||||
onResetRules,
|
||||
sortDisplayMode = "buttons",
|
||||
onChangeSortDisplayMode,
|
||||
}) {
|
||||
const [localRules, setLocalRules] = useState(rules);
|
||||
const [editingId, setEditingId] = useState(null);
|
||||
@@ -120,6 +123,59 @@ export default function SortSettingModal({
|
||||
: "pc-table-setting-body"
|
||||
}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
gap: 12,
|
||||
marginBottom: 16,
|
||||
}}
|
||||
>
|
||||
<h3
|
||||
className="pc-table-setting-subtitle"
|
||||
style={{ margin: 0, fontSize: 14 }}
|
||||
>
|
||||
排序形式
|
||||
</h3>
|
||||
<div style={{ display: "flex", justifyContent: "flex-end", marginLeft: "auto" }}>
|
||||
<RadioGroup
|
||||
value={sortDisplayMode}
|
||||
onValueChange={(value) => onChangeSortDisplayMode?.(value)}
|
||||
className="flex flex-row items-center gap-4"
|
||||
>
|
||||
<label
|
||||
htmlFor="sort-display-mode-buttons"
|
||||
style={{
|
||||
display: "inline-flex",
|
||||
alignItems: "center",
|
||||
gap: 6,
|
||||
fontSize: 13,
|
||||
color: "var(--text)",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
>
|
||||
<RadioGroupItem id="sort-display-mode-buttons" value="buttons" />
|
||||
<span>按钮</span>
|
||||
</label>
|
||||
<label
|
||||
htmlFor="sort-display-mode-dropdown"
|
||||
style={{
|
||||
display: "inline-flex",
|
||||
alignItems: "center",
|
||||
gap: 6,
|
||||
fontSize: 13,
|
||||
color: "var(--text)",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
>
|
||||
<RadioGroupItem id="sort-display-mode-dropdown" value="dropdown" />
|
||||
<span>下拉单选</span>
|
||||
</label>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
|
||||
Reference in New Issue
Block a user