Browse Source

取消了加号唤起窗口

追梦人 1 tuần trước cách đây
mục cha
commit
856cf9dd4c

+ 11 - 7
src/app/shared/task-card/task-card.component.ts

@@ -1,6 +1,5 @@
-import { Component, Input } from '@angular/core';
+import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
 import { IonicModule } from '@ionic/angular';
-import { Output, EventEmitter } from '@angular/core';
 
 @Component({
   selector: 'app-task-card',
@@ -9,18 +8,23 @@ import { Output, EventEmitter } from '@angular/core';
   standalone: true,
   imports: [IonicModule]
 })
-export class TaskCardComponent {
+export class TaskCardComponent implements OnInit {
   @Input() id: string = '';
-  @Input() title = '';
-  @Input() tags: string[] = [];
-  @Input() dueDate = '';
-  @Input() dueTime = '';
+  @Input() title = '未命名任务';
+  @Input() tags: string[] = ['默认标签'];
+  @Input() dueDate: string = new Date().toLocaleDateString();
+  @Input() dueTime: string = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
   @Input() subtasksCount = 0;
 
 // 导入 Output 和 EventEmitter
 @Output() cardClick = new EventEmitter<string>();
 
+  ngOnInit() {
+    console.log('卡片组件已初始化 | ID:', this.id, '标题:', this.title);
+  }
+
   onClick() {
+    console.debug('[DEBUG] 卡片点击 | ID:', this.id);
     this.cardClick.emit(this.id);
   }
 }

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

@@ -23,5 +23,6 @@
     [tags]="card.tags"
     [dueTime]="card.dueTime"
     [subtasksCount]="card.subtasks?.length || 0"
+    (cardClick)="handleCardAction($event)"
   ></app-task-card>
 </ion-content>

+ 12 - 12
src/app/tab1/tab1.page.ts

@@ -14,24 +14,24 @@ import { IonHeader, IonToolbar, IonTitle, IonContent, IonFab, IonFabButton, IonI
 })
 export class Tab1Page {
   currentDate: string;
-  cards: any[] = []; // 初始化空数组
+  cards: any[] = [];
 
   constructor(private dataService: DataService, private modalCtrl: ModalController) {
     this.currentDate = new Date().toLocaleDateString();
   }
 
-  async openTaskModal() {
-    const modal = await this.modalCtrl.create({
-      component: TaskModalComponent
-    });
-
-    modal.onDidDismiss().then(({ data }) => {
-      if (data) {
-        this.dataService.addCard(data);
-      }
-    });
+  handleCardAction(cardId: string) {
+    this.dataService.removeCard(cardId);
+  }
 
-    await modal.present();
+  openTaskModal() {
+    const newCard = {
+      id: Date.now().toString(),
+      title: '新任务',
+      tags: [],
+      dueTime: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
+    };
+    this.cards.push(newCard);
   }
 
   ngOnInit() {