Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
瀑布流
DESKTOP-ZTS2NQJNAfcdc3ce8457d
diff --git a/package.json b/package.jsonindex 57152e75..d802e6f1 100644--- a/package.json+++ b/package.json@@ -62,6 +62,7 @@"path": "^0.12.7","playwright": "^1.49.1","qs": "^6.14.0",+ "react-masonry-css": "^1.0.16","react-router-dom": "6","react-sortablejs": "^6.1.4","react-svg": "^16.2.0",diff --git a/src/views/replyother/index.tsx b/src/views/replyother/index.tsxindex 57fd11a3..1ebad200 100644--- a/src/views/replyother/index.tsx+++ b/src/views/replyother/index.tsx@@ -31,6 +31,7 @@ import {CloseOutlined} from '@ant-design/icons';import webview from 'electron';+import Masonry from 'react-masonry-css';export default function Page() {const [wordList, setWordList] = useState<WorkData[]>([]);@@ -98,7 +99,7 @@ export default function Page() {'414381229d04c46cb39f97a5a0b7f9eb',);console.log('------ getCommentSearchNotes', list);- let newlist = list.slice(0, 12);+ let newlist = list.slice(0, 20);newlist[0].noteId = '67de8bc2000000001c00fdce';newlist[0].xsec_token = 'AB-q1Xl6YS66mGgN8y_DMoskX40j7FsSv2DoSQTYE6DYU=';@@ -255,6 +256,15 @@ export default function Page() {setWebviewModalVisible(true);};+ // 计算断点值,用于响应式布局+ const breakpointColumnsObj = {+ default: 5, // 默认显示5列+ 1600: 4, // 宽度小于1600px时显示4列+ 1200: 3, // 宽度小于1200px时显示3列+ 900: 2, // 宽度小于900px时显示2列+ 600: 1 // 宽度小于600px时显示1列+ };+return (<div className={styles.reply}><Row>@@ -280,22 +290,24 @@ export default function Page() {<Col span={20}><div className={styles.postList}>- <List- grid={{ gutter: 16, column: 3 }}- dataSource={postList}- renderItem={(item: any) => (- <List.Item>+ <Masonry+ breakpointCols={breakpointColumnsObj}+ className={styles.myMasonryGrid}+ columnClassName={styles.myMasonryGridColumn}+ >+ {postList.map((item: any) => (+ <div key={item.noteId || item._id} className={styles.masonryItem}><Cardhoverablecover={<div- style={{ cursor: 'pointer'}}+ style={{ cursor: 'pointer' }}onClick={() => handleImageClick(item)}><imgalt={item.title}src={item.cover}- style={{ width: '96%', margin: '2%', borderRadius: '10px', objectFit: 'cover' }}+ style={{ width: '100%', borderRadius: '10px 10px 0 0', objectFit: 'cover' }}/></div>}@@ -329,9 +341,9 @@ export default function Page() {}/></Card>- </List.Item>- )}- />+ </div>+ ))}+ </Masonry></div></Col></Row>diff --git a/src/views/replyother/reply.module.scss b/src/views/replyother/reply.module.scssindex 10823dab..d89f89d7 100644--- a/src/views/replyother/reply.module.scss+++ b/src/views/replyother/reply.module.scss@@ -102,4 +102,26 @@background-color: rgba(255, 255, 255, 0.8);z-index: 1;}++ // 瀑布流布局样式+ .myMasonryGrid {+ display: flex;+ width: auto;+ margin-left: -16px; // 列间距+ }++ .myMasonryGridColumn {+ padding-left: 16px; // 列间距+ background-clip: padding-box;+ }++ .masonryItem {+ margin-bottom: 16px;++ :global {+ .ant-card {+ width: 300px;+ }+ }+ }}\ No newline at end of file