fix: post detail client error (hooks order), image viewer, messages vs DM split
- Fix critical bug: useState declared after conditional return in PostDetail
caused 'Rendered more hooks than during previous render' client error
- Add image viewer (click post image to zoom, matching upstream openImageViewer)
- CSS upload warning confirm modal (matching upstream)
- Fix: navbar 消息 menu item now opens notifications page (messages), not DM
list — DM stays on the ✉️ nav button (matches upstream structure)
This commit is contained in:
1 parent
4ee38f6486
commit
2a508d1b21
5 files changed
+89
-16
No files matched your search
@@ -0,0 +1,35 @@
|
||||
'use client';
|
||||
|
||||
// 图片查看器(点击帖子图片放大)
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export default function ImageViewer({ src, onClose }) {
|
||||
useEffect(() => {
|
||||
const onKey = (e) => { if (e.key === 'Escape') onClose(); };
|
||||
document.addEventListener('keydown', onKey);
|
||||
return () => document.removeEventListener('keydown', onKey);
|
||||
}, [onClose]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="modal active"
|
||||
style={{
|
||||
position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.85)', zIndex: 9999,
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
cursor: 'pointer', animation: 'fadeIn 0.2s ease-out',
|
||||
}}
|
||||
onClick={onClose}
|
||||
>
|
||||
<img
|
||||
src={src}
|
||||
alt=""
|
||||
style={{
|
||||
maxWidth: '90vw', maxHeight: '90vh', objectFit: 'contain',
|
||||
borderRadius: 8, boxShadow: '0 8px 32px rgba(0,0,0,0.5)',
|
||||
cursor: 'default', userSelect: 'none',
|
||||
}}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user