浏览代码

feat(book-app): 添加小说展示功能并优化页面布局

18460000105 4 月之前
父节点
当前提交
e32dd7d5a3

+ 1 - 0
book-app/src/app/app.routes.ts

@@ -1,6 +1,7 @@
 import { Routes } from '@angular/router';
 
 export const routes: Routes = [
+  
   {
     path: '',
     loadChildren: () => import('./tabs/tabs.routes').then((m) => m.routes),

+ 25 - 0
book-app/src/app/show-novel/show-novel.component.html

@@ -0,0 +1,25 @@
+
+
+
+<ion-content>
+  <h1>热门小说</h1>
+  <ion-grid>
+    <ion-row>
+      <ion-col size="6" *ngFor="let novel of novels">
+        <ion-card>
+          <img [src]="novel.image" alt="{{novel.title}}" />
+          <ion-card-header>
+            <ion-card-title>{{novel.title}}</ion-card-title>
+          </ion-card-header>
+          <ion-card-content>
+            <p>{{novel.description}}</p>
+            <ion-button fill="outline" expand="full">
+              <ion-icon slot="start" name="book"></ion-icon>
+              阅读
+            </ion-button>
+          </ion-card-content>
+        </ion-card>
+      </ion-col>
+    </ion-row>
+  </ion-grid>
+</ion-content>

+ 15 - 0
book-app/src/app/show-novel/show-novel.component.scss

@@ -0,0 +1,15 @@
+ion-card {
+  display: flex;
+  flex-direction: column;
+  align-items: center; /* 水平居中 */
+  justify-content: center; /* 垂直居中 */
+  text-align: center; /* 文字居中 */
+}
+
+ion-card img {
+  // width: 280px;
+  height: 384px;
+  max-width: 100%; /* 限制图片宽度 */
+
+  margin-bottom: 10px; /* 图片与标题之间的间距 */
+}

+ 22 - 0
book-app/src/app/show-novel/show-novel.component.spec.ts

@@ -0,0 +1,22 @@
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
+
+import { ShowNovelComponent } from './show-novel.component';
+
+describe('ShowNovelComponent', () => {
+  let component: ShowNovelComponent;
+  let fixture: ComponentFixture<ShowNovelComponent>;
+
+  beforeEach(waitForAsync(() => {
+    TestBed.configureTestingModule({
+      imports: [ShowNovelComponent],
+    }).compileComponents();
+
+    fixture = TestBed.createComponent(ShowNovelComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  }));
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 36 - 0
book-app/src/app/show-novel/show-novel.component.ts

@@ -0,0 +1,36 @@
+import { NgForOf } from '@angular/common';
+import { Component } from '@angular/core';
+import { IonButton, IonCard, IonCardContent, IonCardHeader, IonCardTitle, IonCol, IonContent, IonGrid, IonHeader, IonRow, IonTitle, IonToolbar } from '@ionic/angular/standalone';
+import { IonIcon } from '@ionic/angular/standalone';
+
+@Component({
+  selector: 'app-show-novel',
+  standalone: true,
+  templateUrl: './show-novel.component.html',
+  styleUrls: ['./show-novel.component.scss'],
+  imports: [
+    IonHeader,IonToolbar,IonTitle,IonContent,IonGrid,IonRow,IonCol,IonCard,IonCardHeader,IonCardTitle,IonCardContent,IonButton,IonIcon,NgForOf
+  ]
+
+
+})
+export class ShowNovelComponent {
+  novels = [
+    {
+      title: '我在精神病院学斩神',
+      description: '若黯夜降临,吾必立于万万人前,横刀向渊,血染苍穹',
+      image: 'assets/img/1.png' // 请替换为实际图片路径
+    },
+    {
+      title: '诡舍',
+      description: '日子无聊没活力?看看诡舍刺激刺激',
+      image: 'assets/img/2.png' // 请替换为实际图片路径
+    },
+    // {
+    //   title: '小说3',
+    //   description: '这是小说3的简短描述。',
+    //   image: 'assets/img/1.png' // 请替换为实际图片路径
+    // },
+    // 可以继续添加更多小说
+  ];
+}

+ 0 - 0
book-app/src/app/tab1/book-app/src/assets/img/1.png


+ 9 - 7
book-app/src/app/tab1/tab1.page.html

@@ -6,19 +6,18 @@
   </ion-toolbar>
 </ion-header>
 
+
+
 <ion-content [fullscreen]="true">
   <h1>
     生成器列表
   </h1>
   
-  <ion-button expand="full" class="custom-button">
-    点击我
-    <img src="1.png" alt="底部图片" class="button-image" />
-  </ion-button>
+
   <div class="inquery" style="margin-top: 10px">
     <div class="inquery-ai">
-    <ion-button expand="full" (click)="getPlantingPlan()">
-    <img src="1.png" alt="" slot="start">
+    <ion-button expand="full" (click)="goToPage3()">
+    <!-- <img src="assets\img\1.png" alt="" slot="start"> -->
     取名生成器</ion-button>
 </div>
 
@@ -36,7 +35,10 @@
 <div class="inquery-human">
     <ion-button expand="full" (click)="goToPage2()">图片生成器</ion-button>
   </div>
+  
 </div>
 
-  
 </ion-content>
+
+
+

+ 6 - 1
book-app/src/app/tab1/tab1.page.ts

@@ -1,14 +1,16 @@
+import { ShowNovelComponent } from './../show-novel/show-novel.component';
 import { Component } from '@angular/core';
 import { IonHeader, IonToolbar, IonTitle, IonContent,IonButton } from '@ionic/angular/standalone';
 import { ExploreContainerComponent } from '../explore-container/explore-container.component';
 import { Router } from '@angular/router'; 
 
 @Component({
+
   selector: 'app-tab1',
   templateUrl: 'tab1.page.html',
   styleUrls: ['tab1.page.scss'],
   standalone: true,
-  imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,IonButton],
+  imports: [IonHeader, IonToolbar, IonTitle, IonContent,ShowNovelComponent, ExploreContainerComponent,IonButton],
 })
 export class Tab1Page {
  
@@ -23,6 +25,9 @@ export class Tab1Page {
   goToPage2(){
     this.router.navigate(['/tabs/picture'])
   }
+  goToPage3(){
+    this.router.navigate(['/tabs/show'])
+  }
   
  
 }

+ 3 - 2
book-app/src/app/tab2/tab2.page.html

@@ -1,7 +1,7 @@
 <ion-header [translucent]="true">
   <ion-toolbar>
     <ion-title>
-      Tab 2
+     视野
     </ion-title>
   </ion-toolbar>
 </ion-header>
@@ -13,5 +13,6 @@
     </ion-toolbar>
   </ion-header>
 
-  <app-explore-container name="Tab 2 page"></app-explore-container>
+  <app-show-novel></app-show-novel> <!-- 使用 ShowNovelComponent -->
+
 </ion-content>

+ 4 - 3
book-app/src/app/tab2/tab2.page.ts

@@ -1,13 +1,14 @@
+import { ShowNovelComponent } from './../show-novel/show-novel.component';
 import { Component } from '@angular/core';
-import { IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/angular/standalone';
+import { IonHeader, IonToolbar, IonTitle, IonContent,IonButton } from '@ionic/angular/standalone';
 import { ExploreContainerComponent } from '../explore-container/explore-container.component';
-
+import { Router } from '@angular/router'; 
 @Component({
   selector: 'app-tab2',
   templateUrl: 'tab2.page.html',
   styleUrls: ['tab2.page.scss'],
   standalone: true,
-  imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent]
+  imports: [IonHeader, IonToolbar, IonTitle, IonContent,ShowNovelComponent, ExploreContainerComponent,IonButton,IonContent],
 })
 export class Tab2Page {
 

+ 5 - 0
book-app/src/app/tabs/tabs.routes.ts

@@ -37,6 +37,11 @@ export const routes: Routes = [
         loadComponent: () =>
           import('../book-picture/book-picture.component').then((m) => m.BookPictureComponent),
       },
+      {
+        path: 'show',
+        loadComponent: () =>
+          import('../show-novel/show-novel.component').then((m) => m.ShowNovelComponent),
+      },
       {
         path: '',
         redirectTo: '/tabs/tab1',

二进制
book-app/src/assets/img/1.png


+ 0 - 0
book-app/src/app/tab1/1.png → book-app/src/assets/img/1000.png


二进制
book-app/src/assets/img/2.png


+ 0 - 0
book-app/src/assets/shapes.svg → book-app/src/assets/img/shapes.svg