Showing
1 changed file
with
25 additions
and
6 deletions
| @@ -13,6 +13,8 @@ import NoMoreLayout from '../../page/NoMoreLayout'; | @@ -13,6 +13,8 @@ import NoMoreLayout from '../../page/NoMoreLayout'; | ||
| 13 | import { EmptyComponent } from '../../view/EmptyComponent'; | 13 | import { EmptyComponent } from '../../view/EmptyComponent'; |
| 14 | import { ContentDetailDTO, Params } from 'wdBean/Index'; | 14 | import { ContentDetailDTO, Params } from 'wdBean/Index'; |
| 15 | import { TrackingContent, TrackParamConvert } from 'wdTracking/Index'; | 15 | import { TrackingContent, TrackParamConvert } from 'wdTracking/Index'; |
| 16 | +import { WindowModel } from 'wdKit/Index'; | ||
| 17 | +import { window } from '@kit.ArkUI'; | ||
| 16 | 18 | ||
| 17 | const TAG = 'CommentComponent'; | 19 | const TAG = 'CommentComponent'; |
| 18 | 20 | ||
| @@ -53,6 +55,11 @@ export struct CommentComponent { | @@ -53,6 +55,11 @@ export struct CommentComponent { | ||
| 53 | private dialogBeforeJumpOtherPageAction: () => void = () => {} | 55 | private dialogBeforeJumpOtherPageAction: () => void = () => {} |
| 54 | private dialogUpdateTitle: (title: string) => void = () => {} | 56 | private dialogUpdateTitle: (title: string) => void = () => {} |
| 55 | 57 | ||
| 58 | + private windowClass?: window.Window; | ||
| 59 | + @State isZD: boolean = false // 存储是否折叠屏 | ||
| 60 | + private screenWidth: number = 0 | ||
| 61 | + @State windowWidth: number = AppStorage.get<number>('windowWidth') || 0 | ||
| 62 | + | ||
| 56 | // 在自定义组件即将析构销毁时将dialogControlle置空 | 63 | // 在自定义组件即将析构销毁时将dialogControlle置空 |
| 57 | aboutToDisappear() { | 64 | aboutToDisappear() { |
| 58 | this.dialogController = null // 将dialogController置空 | 65 | this.dialogController = null // 将dialogController置空 |
| @@ -93,8 +100,19 @@ export struct CommentComponent { | @@ -93,8 +100,19 @@ export struct CommentComponent { | ||
| 93 | 100 | ||
| 94 | this.getData(); | 101 | this.getData(); |
| 95 | 102 | ||
| 103 | + this.windowClass = WindowModel.shared.getWindowClass(); // 获取应用主窗口 | ||
| 104 | + this.screenWidth = this.windowClass?.getWindowProperties()?.windowRect.width | ||
| 105 | + // 2000折叠屏 TODO DeviceUtil 方法完善了换判断条件 | ||
| 106 | + this.isZD = this.screenWidth > 2000 ? true : false | ||
| 107 | + this.resizeWindow() | ||
| 96 | } | 108 | } |
| 97 | 109 | ||
| 110 | + resizeWindow() { | ||
| 111 | + this.windowClass?.on('windowSizeChange', () => { | ||
| 112 | + this.screenWidth = this.windowClass?.getWindowProperties()?.windowRect.width || this.windowWidth | ||
| 113 | + this.isZD = this.screenWidth > 2000 ? true : false | ||
| 114 | + }); | ||
| 115 | + } | ||
| 98 | // | 116 | // |
| 99 | addCommentLocal() { | 117 | addCommentLocal() { |
| 100 | // let model = commentViewModel.deepCopyCommentItemModel(this.publishCommentModel.lastCommentModel) | 118 | // let model = commentViewModel.deepCopyCommentItemModel(this.publishCommentModel.lastCommentModel) |
| @@ -168,12 +186,13 @@ export struct CommentComponent { | @@ -168,12 +186,13 @@ export struct CommentComponent { | ||
| 168 | 186 | ||
| 169 | /*1级评论作为titleHeader*/ | 187 | /*1级评论作为titleHeader*/ |
| 170 | @Builder | 188 | @Builder |
| 171 | - CommentHeaderItem(item: commentItemModel, index: number) { | 189 | + CommentHeaderItem(item: commentItemModel, index: number,isZD:boolean) { |
| 172 | commentHeaderView({ | 190 | commentHeaderView({ |
| 173 | item: item, | 191 | item: item, |
| 174 | dialogController: this.dialogController, | 192 | dialogController: this.dialogController, |
| 175 | publishCommentModel: this.publishCommentModel, | 193 | publishCommentModel: this.publishCommentModel, |
| 176 | - dialogBeforeJumpOtherPageAction: this.dialogBeforeJumpOtherPageAction | 194 | + dialogBeforeJumpOtherPageAction: this.dialogBeforeJumpOtherPageAction, |
| 195 | + isZD:isZD | ||
| 177 | }) | 196 | }) |
| 178 | } | 197 | } |
| 179 | 198 | ||
| @@ -214,7 +233,7 @@ export struct CommentComponent { | @@ -214,7 +233,7 @@ export struct CommentComponent { | ||
| 214 | } | 233 | } |
| 215 | else if (item.hasMore) { | 234 | else if (item.hasMore) { |
| 216 | ListItemGroup({ | 235 | ListItemGroup({ |
| 217 | - header: this.CommentHeaderItem(item, index), | 236 | + header: this.CommentHeaderItem(item, index,this.isZD), |
| 218 | footer: this.GroupFooterView(item, index) | 237 | footer: this.GroupFooterView(item, index) |
| 219 | }) { | 238 | }) { |
| 220 | LazyForEach(item.childCommentsLazyDataSource, (childItem: commentItemModel, subIndex: number) => { | 239 | LazyForEach(item.childCommentsLazyDataSource, (childItem: commentItemModel, subIndex: number) => { |
| @@ -232,7 +251,7 @@ export struct CommentComponent { | @@ -232,7 +251,7 @@ export struct CommentComponent { | ||
| 232 | }, (childItem: commentItemModel, subIndex: number) => JSON.stringify(childItem) + subIndex.toString()) | 251 | }, (childItem: commentItemModel, subIndex: number) => JSON.stringify(childItem) + subIndex.toString()) |
| 233 | } | 252 | } |
| 234 | } else { | 253 | } else { |
| 235 | - ListItemGroup({ header: this.CommentHeaderItem(item, index) }) { | 254 | + ListItemGroup({ header: this.CommentHeaderItem(item, index,this.isZD) }) { |
| 236 | LazyForEach(item.childCommentsLazyDataSource, (childItem: commentItemModel, subIndex: number) => { | 255 | LazyForEach(item.childCommentsLazyDataSource, (childItem: commentItemModel, subIndex: number) => { |
| 237 | ListItem() { | 256 | ListItem() { |
| 238 | ChildCommentItem({ | 257 | ChildCommentItem({ |
| @@ -684,6 +703,7 @@ struct commentHeaderView { | @@ -684,6 +703,7 @@ struct commentHeaderView { | ||
| 684 | private dialogBeforeJumpOtherPageAction: () => void = () => {} | 703 | private dialogBeforeJumpOtherPageAction: () => void = () => {} |
| 685 | private leftGap: number = 64 | 704 | private leftGap: number = 64 |
| 686 | @State isCanClickHeader:boolean = true | 705 | @State isCanClickHeader:boolean = true |
| 706 | + @Prop isZD: boolean = false | ||
| 687 | 707 | ||
| 688 | build() { | 708 | build() { |
| 689 | Column() { | 709 | Column() { |
| @@ -731,7 +751,7 @@ struct commentHeaderView { | @@ -731,7 +751,7 @@ struct commentHeaderView { | ||
| 731 | maxline: 3, | 751 | maxline: 3, |
| 732 | fontSize: 16, | 752 | fontSize: 16, |
| 733 | fontWeight: FontWeight.Regular, | 753 | fontWeight: FontWeight.Regular, |
| 734 | - marginWidth: (59 + 16) | 754 | + marginWidth: (this.isZD?60:70 + 16) |
| 735 | }) | 755 | }) |
| 736 | .margin({ left: this.leftGap, right: 16,top:-12 }) | 756 | .margin({ left: this.leftGap, right: 16,top:-12 }) |
| 737 | .onClick(() => { | 757 | .onClick(() => { |
| @@ -745,7 +765,6 @@ struct commentHeaderView { | @@ -745,7 +765,6 @@ struct commentHeaderView { | ||
| 745 | } | 765 | } |
| 746 | }) | 766 | }) |
| 747 | ) | 767 | ) |
| 748 | - | ||
| 749 | if (this.item.commentPics.length > 0) { | 768 | if (this.item.commentPics.length > 0) { |
| 750 | Image(this.item.commentPics) | 769 | Image(this.item.commentPics) |
| 751 | .width(88).height(88) | 770 | .width(88).height(88) |
-
Please register or login to post a comment