tab-community.page.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <ion-header [translucent]="true">
  2. <ion-toolbar>
  3. <ion-title>学习社区</ion-title>
  4. </ion-toolbar>
  5. </ion-header>
  6. <ion-content [fullscreen]="true">
  7. <!-- 下拉刷新 -->
  8. <ion-refresher slot="fixed" (ionRefresh)="doRefresh($event)">
  9. <ion-refresher-content></ion-refresher-content>
  10. </ion-refresher>
  11. <!-- 帖子列表 -->
  12. <ion-list>
  13. <!-- 加载状态 -->
  14. <ion-card *ngIf="isLoading">
  15. <ion-card-content>
  16. <ion-item lines="none">
  17. <ion-avatar slot="start">
  18. <ion-skeleton-text [animated]="true"></ion-skeleton-text>
  19. </ion-avatar>
  20. <ion-label>
  21. <h3><ion-skeleton-text [animated]="true" style="width: 50%"></ion-skeleton-text></h3>
  22. <p><ion-skeleton-text [animated]="true" style="width: 80%"></ion-skeleton-text></p>
  23. </ion-label>
  24. </ion-item>
  25. </ion-card-content>
  26. </ion-card>
  27. <!-- 帖子内容 -->
  28. <ion-card *ngFor="let post of posts">
  29. <ion-card-content>
  30. <ion-item lines="none" class="author-info">
  31. <ion-avatar slot="start">
  32. <img [src]="post.author.avatar" alt="avatar">
  33. </ion-avatar>
  34. <ion-label>
  35. <h3>{{post.author.name}}</h3>
  36. <p>{{post.createdAt | date:'MM-dd HH:mm'}}</p>
  37. </ion-label>
  38. </ion-item>
  39. <p class="post-content">{{post.content}}</p>
  40. <!-- 图片展示区域 -->
  41. <div class="post-images" *ngIf="post.images?.length > 0">
  42. <!-- 单张图片 -->
  43. <div class="single-image" *ngIf="post.images.length === 1">
  44. <img [src]="post.images[0]" (click)="viewImage(post.images[0])">
  45. </div>
  46. <!-- 两张图片 -->
  47. <div class="double-images" *ngIf="post.images.length === 2">
  48. <img *ngFor="let img of post.images"
  49. [src]="img"
  50. (click)="viewImage(img)">
  51. </div>
  52. <!-- 三张及以上图片 -->
  53. <div class="multiple-images" *ngIf="post.images.length >= 3">
  54. <img *ngFor="let img of post.images.slice(0, 9)"
  55. [src]="img"
  56. (click)="viewImage(img)">
  57. <div class="more-images" *ngIf="post.images.length > 9">
  58. +{{post.images.length - 9}}
  59. </div>
  60. </div>
  61. </div>
  62. <!-- 添加标签 -->
  63. <div class="post-tags">
  64. <ion-chip *ngFor="let tag of post.tags" color="primary" outline>
  65. <ion-label>{{tag}}</ion-label>
  66. </ion-chip>
  67. </div>
  68. <div class="post-actions">
  69. <ion-button fill="clear" (click)="toggleLike(post)">
  70. <ion-icon [name]="post.isLiked ? 'heart' : 'heart-outline'"
  71. [color]="post.isLiked ? 'danger' : 'medium'"
  72. slot="start">
  73. </ion-icon>
  74. {{post.likes}}
  75. </ion-button>
  76. <ion-button fill="clear">
  77. <ion-icon name="chatbubble-outline" slot="start"></ion-icon>
  78. {{post.comments}}
  79. </ion-button>
  80. <ion-button fill="clear">
  81. <ion-icon name="share-outline" slot="start"></ion-icon>
  82. </ion-button>
  83. </div>
  84. </ion-card-content>
  85. </ion-card>
  86. </ion-list>
  87. <!-- 无限滚动 -->
  88. <ion-infinite-scroll (ionInfinite)="loadMore($event)">
  89. <ion-infinite-scroll-content></ion-infinite-scroll-content>
  90. </ion-infinite-scroll>
  91. <!-- 发帖按钮 -->
  92. <ion-button class="fab-button" shape="round" (click)="createPost()">
  93. <ion-icon name="add-outline"></ion-icon>
  94. 发帖
  95. </ion-button>
  96. </ion-content>