未来全栈 5 meses atrás
pai
commit
610c553ddb

+ 4 - 0
src/app/app-routing.module.ts

@@ -17,6 +17,10 @@ const routes: Routes = [
   {
     path: 'comment-modal',
     loadChildren: () => import('./comment-modal/comment-modal.module').then( m => m.CommentModalPageModule)
+  },
+  {
+    path: 'begin-page',
+    loadChildren: () => import('./begin-page/begin-page.module').then( m => m.BeginPagePageModule)
   }
 ];
 @NgModule({

+ 17 - 0
src/app/begin-page/begin-page-routing.module.ts

@@ -0,0 +1,17 @@
+import { NgModule } from '@angular/core';
+import { Routes, RouterModule } from '@angular/router';
+
+import { BeginPagePage } from './begin-page.page';
+
+const routes: Routes = [
+  {
+    path: '',
+    component: BeginPagePage
+  }
+];
+
+@NgModule({
+  imports: [RouterModule.forChild(routes)],
+  exports: [RouterModule],
+})
+export class BeginPagePageRoutingModule {}

+ 20 - 0
src/app/begin-page/begin-page.module.ts

@@ -0,0 +1,20 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormsModule } from '@angular/forms';
+
+import { IonicModule } from '@ionic/angular';
+
+import { BeginPagePageRoutingModule } from './begin-page-routing.module';
+
+import { BeginPagePage } from './begin-page.page';
+
+@NgModule({
+  imports: [
+    CommonModule,
+    FormsModule,
+    IonicModule,
+    BeginPagePageRoutingModule
+  ],
+  declarations: [BeginPagePage]
+})
+export class BeginPagePageModule {}

+ 20 - 0
src/app/begin-page/begin-page.page.html

@@ -0,0 +1,20 @@
+<ion-header [translucent]="true">
+  <ion-buttons slot="start">
+    <ion-back-button defaultHref="/tabs/tab1"></ion-back-button>
+  </ion-buttons>
+</ion-header>
+
+<ion-content [fullscreen]="true">
+  <div class="file-input-container">
+    <label for="file-input" class="file-input-label">
+      <ion-icon name="add-outline" size="large"></ion-icon>
+      <img *ngIf="selectedImage" [src]="selectedImage" width="60" class="selected-image">
+    </label>
+    <input id="file-input" type="file" (change)="onFileSelected($event)" accept="image/*" style="display: none">
+  </div>
+  <p>有意义的标题可以获得更多关注~</p>
+  <ion-item>
+    <ion-textarea placeholder="写点什么吧..." [(ngModel)]="content" (input)="checkContent()" class="custom-textarea"></ion-textarea>
+  </ion-item>
+  <ion-button expand="block" color="primary" [disabled]="isContentEmpty || !selectedImage" (click)="publish()">发布</ion-button>
+</ion-content>

+ 40 - 0
src/app/begin-page/begin-page.page.scss

@@ -0,0 +1,40 @@
+.file-input-container {
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    margin-top: 20px;
+    position: relative;
+}
+
+.custom-textarea {
+    overflow-y: auto;
+    max-height: 200px;
+    /* 设置最大高度,超出部分自动滚动 */
+}
+
+.file-input-label {
+    position: relative;
+    display: inline-block;
+    background-color: #dadada;
+    width: 120px;
+    height: 120px;
+    border-radius: 20px;
+    text-align: center;
+    line-height: 120px;
+    cursor: pointer;
+}
+
+.file-input-label ion-icon {
+    color: #757474;
+    font-size: 40px;
+    font-weight: bold;
+}
+
+.selected-image {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100%;
+    height: 100%;
+    object-fit: cover;
+}

+ 17 - 0
src/app/begin-page/begin-page.page.spec.ts

@@ -0,0 +1,17 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { BeginPagePage } from './begin-page.page';
+
+describe('BeginPagePage', () => {
+  let component: BeginPagePage;
+  let fixture: ComponentFixture<BeginPagePage>;
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(BeginPagePage);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 44 - 0
src/app/begin-page/begin-page.page.ts

@@ -0,0 +1,44 @@
+import { Component, OnInit } from '@angular/core';
+import { NavController } from '@ionic/angular';
+
+@Component({
+  selector: 'app-begin-page',
+  templateUrl: './begin-page.page.html',
+  styleUrls: ['./begin-page.page.scss'],
+})
+export class BeginPagePage implements OnInit {
+
+  content: string = ''; // 用于存储输入框内容
+  isContentEmpty: boolean = true; // 用于判断输入框内容是否为空
+  selectedImage: any; // 用于存储所选图片的数据
+
+  constructor(private navCtrl: NavController) { }
+
+  checkContent() {
+    this.isContentEmpty = this.content.trim().length === 1;
+  }
+
+
+  onFileSelected(event:any) {
+    const file: File = event.target.files[0];
+    if (file) {
+      const reader = new FileReader();
+      reader.onload = (e: any) => {
+        this.selectedImage = e.target.result;
+      };
+      reader.readAsDataURL(file);
+    }
+  }
+
+  publish() {
+    // 处理发布逻辑
+    console.log('发布内容:', this.content);
+    console.log('发布图片:', this.selectedImage);
+  }
+
+
+
+  ngOnInit() {
+  }
+
+}

+ 26 - 1
src/app/comments/comments.page.html

@@ -48,7 +48,29 @@
         <img
           src="https://tse3-mm.cn.bing.net/th/id/OIP-C.QGUz1-tWsQhwsa3F6i9nGAHaHa?w=268&h=201&c=7&r=0&o=5&dpr=1.3&pid=1.7"
           class="avatar">
-        <span class="username">评论者1</span>
+        <span class="username">评论者</span>
+      </div>
+      <div class="content">
+        <p>评论内容...</p>
+      </div>
+      <div class="actions">
+        <ion-button size="small" color="primary">
+          <ion-icon name="thumbs-up"></ion-icon>
+          <!-- 点赞 -->
+        </ion-button>
+        <ion-button size="small" color="primary" (click)="openCommentPopover($event)">
+          <ion-icon name="chatbox-ellipses-outline"></ion-icon>
+          <!-- 评论 -->
+        </ion-button>
+      </div>
+    </div>
+
+    <div class="comment">
+      <div class="user-info">
+        <img
+          src="https://tse3-mm.cn.bing.net/th/id/OIP-C.QGUz1-tWsQhwsa3F6i9nGAHaHa?w=268&h=201&c=7&r=0&o=5&dpr=1.3&pid=1.7"
+          class="avatar">
+        <span class="username">评论者</span>
       </div>
       <div class="content">
         <p>评论内容...</p>
@@ -68,6 +90,9 @@
   </div>
 </ion-content>
 
+<div>......</div>
+<div>已经到底了</div>
+
 <ion-footer>
   <ion-button (click)="like()">
     <ion-icon name="thumbs-up"></ion-icon>

+ 6 - 0
src/app/tab1/tab1.page.html

@@ -35,4 +35,10 @@
     <!-- 可以添加更多评论项 -->
 
   </ion-list>
+
+  <ion-fab vertical="bottom" horizontal="end" slot="fixed">
+    <ion-fab-button (click)="goToBeginPage()">
+      <ion-icon name="create-outline"></ion-icon>
+    </ion-fab-button>
+  </ion-fab>
 </ion-content>

+ 5 - 0
src/app/tab1/tab1.page.ts

@@ -67,4 +67,9 @@ export class Tab1Page {
     }
   }
 
+  goToBeginPage() {
+    // 在这里编写跳转逻辑,例如使用路由导航跳转到发表评论的界面
+    this.navCtrl.navigateForward('/begin-page');
+  }
+
 }

+ 23 - 8
src/app/tab2/tab2.page.html

@@ -1,17 +1,32 @@
 <ion-header [translucent]="true">
   <ion-toolbar>
     <ion-title>
-      Tab 2
+      智能解答
     </ion-title>
   </ion-toolbar>
 </ion-header>
 
 <ion-content [fullscreen]="true">
-  <ion-header collapse="condense">
-    <ion-toolbar>
-      <ion-title size="large">Tab 2</ion-title>
-    </ion-toolbar>
-  </ion-header>
+  <div class="chat-container">
+    <div class="messages">
+      <div class="message received">
+        <img src="https://tse3-mm.cn.bing.net/th/id/OIP-C.QGUz1-tWsQhwsa3F6i9nGAHaHa?w=268&h=201&c=7&r=0&o=5&dpr=1.3&pid=1.7" class="avatar1">
+        <div class="message-content">
+          <p>你好!有什么问题我可以帮助你解答吗?</p>
+        </div>
+      </div>
 
-  <app-explore-container name="Tab 2 page"></app-explore-container>
-</ion-content>
+      <div class="message sent">
+        <div class="message-content">
+          <p>你好!我想询问关于梦境的信息。</p>
+        </div>
+        <img src="https://tse3-mm.cn.bing.net/th/id/OIP-C.QGUz1-tWsQhwsa3F6i9nGAHaHa?w=268&h=201&c=7&r=0&o=5&dpr=1.3&pid=1.7" class="avatar2">
+      </div>
+      <!-- 更多聊天消息可以继续添加 -->
+    </div>
+    <div class="input-container">
+      <ion-input placeholder="输入消息"></ion-input>
+      <ion-button expand="block" color="primary">发送</ion-button>
+    </div>
+  </div>
+</ion-content>

+ 64 - 0
src/app/tab2/tab2.page.scss

@@ -0,0 +1,64 @@
+.chat-container {
+    display: flex;
+    flex-direction: column;
+    padding: 20px;
+}
+
+.messages {
+    flex: 1;
+    overflow-y: auto;
+}
+
+.message {
+    margin-bottom: 10px;
+    display: flex;
+    border-radius: 20px;
+    // padding: 10px;
+    align-items: flex-start;
+}
+
+.avatar1 {
+    width: 40px;
+    height: 40px;
+    border-radius: 50%;
+    margin-right: 10px;
+    // margin-left: 10px;
+}
+
+.avatar2 {
+    width: 40px;
+    height: 40px;
+    border-radius: 50%;
+    // margin-right: 10px;
+}
+
+.message-content {
+    padding: 10px;
+    border-radius: 10px;
+    max-width: 90%;
+    margin-right: 50px;
+}
+
+.received {
+    align-self: flex-start;
+    background-color: #f0f0f0;
+    flex-direction: row;
+}
+
+.sent {
+    align-self: flex-end;
+    background-color: #007bff;
+    color: white;
+    // flex-direction: row-reverse;
+}
+
+.input-container {
+    display: flex;
+    align-items: center;
+    margin-top: 20px;
+}
+
+ion-input {
+    flex: 1;
+    margin-right: 10px;
+}