Quellcode durchsuchen

创建mail消息页面

5230240 vor 4 Monaten
Ursprung
Commit
fb514cbbcc

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

@@ -20,6 +20,10 @@ const routes: Routes = [
     path: 'user',
     loadChildren: () => import('../modules/user/user.module').then(m => m.UserModule)
   },
+  {
+    path: 'mail',
+    loadChildren: () => import('./mail/mail.module').then( m => m.MailPageModule)
+  },
 
 ];
 @NgModule({

+ 17 - 0
src/app/mail/mail-routing.module.ts

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

+ 20 - 0
src/app/mail/mail.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 { MailPageRoutingModule } from './mail-routing.module';
+
+import { MailPage } from './mail.page';
+
+@NgModule({
+  imports: [
+    CommonModule,
+    FormsModule,
+    IonicModule,
+    MailPageRoutingModule
+  ],
+  declarations: [MailPage]
+})
+export class MailPageModule {}

+ 23 - 0
src/app/mail/mail.page.html

@@ -0,0 +1,23 @@
+<ion-header>
+  <ion-toolbar>
+    <ion-buttons slot="start">
+      <ion-back-button defaultHref="/previous-page"></ion-back-button>
+    </ion-buttons>
+    <ion-title>消息</ion-title>
+  </ion-toolbar>
+</ion-header>
+
+<ion-content>
+  <ion-list>
+    <ion-item *ngFor="let message of messages">
+      <ion-avatar slot="start">
+        <img src="{{message.avatar}}">
+      </ion-avatar>
+      <ion-label>
+        <h2>{{message.sender}}</h2>
+        <p>{{message.content}}</p>
+      </ion-label>
+      <ion-note slot="end">{{message.time}}</ion-note>
+    </ion-item>
+  </ion-list>
+</ion-content>

+ 23 - 0
src/app/mail/mail.page.scss

@@ -0,0 +1,23 @@
+ion-item {
+    --border-radius: 10px;
+  }
+  
+  ion-avatar {
+    width: 50px;
+    height: 50px;
+  }
+  
+  h2 {
+    font-size: 1.2em;
+    font-weight: bold;
+  }
+  
+  p {
+    font-size: 1em;
+    color: #333;
+  }
+  
+  ion-note {
+    font-size: 0.8em;
+    color: #999;
+  }

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

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

+ 17 - 0
src/app/mail/mail.page.ts

@@ -0,0 +1,17 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+  selector: 'app-mail',
+  templateUrl: './mail.page.html',
+  styleUrls: ['./mail.page.scss'],
+})
+
+export class MailPage {
+  messages = [
+    { avatar: 'assets/avatar1.jpg', sender: 'Alice', content: 'Hello!', time: '10:00 AM' },
+    { avatar: 'assets/avatar2.jpg', sender: 'Bob', content: 'Hi there!', time: '10:05 AM' },
+    // Add more message objects as needed
+  ];
+
+  constructor() {}
+}

+ 1 - 1
src/app/person/person.page.html

@@ -12,7 +12,7 @@
    
       <div class="container">
         <div class="icon-group">
-          <ion-icon name="mail-outline" class="icon"></ion-icon>
+          <ion-icon name="mail-outline" class="icon" (click)="goToMailPage()"></ion-icon>
           <ion-icon name="settings-outline" class="icon" (click)="goToSettingPage()"></ion-icon>
         </div>
       </div>

+ 3 - 1
src/app/person/person.page.ts

@@ -25,5 +25,7 @@ export class PersonPage  {
     this.router.navigate(['/setting']); // 替换成你的 setting 页面路由路径
   }
 
-
+  goToMailPage() {
+    this.router.navigate(['/mail']); // 替换成你的 setting 页面路由路径
+  }
 }

+ 1 - 1
src/app/search/search.page.html

@@ -3,7 +3,7 @@
     <ion-buttons slot="start">
       <ion-back-button></ion-back-button>
     </ion-buttons>
-    <ion-title>搜索</ion-title>
+    <ion-title>search</ion-title>
   </ion-toolbar>
 </ion-header>