yi 1 жил өмнө
parent
commit
1c67c82c6e

+ 58 - 53
FilmDraw-app/src/app/tab1/tab1.page.html

@@ -17,65 +17,70 @@
 
  <ion-content [fullscreen]="true">
 <!-- 包含热门话题区和讨论区的父容器 -->
-
-  <div class="content-container">
+<ion-segment [scrollable]="true" value="heart">
+    <div class="content-container">
     <!-- 热门话题区 -->
     <section class="card-section">
-      <ion-card>
-        <ion-card-header>
-          <ion-card-title>热门话题</ion-card-title>
-        </ion-card-header>
-        <ion-card-content class="scrollable-content">
-          <ion-list>
-            <ion-item *ngFor="let topic of topics">
-              <ion-label>
-                <h2>{{ topic.title }}</h2>
-                <p>参与人数: {{ topic.participants }} | 热度: {{ topic.popularity }}</p>
-              </ion-label>
-            </ion-item>
-          </ion-list>
-        </ion-card-content>
-      </ion-card>
+     <ion-card class="card1">
+      <ion-card-header>
+       <ion-card-title >热门话题</ion-card-title>
+      </ion-card-header>
+      <ion-card-content class="scrollable-content">
+       <ion-list>
+        <ion-item *ngFor="let topic of filmpostList">
+         <ion-label>
+          <h2>{{post?.get('title')}}</h2>
+          <p>参与人数:10086 👤| 热度:10086🔥 </p>
+         </ion-label>
+        </ion-item>
+       </ion-list>
+      </ion-card-content>
+     </ion-card>
     </section>
-
+  
     <!-- 话题讨论区 -->
     <section class="card-section">
-      <ion-card>
-        <ion-card-header>
-          <ion-card-title>讨论区</ion-card-title>
-        </ion-card-header>
-        <ion-card-content class="scrollable-content">
-          <ion-list>
-            <ion-item *ngFor="let post of posts">
-              <ion-label>
-                <h2>{{ post.title }}</h2>
-                <p>作者: {{ post.author }} | 评论数: {{ post.comments }} | 热度: {{ post.popularity }}</p>
-              </ion-label>
-            </ion-item>
-          </ion-list>
-        </ion-card-content>
-      </ion-card>
+     <ion-card class="card2">
+      <ion-card-header>
+       <ion-card-title >讨论区</ion-card-title>
+      </ion-card-header>
+      <ion-card-content class="scrollable-content">
+       <ion-list>
+        <ion-item *ngFor="let post of filmpostList">
+         <ion-label>
+          <h2>{{post?.get('title')}} </h2>
+          <p>作者: | 评论数: | 热度: </p>
+         </ion-label>
+        </ion-item>
+       </ion-list>
+      </ion-card-content>
+     </ion-card>
     </section>
-  </div>
+   </div>
+  </ion-segment>
+ 
 
 
-    <!-- 热门话题区 -->
-    <!-- <section class="card-section">
-      <ion-card>
-        <ion-card-header>
-          <ion-card-title>热门话题</ion-card-title>
-        </ion-card-header>
-        <ion-card-content>
-          <ion-list>
-            <ion-item *ngFor="let topic of topics">
-              <ion-label>
-                <h2>{{ topic.title }}</h2>
-                <p>参与人数: {{ topic.participants }} | 热度: {{ topic.popularity }}</p>
-              </ion-label>
-            </ion-item>
-          </ion-list>
-        </ion-card-content>
-      </ion-card>
-    </section> -->
+    <ion-list>
+      <ion-item *ngFor="let post of filmpostList" class="post-item">
+        <ion-avatar slot="start">
+          <img src="/assets/img/1.png" alt="User Avatar" />
+        </ion-avatar>
+        <ion-label>
+          <h2>{{post?.get('title')}} </h2>
+          <h3 class="topic"></h3>
+          <p class="post-content" [class.collapsed]="post?.get('content').length  > 100">
+          {{ post?.get('content').length > 100 ? (post?.get('content') | slice:0:100) + '...' : post?.get('content') }}
+          </p>
+          <p class="post-content" >
+            {{post?.get('content')}}
+          </p>
+          <div class="post-actions">
+            <ion-button fill="clear" (click)="likePost()">👍 </ion-button>
+            <ion-button fill="clear" (click)="commentPost()">💬</ion-button>
+          </div>
+        </ion-label>
+      </ion-item>
+    </ion-list>
+  </ion-content>
 
-</ion-content>

+ 42 - 4
FilmDraw-app/src/app/tab1/tab1.page.scss

@@ -31,14 +31,21 @@
 .content-container {
   display: flex;
   justify-content: space-between; /* 在主轴上均匀分配空间 */
-  padding: 16px; /* 内边距 */
+  padding: 1px; /* 内边距 */
+  background: white;
 }
 
+ion-segment {
+  overflow: auto;
+  scrollbar-width: none; /* Firefox */
+  -ms-overflow-style: none; /* IE and Edge */
+}
 .card-section {
   flex: 1; /* 让每个卡片占据相同的空间 */
-  margin: 0 8px; /* 卡片之间的水平间距 */
-  min-width: 300px; /* 设置最小宽度,以确保在小屏幕上不会过于拥挤 */
+  margin: 0 1px; /* 卡片之间的水平间距 */
+  min-width: 250px; /* 设置最小宽度,以确保在小屏幕上不会过于拥挤 */
   display: flex;
+  float: left;
   flex-direction: column; /* 使卡片内容垂直排列 */
   height: 100%; /* 确保卡片高度相同 */
 }
@@ -49,8 +56,16 @@ ion-card {
   overflow: hidden; /* 隐藏溢出内容 */
 }
 
+// .card1{
+// background: #036a99;
+// }
+
+// .card2{
+//   background: #036a99;
+// }
+
 .scrollable-content {
-  max-height: 300px; /* 设置最大高度,可以根据需要调整 */
+  height: 150px; /* 设置最大高度,可以根据需要调整 */
   overflow-y: auto; /* 添加垂直滚动条 */
 }
 
@@ -75,7 +90,30 @@ ion-label p {
   font-size: 0.9em; /* 字体大小 */
 }
 
+.post-item {
+  margin-bottom: 16px;
+}
+
+.topic {
+  color: #888;
+  font-size: 0.9em;
+}
+
+.post-content {
+  margin: 8px 0;
+  transition: max-height 0.3s ease;
+}
 
+.collapsed {
+  max-height: 40px; // 控制折叠后的高度
+  overflow: hidden;
+}
+
+.post-actions {
+  display: flex;
+  justify-content: space-between;
+  margin-top: 8px;
+}
 
 // ion-header {
 //     background-color: #ffffff; // 设置头部背景色

+ 30 - 35
FilmDraw-app/src/app/tab1/tab1.page.ts

@@ -3,11 +3,12 @@ import {
   IonHeader, IonToolbar, IonTitle, IonContent, 
   IonButton, IonButtons, IonIcon, IonCard, IonCardHeader, IonCardTitle, IonCardContent,
   IonItem, IonLabel, IonList, IonInput, IonTextarea, IonAvatar, IonSearchbar,
-  ModalController} from '@ionic/angular/standalone';
+  ModalController,
+  IonSegment,} from '@ionic/angular/standalone';
 import { ExploreContainerComponent } from '../explore-container/explore-container.component';
 import { CommonModule } from '@angular/common';
 import { openPostPublisherModal } from 'src/lib/public/post-publisher/post-publisher.component';
-import { CloudUser } from 'src/lib/ncloud';
+import { CloudObject, CloudPost, CloudQuery, CloudUser } from 'src/lib/ncloud';
 import { openUserLoginModal } from 'src/lib/user/modal-user-login/modal-user-login.component';
 
 @Component({
@@ -19,7 +20,7 @@ import { openUserLoginModal } from 'src/lib/user/modal-user-login/modal-user-log
     CommonModule,
     IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,
  
-    IonButton, IonButtons, IonIcon, 
+    IonButton, IonButtons, IonIcon,IonSegment,
 
     IonCard, IonCardHeader, IonCardTitle, IonCardContent,
     IonList, IonItem, IonLabel, IonAvatar, IonInput, IonTextarea,IonSearchbar
@@ -28,11 +29,29 @@ import { openUserLoginModal } from 'src/lib/user/modal-user-login/modal-user-log
 })
 export class Tab1Page {
   currentUser:CloudUser|undefined
+  post:CloudPost|undefined
+
+
   constructor(private modalCtrl:ModalController){
     this.currentUser=new CloudUser();
+    this.post=new CloudPost();
   }
 
 
+    ngOnInit() {
+      // 生命周期:页面加载后,运行帖子列表,加载函数
+      this.loadFilmPostList()
+    }
+  
+    // 创建用于数据列表存储的属性
+    filmpostList:Array<CloudObject> = []
+
+    // 查询并加载列表的函数
+    async loadFilmPostList(){
+      let query = new CloudQuery("FilmPost");
+      this.filmpostList = await query.find()
+    }
+
 async openPublishModal(){
 
   if(!this.currentUser?.id){
@@ -41,47 +60,23 @@ async openPublishModal(){
 if(this.currentUser?.id){
   openPostPublisherModal(this.modalCtrl);
 }
-  
 
 }
 
+  likePost() {
+   
+  }
+
+  commentPost() {
+    // 评论逻辑
+  }
   onSearch(event: any) {
         const searchTerm = event.target.value; // 获取用户输入的搜索内容
         console.log('搜索内容:', searchTerm);
         // 在这里添加搜索逻辑,例如过滤列表或导航到搜索结果页面
       }
   
-  topics = [
-    { title: '年度最佳剧集', participants: 120, popularity: '⭐⭐⭐⭐⭐' },
-    { title: '经典电影回顾', participants: 80, popularity: '⭐⭐⭐⭐' },
-    { title: '新剧推荐', participants: 200, popularity: '⭐⭐⭐⭐⭐⭐' },
-  ];
-
-  posts = [
-    { title: '对《某某剧名》的看法', author: '用户A', comments: 5, popularity: '⭐⭐⭐⭐⭐' },
-    { title: '最新剧集讨论', author: '用户B', comments: 2, popularity: '⭐⭐⭐⭐' },
-  ];
 
-  newPost = {
-    title: '',
-    content: ''
-  };
 
-  comments = [
-    { username: '用户C', content: '我觉得这部剧非常精彩!', userAvatar: 'assets/avatar1.png' },
-    { username: '用户D', content: '剧情发展很吸引人!', userAvatar: 'assets/avatar2.png' },
-  ];
-
-  submitPost() {
-    if (this.newPost.title && this.newPost.content) {
-      this.posts.push({
-        title: this.newPost.title,
-        author: '当前用户', // 这里可以替换为实际用户
-        comments: 0,
-        popularity: '⭐⭐' // 默认热度
-      });
-      this.newPost.title = '';
-      this.newPost.content = '';
-    }
-  }
+  
 }

+ 1 - 1
FilmDraw-app/src/lib/ncloud.ts

@@ -377,7 +377,7 @@ export class CloudUser extends CloudObject {
 //CloudPost.ts
 export class CloudPost extends CloudObject {
     constructor() {
-        super('FilmPosts'); // 调用父类构造函数,指定类名
+        super('FilmPost'); // 调用父类构造函数,指定类名
     }
 
     // 设置帖子数据,包括发布者信息

+ 9 - 1
FilmDraw-app/src/lib/public/post-publisher/post-publisher.component.html

@@ -8,12 +8,20 @@
    </ion-card-header>
  <ion-card-content>
 
+
+  <ion-item>
+    <ion-input [value]="postData['title']" (ionChange)="postDataChange('title',$event)" title="标题" placeholder="请输入的标题"></ion-input>
+  </ion-item>
    <ion-item>
-     <ion-input [value]="postData['content']" (ionChange)="postDataChange('content',$event)" label="内容" placeholder="请输入你要分享的内容"></ion-input>
+     <ion-input [value]="postData['content']" (ionChange)="postDataChange('content',$event)" content="内容" placeholder="请输入你要分享的内容"></ion-input>
    </ion-item>
    <ion-item>
     <ion-input [value]="postData['label']" (ionChange)="postDataChange('label',$event)" label="话题" placeholder="请输入你讨论的话题"></ion-input>
   </ion-item>
+   <ion-item>
+    <ion-input [value]="postData['avatar']" (ionChange)="postDataChange('avatar',$event)" avatar="图片" placeholder="请输入你想上传的图片"></ion-input>
+  </ion-item>
+
 
    <ion-button expand="block" (click)="save()">发布帖子</ion-button>
    <ion-button expand="block" (click)="cancel()">取消发布</ion-button>