daijian_wd

fix: 解决收藏bug

@@ -41,7 +41,7 @@ const TAG = 'OperRowListView'; @@ -41,7 +41,7 @@ const TAG = 'OperRowListView';
41 @Preview 41 @Preview
42 @Component 42 @Component
43 export struct OperRowListView { 43 export struct OperRowListView {
44 - @Prop contentDetailData: ContentDetailDTO // 稿件详情 44 + @Prop @Watch('onDetailUpdated') contentDetailData: ContentDetailDTO // 稿件详情
45 @State operationButtonList: string[] = ['comment', 'collect', 'share'] // 组件展示条件 45 @State operationButtonList: string[] = ['comment', 'collect', 'share'] // 组件展示条件
46 @ObjectLink publishCommentModel: publishCommentModel 46 @ObjectLink publishCommentModel: publishCommentModel
47 // @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO 47 // @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
@@ -52,7 +52,9 @@ export struct OperRowListView { @@ -52,7 +52,9 @@ export struct OperRowListView {
52 @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 52 @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
53 needLike: boolean = true 53 needLike: boolean = true
54 54
55 - async aboutToAppear() { 55 + // async aboutToAppear() {
  56 + async onDetailUpdated() {
  57 + if (!this.contentDetailData) return
56 const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') 58 const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
57 if (user_id) { 59 if (user_id) {
58 this.getInteractDataStatus() 60 this.getInteractDataStatus()
@@ -99,6 +101,7 @@ export struct OperRowListView { @@ -99,6 +101,7 @@ export struct OperRowListView {
99 }) 101 })
100 .width(42) 102 .width(42)
101 103
  104 + if (this.contentDetailData) {
102 ForEach(this.operationButtonList, (item: string, index: number) => { 105 ForEach(this.operationButtonList, (item: string, index: number) => {
103 if (item == 'comment') { 106 if (item == 'comment') {
104 this.builderComment() 107 this.builderComment()
@@ -114,6 +117,7 @@ export struct OperRowListView { @@ -114,6 +117,7 @@ export struct OperRowListView {
114 } 117 }
115 }) 118 })
116 } 119 }
  120 + }
117 .width('100%') 121 .width('100%')
118 .justifyContent(FlexAlign.Start) 122 .justifyContent(FlexAlign.Start)
119 } 123 }