This commit is contained in:
2026-06-29 18:26:06 +08:00
parent 13970941d5
commit 63c2f0fb33
3 changed files with 36 additions and 14 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -28,7 +28,7 @@
}
})();
</script>
<script type="module" crossorigin src="/assets/index-D1wOjhOn.js"></script>
<script type="module" crossorigin src="/assets/index-Qg4hmCnl.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-D3IaMBsq.css">
</head>
<body>
@@ -146,9 +146,13 @@ const AppLayout: React.FC = () => {
const [contactHovered, setContactHovered] = useState(false);
const [contactForm] = Form.useForm();
const [submittingContact, setSubmittingContact] = useState(false);
const [contactPosition, setContactPosition] = useState<{ x: number; y: number | string }>({ x: 24, y: '25%' });
const [contactPosition, setContactPosition] = useState<{ x: number; y: number }>(() => ({
x: 24,
y: window.innerHeight * 0.75
}));
const [isDragging, setIsDragging] = useState(false);
const [dragStart, setDragStart] = useState({ x: 0, y: 0 });
const hasMovedRef = useRef(false);
const dragOffsetRef = useRef({ x: 0, y: 0 });
const [mobileExpandedMenus, setMobileExpandedMenus] = useState<Record<string, boolean>>({});
const [siteName, setSiteName] = useState(() => {
const cached = localStorage.getItem('siteInfo');
@@ -213,24 +217,41 @@ const AppLayout: React.FC = () => {
const handleContactMouseDown = (e: React.MouseEvent) => {
if (e.button === 0) {
setIsDragging(true);
setDragStart({
hasMovedRef.current = false;
dragOffsetRef.current = {
x: e.clientX - contactPosition.x,
y: typeof contactPosition.y === 'string' ? e.clientY - (window.innerHeight * parseInt(contactPosition.y) / 100) : e.clientY - contactPosition.y,
});
y: e.clientY - contactPosition.y,
};
}
};
const handleContactMouseMove = (e: MouseEvent) => {
if (!isDragging) return;
const newX = Math.max(16, Math.min(window.innerWidth - 70, e.clientX - dragStart.x));
const newY = Math.max(60, Math.min(window.innerHeight - 60, e.clientY - dragStart.y));
const deltaY = Math.abs(e.clientY - (contactPosition.y + dragOffsetRef.current.y));
if (deltaY > 2) {
hasMovedRef.current = true;
}
setContactPosition({ x: newX, y: newY });
const newY = Math.max(60, Math.min(window.innerHeight - 60, e.clientY - dragOffsetRef.current.y));
setContactPosition(prev => ({ x: prev.x, y: newY }));
};
const handleContactMouseUp = () => {
const wasDragging = isDragging;
setIsDragging(false);
if (!hasMovedRef.current && !wasDragging) {
setContactModalOpen(true);
}
hasMovedRef.current = false;
};
const handleContactClick = () => {
if (!hasMovedRef.current && !isDragging) {
setContactModalOpen(true);
}
};
useEffect(() => {
@@ -242,7 +263,7 @@ const AppLayout: React.FC = () => {
document.removeEventListener('mouseup', handleContactMouseUp);
};
}
}, [isDragging, dragStart]);
}, [isDragging]);
const loadUnreadCount = () => {
getUnreadCount().then(count => {
@@ -958,7 +979,7 @@ const AppLayout: React.FC = () => {
/
<Typography.Text
style={{
color: '#6366f1',
color: '#ff0000ff',
cursor: 'pointer',
textDecoration: 'underline',
}}
@@ -1242,7 +1263,7 @@ const AppLayout: React.FC = () => {
className="contact-button-wrapper"
style={{
right: `${contactPosition.x}px`,
bottom: typeof contactPosition.y === 'string' ? contactPosition.y : `${window.innerHeight - contactPosition.y}px`,
bottom: `${window.innerHeight - contactPosition.y}px`,
}}
>
<div style={{
@@ -1257,11 +1278,12 @@ const AppLayout: React.FC = () => {
</div>
<button
onClick={() => !isDragging && setContactModalOpen(true)}
onClick={handleContactClick}
className={`contact-button ${isDragging ? 'dragging' : ''}`}
onMouseEnter={() => setContactHovered(true)}
onMouseLeave={() => setContactHovered(false)}
onMouseDown={handleContactMouseDown}
onMouseUp={handleContactMouseUp}
>
<MessageOutlined style={{ fontSize: 20 }} />
</button>