File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ function CommentSubmit(props: CommentSubmitProps) {
38
38
39
39
setCommentData ( {
40
40
...commentData ,
41
- comment : value . trim ( ) ,
41
+ comment : value ,
42
42
height : e . currentTarget . scrollHeight + 2 ,
43
43
} ) ;
44
44
} ;
Original file line number Diff line number Diff line change @@ -32,6 +32,14 @@ export default function TagList() {
32
32
month,
33
33
} = router . query ;
34
34
const [ tags , setTags ] = useState < Tag [ ] > ( [ ] ) ;
35
+ const [ maxHeight , setMaxHeight ] = useState < number > ( 444 ) ; // 初始为默认高度
36
+
37
+ // 动态更新 maxHeight 基于屏幕高度
38
+ const updateMaxHeight = ( ) => {
39
+ // 根据需求动态计算,例如屏幕高度的 60%
40
+ const calculatedHeight = Math . max ( window . innerHeight * 0.6 , 300 ) ; // 最小值为 300px
41
+ setMaxHeight ( calculatedHeight ) ;
42
+ } ;
35
43
36
44
useEffect ( ( ) => {
37
45
const initTags = async ( ) => {
@@ -44,6 +52,14 @@ export default function TagList() {
44
52
45
53
if ( ! isMobile ( ) ) {
46
54
initTags ( ) ;
55
+ // 初始化计算高度
56
+ updateMaxHeight ( ) ;
57
+ // 监听窗口大小变化,更新高度
58
+ window . addEventListener ( 'resize' , updateMaxHeight ) ;
59
+ // 清理事件监听器
60
+ return ( ) => {
61
+ window . removeEventListener ( 'resize' , updateMaxHeight ) ;
62
+ } ;
47
63
}
48
64
} , [ ] ) ; // 确保 useEffect 只在组件挂载时执行
49
65
@@ -70,7 +86,10 @@ export default function TagList() {
70
86
</ div >
71
87
</ div >
72
88
</ div >
73
- < div className = 'hidden-scrollbar max-h-[444px] overflow-y-auto' >
89
+ < div
90
+ className = 'hidden-scrollbar overflow-y-auto'
91
+ style = { { maxHeight : `${ maxHeight } px` } }
92
+ >
74
93
{ ! tags . length && < TagListSkeleton /> }
75
94
{ tags . map ( ( item : Tag ) => (
76
95
< Link
You can’t perform that action at this time.
0 commit comments